Reland "Enable r8 kotlinx coroutines test"
This reverts commit 390fb3fc1687c42143258f8a193f93b051e0213d.
Bug: 157023682
Change-Id: I522d969d05283bff68b22d759b69385fea08ba6e
diff --git a/src/test/java/com/android/tools/r8/kotlin/coroutines/KotlinxCoroutinesTestRunner.java b/src/test/java/com/android/tools/r8/kotlin/coroutines/KotlinxCoroutinesTestRunner.java
index 904f69f..f0179f8 100644
--- a/src/test/java/com/android/tools/r8/kotlin/coroutines/KotlinxCoroutinesTestRunner.java
+++ b/src/test/java/com/android/tools/r8/kotlin/coroutines/KotlinxCoroutinesTestRunner.java
@@ -5,6 +5,9 @@
package com.android.tools.r8.kotlin.coroutines;
import static com.android.tools.r8.KotlinCompilerTool.KOTLINC;
+import static org.hamcrest.CoreMatchers.anyOf;
+import static org.hamcrest.CoreMatchers.containsString;
+import static org.hamcrest.MatcherAssert.assertThat;
import static org.junit.Assert.assertEquals;
import com.android.tools.r8.KotlinTestBase;
@@ -63,7 +66,7 @@
@Test
public void runKotlinxCoroutinesTests_smoke() throws Exception {
- Path baseJar =
+ Path testJar =
kotlinc(KOTLINC, targetVersion)
.addArguments(
"-Xuse-experimental=kotlinx.coroutines.InternalCoroutinesApi",
@@ -73,7 +76,44 @@
.addClasspathFiles(BASE_LIBRARY)
.addSourceFiles(TEST_SOURCES)
.compile();
- runTestsInJar(baseJar, BASE_LIBRARY);
+ runTestsInJar(testJar, BASE_LIBRARY);
+ }
+
+ @Test
+ public void runKotlinxCoroutinesTests_r8() throws Exception {
+ Path baseJar =
+ testForR8(parameters.getBackend())
+ .addProgramFiles(BASE_LIBRARY)
+ .addKeepAllClassesRule()
+ .addKeepAllAttributes()
+ // The BASE_LIBRARY contains proguard rules that do not match.
+ .allowUnusedProguardConfigurationRules()
+ .allowDiagnosticInfoMessages()
+ .addKeepRules(
+ "-dontwarn reactor.blockhound.integration.BlockHoundIntegration",
+ "-dontwarn org.junit.runners.model.Statement",
+ "-dontwarn org.junit.rules.TestRule")
+ .compile()
+ .assertAllInfoMessagesMatch(
+ anyOf(
+ containsString("Unexpected error while reading kotlinx.coroutines"),
+ containsString("Proguard configuration rule does not match anything")))
+ .writeToZip();
+ ProcessResult kotlincResult =
+ kotlinc(KOTLINC, targetVersion)
+ .addArguments(
+ "-Xuse-experimental=kotlinx.coroutines.InternalCoroutinesApi",
+ "-Xuse-experimental=kotlinx.coroutines.ObsoleteCoroutinesApi",
+ "-Xuse-experimental=kotlinx.coroutines.ExperimentalCoroutinesApi")
+ .addClasspathFiles(DEPENDENCIES)
+ .addClasspathFiles(baseJar)
+ .addSourceFiles(TEST_SOURCES)
+ .setOutputPath(temp.newFolder().toPath())
+ .compileRaw();
+ assertEquals(1, kotlincResult.exitCode);
+ assertThat(
+ kotlincResult.stderr,
+ containsString("Couldn't inline method call 'CoroutineExceptionHandler'"));
}
private void runTestsInJar(Path testJar, Path deps) throws Exception {