Ensure all uses of R8 runtime classpath are consistent
Change-Id: I703c8416f98465822aef2523868afc91369a8f1d
diff --git a/d8_r8/test/build.gradle.kts b/d8_r8/test/build.gradle.kts
index c2f5a0b..cd93eb6 100644
--- a/d8_r8/test/build.gradle.kts
+++ b/d8_r8/test/build.gradle.kts
@@ -353,7 +353,7 @@
"KEEP_ANNO_JAVAC_BUILD_DIR", keepAnnoCompileTask.getOutputs().getFiles().getAsPath())
systemProperty("EXAMPLES_JAVA_11_JAVAC_BUILD_DIR",
getRoot().resolveAll("build", "test", "examplesJava11", "classes"))
- systemProperty("R8_RUNTIME_PATH", r8LibJar)
+ systemProperty("BUILD_PROP_R8_RUNTIME_PATH", r8LibJar)
systemProperty("R8_DEPS", mainDepsJarTask.getSingleOutputFile())
systemProperty("com.android.tools.r8.artprofilerewritingcompletenesscheck", "true")
diff --git a/d8_r8/test_modules/tests_bootstrap/build.gradle.kts b/d8_r8/test_modules/tests_bootstrap/build.gradle.kts
index f3dc100..0546ffa 100644
--- a/d8_r8/test_modules/tests_bootstrap/build.gradle.kts
+++ b/d8_r8/test_modules/tests_bootstrap/build.gradle.kts
@@ -81,7 +81,7 @@
layout.buildDirectory.dir("classes/java/test").get().toString())
systemProperty("KEEP_ANNO_JAVAC_BUILD_DIR", keepAnnoCompileTask.outputs.files.getAsPath())
systemProperty("R8_WITH_RELOCATED_DEPS", mainR8RelocatedTask.outputs.files.singleFile)
- systemProperty("R8_RUNTIME_PATH", mainR8RelocatedTask.outputs.files.singleFile)
+ systemProperty("BUILD_PROP_R8_RUNTIME_PATH", mainR8RelocatedTask.outputs.files.singleFile)
}
val testJar by registering(Jar::class) {
diff --git a/d8_r8/test_modules/tests_java_8/build.gradle.kts b/d8_r8/test_modules/tests_java_8/build.gradle.kts
index f2f8725..99e0219 100644
--- a/d8_r8/test_modules/tests_java_8/build.gradle.kts
+++ b/d8_r8/test_modules/tests_java_8/build.gradle.kts
@@ -137,10 +137,11 @@
systemProperty("EXAMPLES_JAVA_11_JAVAC_BUILD_DIR",
getRoot().resolveAll("build", "test", "examplesJava11", "classes"))
systemProperty(
- "R8_RUNTIME_PATH",
+ "BUILD_PROP_R8_RUNTIME_PATH",
mainCompileTask.outputs.files.getAsPath().split(File.pathSeparator)[0] +
File.pathSeparator + mainDepsJarTask.outputs.files.singleFile +
File.pathSeparator + getRoot().resolveAll("src", "main", "resources") +
+ File.pathSeparator + keepAnnoCompileTask.outputs.files.getAsPath().split(File.pathSeparator)[0] +
File.pathSeparator + resourceShrinkerJavaCompileTask.outputs.files.getAsPath().split(File.pathSeparator)[0] +
File.pathSeparator + resourceShrinkerKotlinCompileTask.outputs.files.getAsPath().split(File.pathSeparator)[1])
systemProperty("R8_DEPS", mainDepsJarTask.outputs.files.singleFile)
diff --git a/src/test/java/com/android/tools/r8/ExternalR8TestBuilder.java b/src/test/java/com/android/tools/r8/ExternalR8TestBuilder.java
index 52d8b52..247cb6a 100644
--- a/src/test/java/com/android/tools/r8/ExternalR8TestBuilder.java
+++ b/src/test/java/com/android/tools/r8/ExternalR8TestBuilder.java
@@ -38,7 +38,7 @@
ExternalR8TestBuilder> {
// The r8.jar to run.
- private List<Path> r8Classpath = ToolHelper.getClasspathForR8();
+ private List<Path> r8Classpath = ToolHelper.getBuildPropR8RuntimePath();
// Ordered list of program jar entries.
private final List<Path> programJars = new ArrayList<>();
diff --git a/src/test/java/com/android/tools/r8/ToolHelper.java b/src/test/java/com/android/tools/r8/ToolHelper.java
index 395f2ce..a06500a 100644
--- a/src/test/java/com/android/tools/r8/ToolHelper.java
+++ b/src/test/java/com/android/tools/r8/ToolHelper.java
@@ -110,6 +110,29 @@
return current + "/";
}
+ private static String getBuildProp(String prop) {
+ assert prop.startsWith("BUILD_PROP_");
+ String value = System.getProperty(prop);
+ assert value != null;
+ return value;
+ }
+
+ public static List<Path> getBuildPropR8RuntimePath() {
+ return ListUtils.map(
+ StringUtils.split(getBuildProp("BUILD_PROP_R8_RUNTIME_PATH"), File.pathSeparatorChar),
+ Paths::get);
+ }
+
+ public static String getExamplesJava11BuildDir() {
+ assert System.getProperty("EXAMPLES_JAVA_11_JAVAC_BUILD_DIR") != null;
+ return System.getProperty("EXAMPLES_JAVA_11_JAVAC_BUILD_DIR");
+ }
+
+ public static Path getKeepAnnoPath() {
+ assert System.getProperty("KEEP_ANNO_JAVAC_BUILD_DIR") != null;
+ return Paths.get(System.getProperty("KEEP_ANNO_JAVAC_BUILD_DIR").split(File.pathSeparator)[0]);
+ }
+
public enum TestDataSourceSet {
LEGACY(null),
TESTS_JAVA_8("tests_java_8/build/classes/java/test"),
@@ -171,29 +194,6 @@
public static final String EXAMPLES_JAVA11_JAR_DIR = TESTS_BUILD_DIR + "examplesJava11/";
public static final String SMALI_BUILD_DIR = THIRD_PARTY_DIR + "smali/";
- public static String getExamplesJava11BuildDir() {
- assert System.getProperty("EXAMPLES_JAVA_11_JAVAC_BUILD_DIR") != null;
- return System.getProperty("EXAMPLES_JAVA_11_JAVAC_BUILD_DIR");
- }
-
- public static Path getR8MainPath() {
- assert System.getProperty("R8_RUNTIME_PATH") != null;
- return Paths.get(System.getProperty("R8_RUNTIME_PATH"));
- }
-
- public static Path getRetracePath() {
- return getR8MainPath();
- }
-
- public static Path getKeepAnnoPath() {
- assert System.getProperty("KEEP_ANNO_JAVAC_BUILD_DIR") != null;
- return Paths.get(System.getProperty("KEEP_ANNO_JAVAC_BUILD_DIR").split(File.pathSeparator)[0]);
- }
-
- public static List<Path> getClasspathForR8() {
- return ImmutableList.of(getKeepAnnoPath(), getR8MainPath());
- }
-
public static final Path CHECKED_IN_R8_17_WITH_DEPS =
Paths.get(THIRD_PARTY_DIR).resolve("r8").resolve("r8_with_deps_17.jar");
diff --git a/src/test/java/com/android/tools/r8/compilerapi/CompilerApiTestCollection.java b/src/test/java/com/android/tools/r8/compilerapi/CompilerApiTestCollection.java
index fb86105..c50b238 100644
--- a/src/test/java/com/android/tools/r8/compilerapi/CompilerApiTestCollection.java
+++ b/src/test/java/com/android/tools/r8/compilerapi/CompilerApiTestCollection.java
@@ -114,7 +114,7 @@
// The API tests always link against the classpath that the test runner is using.
@Override
public List<Path> getTargetClasspath() {
- return ToolHelper.getClasspathForR8();
+ return ToolHelper.getBuildPropR8RuntimePath();
}
// Some tests expectations can depend on the lib/nonlib and internal/external behavior.
diff --git a/src/test/java/com/android/tools/r8/retrace/RetraceCommandLineTests.java b/src/test/java/com/android/tools/r8/retrace/RetraceCommandLineTests.java
index 2bc2ff9..2260cb6 100644
--- a/src/test/java/com/android/tools/r8/retrace/RetraceCommandLineTests.java
+++ b/src/test/java/com/android/tools/r8/retrace/RetraceCommandLineTests.java
@@ -346,7 +346,7 @@
command.add(ToolHelper.getSystemJavaExecutable());
command.add("-ea");
command.add("-cp");
- command.add(ToolHelper.getRetracePath().toString());
+ command.add(RetraceTests.getRetraceClasspath());
command.add(mainEntryPointExternal);
command.addAll(args);
ProcessBuilder builder = new ProcessBuilder(command);
diff --git a/src/test/java/com/android/tools/r8/retrace/RetraceTests.java b/src/test/java/com/android/tools/r8/retrace/RetraceTests.java
index 95c8b5b..7212797 100644
--- a/src/test/java/com/android/tools/r8/retrace/RetraceTests.java
+++ b/src/test/java/com/android/tools/r8/retrace/RetraceTests.java
@@ -90,6 +90,7 @@
import com.android.tools.r8.utils.BooleanUtils;
import com.android.tools.r8.utils.StringUtils;
import com.google.common.collect.ImmutableList;
+import java.io.File;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.nio.file.Path;
@@ -515,6 +516,10 @@
return runRetraceTest(stackTraceForTest, true);
}
+ public static String getRetraceClasspath() {
+ return StringUtils.join(File.pathSeparator, ToolHelper.getBuildPropR8RuntimePath());
+ }
+
private TestDiagnosticMessagesImpl runRetraceTest(
StackTraceForTest stackTraceForTest, boolean allowExperimentalMapping) throws Exception {
String expectedStackTrace =
@@ -541,7 +546,7 @@
command.add(parameters.getRuntime().asCf().getJavaExecutable().toString());
command.add("-ea");
command.add("-cp");
- command.add(ToolHelper.getRetracePath().toString());
+ command.add(getRetraceClasspath());
if (allowExperimentalMapping) {
command.add("-Dcom.android.tools.r8.experimentalmapping");
}
diff --git a/src/test/java/com/android/tools/r8/retrace/api/RetraceApiTestCollection.java b/src/test/java/com/android/tools/r8/retrace/api/RetraceApiTestCollection.java
index 36aa7ce..ccee173 100644
--- a/src/test/java/com/android/tools/r8/retrace/api/RetraceApiTestCollection.java
+++ b/src/test/java/com/android/tools/r8/retrace/api/RetraceApiTestCollection.java
@@ -63,7 +63,7 @@
@Override
public List<Path> getTargetClasspath() {
- return ImmutableList.of(ToolHelper.getRetracePath());
+ return ToolHelper.getBuildPropR8RuntimePath();
}
@Override