summaryrefslogtreecommitdiffstats
path: root/jack-tests/src
diff options
context:
space:
mode:
authorBenoit Lamarche <benoitlamarche@google.com>2015-05-21 15:57:41 +0200
committerBenoit Lamarche <benoitlamarche@google.com>2015-05-29 11:55:12 +0200
commitc359103bc956a61f1e87081994617b62a78f1dc8 (patch)
tree96f342e1bf18ed87913028b189d1440a4cc7eaff /jack-tests/src
parent6007144b3ab9a8c59648fa35a0af920d2a64356e (diff)
downloadtoolchain_jack-c359103bc956a61f1e87081994617b62a78f1dc8.zip
toolchain_jack-c359103bc956a61f1e87081994617b62a78f1dc8.tar.gz
toolchain_jack-c359103bc956a61f1e87081994617b62a78f1dc8.tar.bz2
Adapt incremental tests to use InputJackLibary
(cherry picked from commit 097b5d6e807b250847ec9ff27f4a7ac7a336620f) Change-Id: I954bb80fe35fcc59043665400dd8331e2153427b
Diffstat (limited to 'jack-tests/src')
-rw-r--r--jack-tests/src/com/android/jack/test/helper/IncrementalTestHelper.java72
1 files changed, 37 insertions, 35 deletions
diff --git a/jack-tests/src/com/android/jack/test/helper/IncrementalTestHelper.java b/jack-tests/src/com/android/jack/test/helper/IncrementalTestHelper.java
index 0a8dc75..23ceaca 100644
--- a/jack-tests/src/com/android/jack/test/helper/IncrementalTestHelper.java
+++ b/jack-tests/src/com/android/jack/test/helper/IncrementalTestHelper.java
@@ -16,8 +16,9 @@
package com.android.jack.test.helper;
-import com.android.jack.backend.jayce.JayceFileImporter;
import com.android.jack.library.FileType;
+import com.android.jack.library.InputJackLibrary;
+import com.android.jack.library.InputJackLibraryCodec;
import com.android.jack.test.runner.AbstractRuntimeRunner;
import com.android.jack.test.runner.RuntimeRunner;
import com.android.jack.test.toolchain.AbstractTestTools;
@@ -26,6 +27,9 @@ import com.android.jack.test.toolchain.JackApiToolchainBase;
import com.android.jack.test.toolchain.JackBasedToolchain.MultiDexKind;
import com.android.jack.test.toolchain.JackCliToolchain;
import com.android.jack.test.toolchain.LegacyJillToolchain;
+import com.android.sched.util.codec.CodecContext;
+import com.android.sched.vfs.InputVFile;
+import com.android.sched.vfs.VPath;
import junit.framework.Assert;
@@ -37,6 +41,7 @@ import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
+import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Set;
@@ -60,11 +65,9 @@ public class IncrementalTestHelper {
@Nonnull
private final File compilerStateFolder;
@Nonnull
- private final File jackFolder;
- @Nonnull
private final Set<File> javaFiles = new HashSet<File>();
@Nonnull
- private final Map<String, Long> fileModificationDate = new HashMap<String, Long>();
+ private final Map<VPath, Long> fileModificationDate = new HashMap<VPath, Long>();
@Nonnull
private OutputStream out = System.out;
@Nonnull
@@ -82,12 +85,12 @@ public class IncrementalTestHelper {
if (!compilerStateFolder.exists() && !compilerStateFolder.mkdir()) {
throw new IOException("Failed to create folder " + compilerStateFolder.getAbsolutePath());
}
+
dexOutDir = new File(testingFolder, "outputBinary");
if (!dexOutDir.exists() && !dexOutDir.mkdir()) {
throw new IOException("Failed to create folder " + dexOutDir.getAbsolutePath());
}
dexFile = new File(dexOutDir, "classes.dex");
- jackFolder = new File(compilerStateFolder, FileType.JAYCE.getPrefix());
}
public void setOut(OutputStream out) {
@@ -126,20 +129,11 @@ public class IncrementalTestHelper {
}
public void snapshotJackFilesModificationDate() {
- List<File> jackFiles = new ArrayList<File>();
- fillJackFiles(jackFolder, jackFiles);
- for (File jackFile : jackFiles) {
- fileModificationDate.put(jackFile.getAbsolutePath(), Long.valueOf(jackFile.lastModified()));
- }
- }
-
- private void fillJackFiles(@Nonnull File file, @Nonnull List<File> jackFiles) {
- if (file.isDirectory()) {
- for (File subFile : file.listFiles()) {
- fillJackFiles(subFile, jackFiles);
- }
- } else if (file.getName().endsWith(JayceFileImporter.JAYCE_FILE_EXTENSION)) {
- jackFiles.add(file);
+ Iterator<InputVFile> jayceIter = getJayceIterator();
+ while (jayceIter.hasNext()) {
+ InputVFile jayceFile = jayceIter.next();
+ fileModificationDate.put(jayceFile.getPathFromRoot(),
+ Long.valueOf(jayceFile.getLastModified()));
}
}
@@ -148,20 +142,20 @@ public class IncrementalTestHelper {
assert !fileModificationDate.isEmpty();
List<String> fqnOfRebuiltTypes = new ArrayList<String>();
- List<File> jackFiles = new ArrayList<File>();
- fillJackFiles(jackFolder, jackFiles);
-
- for (File jackFile : jackFiles) {
- Long previousDate = fileModificationDate.get(jackFile.getAbsolutePath());
- if (previousDate == null || jackFile.lastModified() > previousDate.longValue()) {
- String jackFileName = jackFile.getAbsolutePath();
- String binaryTypeName = jackFileName.substring(0, jackFileName.indexOf(".jayce"));
- binaryTypeName = binaryTypeName.substring(jackFolder.getAbsolutePath().length() + 1);
- fqnOfRebuiltTypes.add(binaryTypeName.replace(File.separatorChar, '.'));
+ Iterator<InputVFile> jayceIter = getJayceIterator();
+ while (jayceIter.hasNext()) {
+ InputVFile jayceFile = jayceIter.next();
+ VPath path = jayceFile.getPathFromRoot();
+ Long previousDate = fileModificationDate.get(path);
+ if (previousDate == null || jayceFile.getLastModified() > previousDate.longValue()) {
+ String fqnWithExtension = path.getPathAsString('.');
+ String fqn = fqnWithExtension.substring(0,
+ fqnWithExtension.lastIndexOf(FileType.JAYCE.getFileExtension()));
+ fqnOfRebuiltTypes.add(fqn);
}
}
- return (fqnOfRebuiltTypes);
+ return fqnOfRebuiltTypes;
}
public void incrementalBuildFromFolder() throws Exception {
@@ -224,13 +218,21 @@ public class IncrementalTestHelper {
}
@Nonnull
- public File getJackFolder() {
- return jackFolder;
+ public Iterator<InputVFile> getJayceIterator() {
+ InputJackLibrary compilerStateLib =
+ new InputJackLibraryCodec().parseString(new CodecContext(), compilerStateFolder.getPath());
+
+ return compilerStateLib.iterator(FileType.JAYCE);
}
@Nonnull
- public List<File> getJackFiles() {
- return AbstractTestTools.getFiles(jackFolder, ".jayce");
+ public int getJayceCount() {
+ int size = 0;
+ Iterator<InputVFile> jayceIter = getJayceIterator();
+ while (jayceIter.hasNext()) {
+ size++;
+ jayceIter.next();
+ }
+ return size;
}
-
}