Update tests to work with jdk11 as the system runtime.
This is in preperation for updating the system runtime.
Bug: b/227300698
Change-Id: Ic21efb5002e89792d220a44cd8ac276724067431
diff --git a/buildSrc/src/main/java/dx/DexMergerTask.java b/buildSrc/src/main/java/dx/DexMergerTask.java
index 735afa7..5dea52b 100644
--- a/buildSrc/src/main/java/dx/DexMergerTask.java
+++ b/buildSrc/src/main/java/dx/DexMergerTask.java
@@ -10,17 +10,13 @@
import java.util.List;
import java.util.Set;
import javax.inject.Inject;
-import org.gradle.api.Action;
import org.gradle.api.DefaultTask;
-import org.gradle.api.UncheckedIOException;
import org.gradle.api.file.FileCollection;
import org.gradle.api.tasks.InputFile;
import org.gradle.api.tasks.InputFiles;
import org.gradle.api.tasks.OutputFile;
import org.gradle.api.tasks.TaskAction;
-import org.gradle.process.ExecSpec;
import org.gradle.workers.IsolationMode;
-import org.gradle.workers.WorkerConfiguration;
import org.gradle.workers.WorkerExecutor;
import utils.Utils;
@@ -67,19 +63,30 @@
@TaskAction
void exec() {
- workerExecutor.submit(RunDexMerger.class, config -> {
- config.setIsolationMode(IsolationMode.NONE);
- config.params(source.getFiles(), destination, dexMergerExecutable);
- });
+ workerExecutor.submit(
+ RunDexMerger.class,
+ config -> {
+ File executable =
+ dexMergerExecutable.isPresent()
+ ? dexMergerExecutable.get()
+ : config
+ .getForkOptions()
+ .getWorkingDir()
+ .toPath()
+ .resolve(Utils.dexMergerExecutable())
+ .toFile();
+ config.setIsolationMode(IsolationMode.NONE);
+ config.params(source.getFiles(), destination, executable);
+ });
}
public static class RunDexMerger implements Runnable {
private final Set<File> sources;
private final File destination;
- private final Optional<File> dexMergerExecutable;
+ private final File dexMergerExecutable;
@Inject
- public RunDexMerger(Set<File> sources, File destination, Optional<File> dexMergerExecutable) {
+ public RunDexMerger(Set<File> sources, File destination, File dexMergerExecutable) {
this.sources = sources;
this.destination = destination;
this.dexMergerExecutable = dexMergerExecutable;
@@ -89,7 +96,7 @@
public void run() {
try {
List<String> command = new ArrayList<>();
- command.add(dexMergerExecutable.or(Utils::dexMergerExecutable).getCanonicalPath());
+ command.add(dexMergerExecutable.getCanonicalPath());
command.add(destination.getCanonicalPath());
for (File source : sources) {
command.add(source.getCanonicalPath());
diff --git a/buildSrc/src/main/java/dx/DxTask.java b/buildSrc/src/main/java/dx/DxTask.java
index d8975dc..e05e8fb 100644
--- a/buildSrc/src/main/java/dx/DxTask.java
+++ b/buildSrc/src/main/java/dx/DxTask.java
@@ -75,20 +75,31 @@
@TaskAction
void exec() {
- workerExecutor.submit(RunDx.class, config -> {
- config.setIsolationMode(IsolationMode.NONE);
- config.params(source.getFiles(), destination, dxExecutable, debug);
- });
+ workerExecutor.submit(
+ RunDx.class,
+ config -> {
+ File executable =
+ dxExecutable.isPresent()
+ ? dxExecutable.get()
+ : config
+ .getForkOptions()
+ .getWorkingDir()
+ .toPath()
+ .resolve(Utils.dxExecutable())
+ .toFile();
+ config.setIsolationMode(IsolationMode.NONE);
+ config.params(source.getFiles(), destination, executable, debug);
+ });
}
public static class RunDx implements Runnable {
private final Set<File> sources;
private final File destination;
- private final Optional<File> dxExecutable;
+ private final File dxExecutable;
private final boolean debug;
@Inject
- public RunDx(Set<File> sources, File destination, Optional<File> dxExecutable, boolean debug) {
+ public RunDx(Set<File> sources, File destination, File dxExecutable, boolean debug) {
this.sources = sources;
this.destination = destination;
this.dxExecutable = dxExecutable;
@@ -99,7 +110,7 @@
public void run() {
try {
List<String> command = new ArrayList<>();
- command.add(dxExecutable.or(Utils::dxExecutable).getCanonicalPath());
+ command.add(dxExecutable.getCanonicalPath());
command.add("--dex");
command.add("--output");
command.add(destination.getCanonicalPath());
diff --git a/buildSrc/src/main/java/utils/Utils.java b/buildSrc/src/main/java/utils/Utils.java
index 7843edd..7f09b81 100644
--- a/buildSrc/src/main/java/utils/Utils.java
+++ b/buildSrc/src/main/java/utils/Utils.java
@@ -3,7 +3,8 @@
// BSD-style license that can be found in the LICENSE file.
package utils;
-import java.io.File;
+import java.nio.file.Path;
+import java.nio.file.Paths;
public class Utils {
public static String toolsDir() {
@@ -17,13 +18,17 @@
}
}
- public static File dxExecutable() {
- String dxExecutableName = Utils.toolsDir().equals("windows") ? "dx.bat" : "dx";
- return new File("tools/" + Utils.toolsDir() + "/dx/bin/" + dxExecutableName);
+ public static boolean isWindows() {
+ return toolsDir().equals("windows");
}
- public static File dexMergerExecutable() {
- String executableName = Utils.toolsDir().equals("windows") ? "dexmerger.bat" : "dexmerger";
- return new File("tools/" + Utils.toolsDir() + "/dx/bin/" + executableName);
+ public static Path dxExecutable() {
+ String dxExecutableName = isWindows() ? "dx.bat" : "dx";
+ return Paths.get("tools", toolsDir(), "dx", "bin", dxExecutableName);
+ }
+
+ public static Path dexMergerExecutable() {
+ String executableName = isWindows() ? "dexmerger.bat" : "dexmerger";
+ return Paths.get("tools", toolsDir(), "dx", "bin", executableName);
}
}
diff --git a/src/test/java/com/android/tools/r8/TestParameters.java b/src/test/java/com/android/tools/r8/TestParameters.java
index a9b67e3..555c7fa 100644
--- a/src/test/java/com/android/tools/r8/TestParameters.java
+++ b/src/test/java/com/android/tools/r8/TestParameters.java
@@ -31,6 +31,10 @@
this.apiLevel = apiLevel;
}
+ public static TestParametersCollection justNoneRuntime() {
+ return TestParametersBuilder.builder().withNoneRuntime().build();
+ }
+
public boolean canUseDefaultAndStaticInterfaceMethods() {
assert isCfRuntime() || isDexRuntime();
assert !isCfRuntime() || apiLevel == null
diff --git a/src/test/java/com/android/tools/r8/TestRuntime.java b/src/test/java/com/android/tools/r8/TestRuntime.java
index 336ffd1..06d9c18 100644
--- a/src/test/java/com/android/tools/r8/TestRuntime.java
+++ b/src/test/java/com/android/tools/r8/TestRuntime.java
@@ -189,7 +189,7 @@
if (version.startsWith("9.")) {
return new CfRuntime(CfVm.JDK9, Paths.get(home));
}
- if (version.startsWith("11.")) {
+ if (version.equals("11")) {
return new CfRuntime(CfVm.JDK11, Paths.get(home));
}
throw new Unimplemented("No support for JDK version: " + version);
diff --git a/src/test/java/com/android/tools/r8/jasmin/InvalidClassNames.java b/src/test/java/com/android/tools/r8/jasmin/InvalidClassNames.java
index bd462b7..b8378c3 100644
--- a/src/test/java/com/android/tools/r8/jasmin/InvalidClassNames.java
+++ b/src/test/java/com/android/tools/r8/jasmin/InvalidClassNames.java
@@ -3,8 +3,7 @@
// BSD-style license that can be found in the LICENSE file.
package com.android.tools.r8.jasmin;
-
-import com.android.tools.r8.ToolHelper;
+import com.android.tools.r8.TestParameters;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
@@ -23,32 +22,19 @@
@Parameters(name = "\"{0}\", jvm: {1}, art: {2}")
public static Collection<Object[]> data() {
Collection<Object[]> data = new ArrayList<>();
- data.addAll(NameTestBase.getCommonNameTestData(true));
- data.addAll(
- Arrays.asList(
- new Object[][] {
- {new TestString("a/b/c/a/D/"), true, false},
- {
- new TestString("a<b"),
- !ToolHelper.isWindows() && !ToolHelper.isJava9Runtime(),
- false
- },
- {
- new TestString("a>b"),
- !ToolHelper.isWindows() && !ToolHelper.isJava9Runtime(),
- false
- },
- {
- new TestString("<a>b"),
- !ToolHelper.isWindows() && !ToolHelper.isJava9Runtime(),
- false
- },
- {
- new TestString("<a>"),
- !ToolHelper.isWindows() && !ToolHelper.isJava9Runtime(),
- false
- }
- }));
+ for (TestParameters parameter : TestParameters.justNoneRuntime()) {
+ parameter.assertNoneRuntime();
+ data.addAll(NameTestBase.getCommonNameTestData());
+ data.addAll(
+ Arrays.asList(
+ new Object[][] {
+ {new TestString("a/b/c/a/D/"), true, false},
+ {new TestString("a<b"), false, false},
+ {new TestString("a>b"), false, false},
+ {new TestString("<a>b"), false, false},
+ {new TestString("<a>"), false, false}
+ }));
+ }
return data;
}
diff --git a/src/test/java/com/android/tools/r8/jasmin/InvalidFieldNames.java b/src/test/java/com/android/tools/r8/jasmin/InvalidFieldNames.java
index 8f680ee..cea2557 100644
--- a/src/test/java/com/android/tools/r8/jasmin/InvalidFieldNames.java
+++ b/src/test/java/com/android/tools/r8/jasmin/InvalidFieldNames.java
@@ -3,7 +3,7 @@
// BSD-style license that can be found in the LICENSE file.
package com.android.tools.r8.jasmin;
-import com.android.tools.r8.ToolHelper;
+import com.android.tools.r8.TestParameters;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
@@ -21,17 +21,20 @@
@Parameters(name = "\"{0}\", jvm: {1}, art: {2}")
public static Collection<Object[]> data() {
Collection<Object[]> data = new ArrayList<>();
- data.addAll(NameTestBase.getCommonNameTestData(false));
- data.addAll(
- Arrays.asList(
- new Object[][] {
- {new TestString("a/b"), false, false},
- {new TestString("<a"), !ToolHelper.isJava9Runtime(), false},
- {new TestString("a>"), !ToolHelper.isJava9Runtime(), false},
- {new TestString("a<b>"), !ToolHelper.isJava9Runtime(), false},
- {new TestString("<a>b"), !ToolHelper.isJava9Runtime(), false},
- {new TestString("<a>"), false, true}
- }));
+ for (TestParameters parameter : TestParameters.justNoneRuntime()) {
+ parameter.assertNoneRuntime();
+ data.addAll(NameTestBase.getCommonNameTestData());
+ data.addAll(
+ Arrays.asList(
+ new Object[][] {
+ {new TestString("a/b"), false, false},
+ {new TestString("<a"), false, false},
+ {new TestString("a>"), false, false},
+ {new TestString("a<b>"), false, false},
+ {new TestString("<a>b"), false, false},
+ {new TestString("<a>"), false, true}
+ }));
+ }
return data;
}
diff --git a/src/test/java/com/android/tools/r8/jasmin/InvalidMethodNames.java b/src/test/java/com/android/tools/r8/jasmin/InvalidMethodNames.java
index fa2882e..0327b76 100644
--- a/src/test/java/com/android/tools/r8/jasmin/InvalidMethodNames.java
+++ b/src/test/java/com/android/tools/r8/jasmin/InvalidMethodNames.java
@@ -3,8 +3,7 @@
// BSD-style license that can be found in the LICENSE file.
package com.android.tools.r8.jasmin;
-
-import com.android.tools.r8.ToolHelper;
+import com.android.tools.r8.TestParameters;
import com.google.common.collect.ImmutableList;
import java.util.ArrayList;
import java.util.Arrays;
@@ -27,15 +26,18 @@
@Parameters(name = "\"{0}\", jvm: {1}, art: {2}")
public static Collection<Object[]> data() {
Collection<Object[]> data = new ArrayList<>();
- data.addAll(NameTestBase.getCommonNameTestData(false));
- data.addAll(
- Arrays.asList(
- new Object[][] {
- {new TestString("a/b"), false, false},
- {new TestString("<a"), false, false},
- {new TestString("a>"), !ToolHelper.isJava9Runtime(), false},
- {new TestString("<a>"), false, false}
- }));
+ for (TestParameters parameter : TestParameters.justNoneRuntime()) {
+ parameter.assertNoneRuntime();
+ data.addAll(NameTestBase.getCommonNameTestData());
+ data.addAll(
+ Arrays.asList(
+ new Object[][] {
+ {new TestString("a/b"), false, false},
+ {new TestString("<a"), false, false},
+ {new TestString("a>"), false, false},
+ {new TestString("<a>"), false, false}
+ }));
+ }
return data;
}
diff --git a/src/test/java/com/android/tools/r8/jasmin/NameTestBase.java b/src/test/java/com/android/tools/r8/jasmin/NameTestBase.java
index 594bdbe..0b335a9 100644
--- a/src/test/java/com/android/tools/r8/jasmin/NameTestBase.java
+++ b/src/test/java/com/android/tools/r8/jasmin/NameTestBase.java
@@ -39,51 +39,43 @@
// - Name (String) to test (can be class name, field name, method name).
// - boolean, whether it runs on the JVM.
// - boolean, whether it runs on the ART.
- static Collection<Object[]> getCommonNameTestData(boolean classNames) {
-
- boolean windowsSensitive = classNames && ToolHelper.isWindows();
+ static Collection<Object[]> getCommonNameTestData() {
boolean supportSpaces = ToolHelper.getMinApiLevelForDexVm().getLevel()
>= AndroidApiLevel.R.getLevel();
- boolean java9 = ToolHelper.isJava9Runtime();
-
return Arrays.asList(
new Object[][] {
{new TestString("azAZ09$_"), true, true},
- {new TestString("_"), !java9, true},
- {new TestString("a-b"), !java9, true},
- {new TestString("\u00a0"), !java9, supportSpaces},
- {new TestString("\u00a1"), !java9, true},
- {new TestString("\u1fff"), !java9, true},
- {new TestString("\u2000"), !windowsSensitive && !java9, supportSpaces},
- {new TestString("\u200f"), !windowsSensitive && !java9, false},
- {new TestString("\u2010"), !windowsSensitive && !java9, true},
- {new TestString("\u2027"), !windowsSensitive && !java9, true},
- {new TestString("\u2028"), !windowsSensitive && !java9, false},
- {new TestString("\u202f"), !windowsSensitive && !java9, supportSpaces},
- {new TestString("\u2030"), !windowsSensitive && !java9, true},
- {new TestString("\ud7ff"), !windowsSensitive && !java9, true},
- {new TestString("\ue000"), !windowsSensitive && !java9, true},
- {new TestString("\uffef"), !windowsSensitive && !java9, true},
- {new TestString("\ufff0"), !windowsSensitive && !java9, false},
- {new TestString("\uffff"), !windowsSensitive && !java9, false},
+ {new TestString("_"), false, true},
+ {new TestString("a-b"), false, true},
+ {new TestString("\u00a0"), false, supportSpaces},
+ {new TestString("\u00a1"), false, true},
+ {new TestString("\u1fff"), false, true},
+ {new TestString("\u2000"), false, supportSpaces},
+ {new TestString("\u200f"), false, false},
+ {new TestString("\u2010"), false, true},
+ {new TestString("\u2027"), false, true},
+ {new TestString("\u2028"), false, false},
+ {new TestString("\u202f"), false, supportSpaces},
+ {new TestString("\u2030"), false, true},
+ {new TestString("\ud7ff"), false, true},
+ {new TestString("\ue000"), false, true},
+ {new TestString("\uffef"), false, true},
+ {new TestString("\ufff0"), false, false},
+ {new TestString("\uffff"), false, false},
// Standalone high and low surrogates.
- {new TestString("\ud800"), !classNames && !java9, false},
- {new TestString("\udbff"), !classNames && !java9, false},
- {new TestString("\udc00"), !classNames && !java9, false},
- {new TestString("\udfff"), !classNames && !java9, false},
+ {new TestString("\ud800"), false, false},
+ {new TestString("\udbff"), false, false},
+ {new TestString("\udc00"), false, false},
+ {new TestString("\udfff"), false, false},
// Single and double code points above 0x10000.
{new TestString("\ud800\udc00"), true, true},
{new TestString("\ud800\udcfa"), true, true},
- {new TestString("\ud800\udcfb"), !windowsSensitive && !java9, true},
- {new TestString("\udbff\udfff"), !windowsSensitive && !java9, true},
+ {new TestString("\ud800\udcfb"), false, true},
+ {new TestString("\udbff\udfff"), false, true},
{new TestString("\ud800\udc00\ud800\udcfa"), true, true},
- {
- new TestString("\ud800\udc00\udbff\udfff"),
- !windowsSensitive && !java9,
- true
- }
+ {new TestString("\ud800\udc00\udbff\udfff"), false, true}
});
}
diff --git a/tools/jdk.py b/tools/jdk.py
index 23cacc8..ea6be86 100755
--- a/tools/jdk.py
+++ b/tools/jdk.py
@@ -3,14 +3,18 @@
# for details. All rights reserved. Use of this source code is governed by a
# BSD-style license that can be found in the LICENSE file.
-import defines
import os
import sys
+import defines
+
JDK_DIR = os.path.join(defines.THIRD_PARTY, 'openjdk')
def GetJdkHome():
- root = os.path.join(JDK_DIR, 'openjdk-9.0.4')
+ return GetJdk9Home()
+
+def GetJdk11Home():
+ root = os.path.join(JDK_DIR, 'jdk-11')
if defines.IsLinux():
return os.path.join(root, 'linux')
elif defines.IsOsX():
@@ -20,8 +24,8 @@
else:
return os.environ['JAVA_HOME']
-def GetJdk11Home():
- root = os.path.join(JDK_DIR, 'jdk-11')
+def GetJdk9Home():
+ root = os.path.join(JDK_DIR, 'openjdk-9.0.4')
if defines.IsLinux():
return os.path.join(root, 'linux')
elif defines.IsOsX():