Revert "Run Kotlin tests on 1.6 and 1.8 target versions"
This reverts commit f92ad05c4fd126f5760fd989ee096d79b426f668.
Reason for revert: fails on Windows due to dx incompatibility
Bug: 71894643
Change-Id: Id7fcbc3a8f66b552c8b8ec24d19023bccca6681b
diff --git a/build.gradle b/build.gradle
index af7bb41..e0d28fa 100644
--- a/build.gradle
+++ b/build.gradle
@@ -793,33 +793,25 @@
include "**/*.class"
}
def kotlinResourcesDir = file("src/test/debugTestResourcesKotlin")
- kotlin.Kotlinc.KotlinTargetVersion.values().each { kotlinTargetVersion ->
- def kotlinHostJar = "debug_test_resources_kotlin_${kotlinTargetVersion}.jar"
- def taskName = "jar_debugTestResourcesKotlin_${kotlinTargetVersion}"
- task "$taskName"(type: kotlin.Kotlinc) {
- source = fileTree(dir: kotlinResourcesDir, include: '**/*.kt')
- destination = file("build/test/${kotlinHostJar}")
- targetVersion = kotlinTargetVersion;
- }
- dependsOn taskName
+ def kotlinHostJar = "debug_test_resources_kotlin.jar"
+ task "jar_debugTestResourcesKotlin"(type: kotlin.Kotlinc) {
+ source = fileTree(dir: kotlinResourcesDir, include: '**/*.kt')
+ destination = file("build/test/${kotlinHostJar}")
}
dependsOn downloadDeps
dependsOn jar_debugTestResources
dependsOn jar_debugTestResourcesJava8
+ dependsOn jar_debugTestResourcesKotlin
}
task buildExampleKotlinJars {
def kotlinSrcDir = file("src/test/examplesKotlin")
kotlinSrcDir.eachDir { dir ->
- kotlin.Kotlinc.KotlinTargetVersion.values().each { kotlinTargetVersion ->
- def name = dir.getName();
- def taskName = "compile_example_kotlin_${name}_${kotlinTargetVersion}"
- dependsOn taskName
- task "${taskName}"(type: kotlin.Kotlinc) {
- source = fileTree(dir: file("src/test/examplesKotlin/${name}"), include: '**/*.kt')
- destination = file("build/test/examplesKotlin/${kotlinTargetVersion}/${name}.jar")
- targetVersion = kotlinTargetVersion;
- }
+ def name = dir.getName();
+ dependsOn "compile_example_kotlin_${name}"
+ task "compile_example_kotlin_${name}"(type: kotlin.Kotlinc) {
+ source = fileTree(dir: file("src/test/examplesKotlin/${name}"), include: '**/*.kt')
+ destination = file("build/test/examplesKotlin/${name}.jar")
}
}
}
@@ -1123,23 +1115,20 @@
}
def examplesDir = file("src/test/examplesKotlin")
examplesDir.eachDir { dir ->
- kotlin.Kotlinc.KotlinTargetVersion.values().each { kotlinTargetVersion ->
- def name = dir.getName();
- def compileTaskName = "compile_example_kotlin_${name}_${kotlinTargetVersion}"
- def dexTaskName = "dex_example_kotlin_${name}_${kotlinTargetVersion}"
- dependsOn dexTaskName
- def exampleOutputDir = file("build/test/examplesKotlin/${kotlinTargetVersion}/" + name);
- def dexPath = file("${exampleOutputDir}")
- task "${dexTaskName}"(type: dx.Dx, dependsOn: "${compileTaskName}") {
- doFirst {
- if (!dexPath.exists()) {
- dexPath.mkdirs()
- }
+ def name = dir.getName();
+ dependsOn "dex_example_kotlin_${name}"
+ def exampleOutputDir = file("build/test/examplesKotlin/" + name);
+ def dexPath = file("${exampleOutputDir}")
+ task "dex_example_kotlin_${name}"(type: dx.Dx,
+ dependsOn: "compile_example_kotlin_${name}") {
+ doFirst {
+ if (!dexPath.exists()) {
+ dexPath.mkdirs()
}
- source = files(tasks.getByPath("${compileTaskName}")).asFileTree
- destination = dexPath
- debug = false
}
+ source = files(tasks.getByPath("compile_example_kotlin_${name}")).asFileTree
+ destination = dexPath
+ debug = false
}
}
}
diff --git a/buildSrc/src/main/java/kotlin/Kotlinc.java b/buildSrc/src/main/java/kotlin/Kotlinc.java
index 5ee0992..261acc3 100644
--- a/buildSrc/src/main/java/kotlin/Kotlinc.java
+++ b/buildSrc/src/main/java/kotlin/Kotlinc.java
@@ -23,25 +23,12 @@
*/
public class Kotlinc extends DefaultTask {
- enum KotlinTargetVersion {
- JAVA_6("1.6"),
- JAVA_8("1.8");
-
- private final String optionName;
-
- KotlinTargetVersion(String optionName) {
- this.optionName = optionName;
- }
- }
-
@InputFiles
private FileTree source;
@OutputFile
private File destination;
- private KotlinTargetVersion targetVersion;
-
public FileTree getSource() {
return source;
}
@@ -58,14 +45,6 @@
this.destination = destination;
}
- public KotlinTargetVersion getTargetVersion() {
- return targetVersion;
- }
-
- public void setTargetVersion(KotlinTargetVersion targetVersion) {
- this.targetVersion = targetVersion;
- }
-
@TaskAction
public void compile() {
getProject().exec(new Action<ExecSpec>() {
@@ -78,7 +57,6 @@
execSpec.setExecutable(kotlincExecPath.toFile());
execSpec.args("-include-runtime");
execSpec.args("-nowarn");
- execSpec.args("-jvm-target", targetVersion.optionName);
execSpec.args("-d", destination.getCanonicalPath());
execSpec.args(source.getFiles());
} catch (IOException e) {
diff --git a/src/test/java/com/android/tools/r8/R8RunExamplesKotlinTest.java b/src/test/java/com/android/tools/r8/R8RunExamplesKotlinTest.java
index bc64392..02c2d27 100644
--- a/src/test/java/com/android/tools/r8/R8RunExamplesKotlinTest.java
+++ b/src/test/java/com/android/tools/r8/R8RunExamplesKotlinTest.java
@@ -4,7 +4,6 @@
package com.android.tools.r8;
import com.android.tools.r8.R8RunArtTestsTest.CompilerUnderTest;
-import com.android.tools.r8.ToolHelper.KotlinTargetVersion;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
@@ -18,42 +17,25 @@
@RunWith(Parameterized.class)
public class R8RunExamplesKotlinTest extends R8RunExamplesCommon {
- @Parameters(name = "{0}_{1}_{2}_{3}_{5}_{6}")
- public static Collection<Object[]> data() {
+ @Parameters(name = "{0}_{1}_{2}_{3}_{5}")
+ public static Collection<String[]> data() {
String[] tests = {
"loops.LoopKt"
};
- final int arrayListSize = tests.length *
- CompilationMode.values().length *
- KotlinTargetVersion.values().length *
- 2 /* JAVAC+D8 and DX+R8 */;
- List<Object[]> fullTestList = new ArrayList<>(arrayListSize);
+ List<String[]> fullTestList = new ArrayList<>(tests.length * 2);
for (String test : tests) {
- for (CompilationMode compilationMode : CompilationMode.values()) {
- for (KotlinTargetVersion targetVersion : KotlinTargetVersion.values()) {
- fullTestList.add(
- makeTest(Input.JAVAC, CompilerUnderTest.D8, compilationMode, targetVersion, test));
- fullTestList
- .add(makeTest(Input.DX, CompilerUnderTest.R8, compilationMode, targetVersion, test));
- }
- }
+ fullTestList.add(makeTest(Input.JAVAC, CompilerUnderTest.D8, CompilationMode.DEBUG, test));
+ fullTestList.add(makeTest(Input.JAVAC, CompilerUnderTest.D8, CompilationMode.RELEASE, test));
+ fullTestList.add(makeTest(Input.DX, CompilerUnderTest.R8, CompilationMode.DEBUG, test));
+ fullTestList.add(makeTest(Input.DX, CompilerUnderTest.R8, CompilationMode.RELEASE, test));
}
return fullTestList;
}
- private static Object[] makeTest(Input input, CompilerUnderTest compiler, CompilationMode mode,
- KotlinTargetVersion targetVersion, String clazz) {
- String[] testParams = makeTest(input, compiler, mode, clazz);
- Object[] kotlinTestParams = new Object[testParams.length + 1];
- System.arraycopy(testParams, 0, kotlinTestParams, 0, testParams.length);
- kotlinTestParams[testParams.length] = targetVersion;
- return kotlinTestParams;
- }
-
@Override
protected String getExampleDir() {
- return ToolHelper.getKotlinExamplesBuildDir(targetVersion);
+ return ToolHelper.EXAMPLES_KOTLIN_BUILD_DIR;
}
@Override
@@ -86,18 +68,13 @@
return Collections.emptyMap();
}
- private final KotlinTargetVersion targetVersion;
-
public R8RunExamplesKotlinTest(
String pkg,
String input,
String compiler,
String mode,
String mainClass,
- String output,
- KotlinTargetVersion targetVersion
- ) {
+ String output) {
super(pkg, input, compiler, mode, mainClass, output);
- this.targetVersion = targetVersion;
}
}
diff --git a/src/test/java/com/android/tools/r8/ToolHelper.java b/src/test/java/com/android/tools/r8/ToolHelper.java
index d5453f1..84769c4 100644
--- a/src/test/java/com/android/tools/r8/ToolHelper.java
+++ b/src/test/java/com/android/tools/r8/ToolHelper.java
@@ -72,6 +72,7 @@
public static final String EXAMPLES_ANDROID_P_DIR = TESTS_DIR + "examplesAndroidP/";
public static final String TESTS_BUILD_DIR = BUILD_DIR + "test/";
public static final String EXAMPLES_BUILD_DIR = TESTS_BUILD_DIR + "examples/";
+ public static final String EXAMPLES_KOTLIN_BUILD_DIR = TESTS_BUILD_DIR + "examplesKotlin/";
public static final String EXAMPLES_ANDROID_N_BUILD_DIR = TESTS_BUILD_DIR + "examplesAndroidN/";
public static final String EXAMPLES_ANDROID_O_BUILD_DIR = TESTS_BUILD_DIR + "examplesAndroidO/";
public static final String EXAMPLES_ANDROID_P_BUILD_DIR = TESTS_BUILD_DIR + "examplesAndroidP/";
@@ -1199,19 +1200,4 @@
options,
null);
}
-
- public enum KotlinTargetVersion {
- JAVA_6("JAVA_6"),
- JAVA_8("JAVA_8");
-
- private final String folderName;
-
- KotlinTargetVersion(String folderName) {
- this.folderName = folderName;
- }
- }
-
- public static String getKotlinExamplesBuildDir(KotlinTargetVersion version) {
- return TESTS_BUILD_DIR + "examplesKotlin/" + version.folderName;
- }
}
diff --git a/src/test/java/com/android/tools/r8/debug/KotlinDebugTestBase.java b/src/test/java/com/android/tools/r8/debug/KotlinDebugTestBase.java
index ad42842..845a450 100644
--- a/src/test/java/com/android/tools/r8/debug/KotlinDebugTestBase.java
+++ b/src/test/java/com/android/tools/r8/debug/KotlinDebugTestBase.java
@@ -6,63 +6,42 @@
import com.android.tools.r8.OutputMode;
import com.android.tools.r8.ToolHelper;
-import com.android.tools.r8.ToolHelper.KotlinTargetVersion;
import com.android.tools.r8.utils.AndroidApp;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.Arrays;
import java.util.Collections;
-import java.util.EnumMap;
import java.util.List;
-import java.util.Map;
import org.apache.harmony.jpda.tests.framework.jdwp.Frame.Variable;
import org.apache.harmony.jpda.tests.framework.jdwp.Location;
import org.junit.BeforeClass;
import org.junit.rules.TemporaryFolder;
-import org.junit.runner.RunWith;
-import org.junit.runners.Parameterized;
-import org.junit.runners.Parameterized.Parameter;
-import org.junit.runners.Parameterized.Parameters;
/**
* A specialization for Kotlin-based tests which provides extra commands.
*/
-@RunWith(Parameterized.class)
public abstract class KotlinDebugTestBase extends DebugTestBase {
+ private static final Path DEBUGGEE_KOTLIN_JAR =
+ Paths.get(ToolHelper.BUILD_DIR, "test", "debug_test_resources_kotlin.jar");
+
protected static class KotlinD8Config extends D8DebugTestConfig {
- private static Map<ToolHelper.KotlinTargetVersion, AndroidApp> compiledResourcesMap =
- new EnumMap<>(ToolHelper.KotlinTargetVersion.class);
+ private static AndroidApp compiledResources = null;
- private static synchronized AndroidApp getCompiledResources(KotlinTargetVersion targetVersion)
- throws Throwable {
- AndroidApp compiledResources = compiledResourcesMap.get(targetVersion);
+ private static synchronized AndroidApp getCompiledResources() throws Throwable {
if (compiledResources == null) {
- Path kotlinJarPath = getKotlinDebugJar(targetVersion);
compiledResources =
- D8DebugTestConfig.d8Compile(Collections.singletonList(kotlinJarPath), null);
- compiledResourcesMap.put(targetVersion, compiledResources);
+ D8DebugTestConfig.d8Compile(Collections.singletonList(DEBUGGEE_KOTLIN_JAR), null);
}
return compiledResources;
}
- private static Path getKotlinDebugJar(KotlinTargetVersion targetVersion) {
- switch (targetVersion) {
- case JAVA_6:
- return Paths.get(ToolHelper.BUILD_DIR, "test", "debug_test_resources_kotlin_JAVA_6.jar");
- case JAVA_8:
- return Paths.get(ToolHelper.BUILD_DIR, "test", "debug_test_resources_kotlin_JAVA_8.jar");
- default:
- throw new AssertionError("Unknown Kotlin target version");
- }
- }
-
- public KotlinD8Config(TemporaryFolder temp, KotlinTargetVersion targetVersion) {
+ public KotlinD8Config(TemporaryFolder temp) {
super();
try {
Path out = temp.newFolder().toPath().resolve("d8_debug_test_resources_kotlin.jar");
- getCompiledResources(targetVersion).write(out, OutputMode.DexIndexed);
+ getCompiledResources().write(out, OutputMode.DexIndexed);
addPaths(out);
} catch (Throwable e) {
throw new RuntimeException(e);
@@ -70,32 +49,15 @@
}
}
- private static KotlinD8Config d8ConfigForKotlinJava6;
- private static KotlinD8Config d8ConfigForKotlinJava8;
+ private static KotlinD8Config d8Config;
@BeforeClass
public static void setup() {
- d8ConfigForKotlinJava6 = new KotlinD8Config(temp, KotlinTargetVersion.JAVA_6);
- d8ConfigForKotlinJava8 = new KotlinD8Config(temp, KotlinTargetVersion.JAVA_8);
+ d8Config = new KotlinD8Config(temp);
}
- @Parameters(name = "{0}")
- public static ToolHelper.KotlinTargetVersion[] kotlinTargetVersions() {
- return ToolHelper.KotlinTargetVersion.values();
- }
-
- @Parameter(0)
- public KotlinTargetVersion targetVersion;
-
protected KotlinD8Config getD8Config() {
- switch (targetVersion) {
- case JAVA_6:
- return d8ConfigForKotlinJava6;
- case JAVA_8:
- return d8ConfigForKotlinJava8;
- default:
- throw new AssertionError("Unknown Kotlin target version");
- }
+ return d8Config;
}
protected final JUnit3Wrapper.Command kotlinStepOver() {