[Metadata] Update tests to account for vertical class merging
Bug: 154300326
Change-Id: I021039f223db8b58554f0575d744495c9f858d76
diff --git a/src/test/java/com/android/tools/r8/kotlin/metadata/MetadataRewriteInExtensionFunctionTest.java b/src/test/java/com/android/tools/r8/kotlin/metadata/MetadataRewriteInExtensionFunctionTest.java
index a03354e..069ba8a 100644
--- a/src/test/java/com/android/tools/r8/kotlin/metadata/MetadataRewriteInExtensionFunctionTest.java
+++ b/src/test/java/com/android/tools/r8/kotlin/metadata/MetadataRewriteInExtensionFunctionTest.java
@@ -8,7 +8,6 @@
import static com.android.tools.r8.utils.codeinspector.Matchers.isPresent;
import static com.android.tools.r8.utils.codeinspector.Matchers.isPresentAndNotRenamed;
import static com.android.tools.r8.utils.codeinspector.Matchers.isPresentAndRenamed;
-import static org.hamcrest.CoreMatchers.not;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
@@ -25,10 +24,10 @@
import com.android.tools.r8.utils.codeinspector.KmTypeProjectionSubject;
import com.android.tools.r8.utils.codeinspector.KmTypeSubject;
import com.android.tools.r8.utils.codeinspector.KmValueParameterSubject;
+import com.android.tools.r8.utils.codeinspector.Matchers;
import java.nio.file.Path;
import java.util.Collection;
import java.util.List;
-import org.junit.Ignore;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;
@@ -77,13 +76,20 @@
}
@Test
- @Ignore("b/154300326")
- public void testMetadataInExtensionFunction_merged() throws Exception {
+ public void testMetadataInExtensionFunction_merged_compat() throws Exception {
+ testMetadataInExtensionFunction_merged(false);
+ }
+
+ @Test
+ public void testMetadataInExtensionFunction_merged_full() throws Exception {
+ testMetadataInExtensionFunction_merged(true);
+ }
+
+ public void testMetadataInExtensionFunction_merged(boolean full) throws Exception {
Path libJar =
- testForR8(parameters.getBackend())
- .addProgramFiles(
- extLibJarMap.getForConfiguration(kotlinc, targetVersion),
- kotlinc.getKotlinAnnotationJar())
+ (full ? testForR8(parameters.getBackend()) : testForR8Compat(parameters.getBackend()))
+ .addClasspathFiles(kotlinc.getKotlinStdlibJar(), kotlinc.getKotlinAnnotationJar())
+ .addProgramFiles(extLibJarMap.getForConfiguration(kotlinc, targetVersion))
// Keep the B class and its interface (which has the doStuff method).
.addKeepRules("-keep class **.B")
.addKeepRules("-keep class **.I { <methods>; }")
@@ -95,7 +101,7 @@
.addKeepAttributes(ProguardKeepAttributes.INNER_CLASSES)
.addKeepAttributes(ProguardKeepAttributes.ENCLOSING_METHOD)
.compile()
- .inspect(this::inspectMerged)
+ .inspect(inspector -> inspectMerged(inspector, full))
.writeToZip();
Path output =
@@ -103,7 +109,10 @@
.addClasspathFiles(libJar)
.addSourceFiles(getKotlinFileInTest(PKG_PREFIX + "/extension_function_app", "main"))
.setOutputPath(temp.newFolder().toPath())
- .compile();
+ .compile(full);
+ if (full) {
+ return;
+ }
testForJvm()
.addRunClasspathFiles(kotlinc.getKotlinStdlibJar(), libJar)
@@ -112,11 +121,11 @@
.assertSuccessWithOutput(EXPECTED);
}
- private void inspectMerged(CodeInspector inspector) {
+ private void inspectMerged(CodeInspector inspector, boolean full) {
String superClassName = PKG + ".extension_function_lib.Super";
String bClassName = PKG + ".extension_function_lib.B";
- assertThat(inspector.clazz(superClassName), not(isPresent()));
+ assertThat(inspector.clazz(superClassName), Matchers.notIf(isPresent(), full));
ClassSubject impl = inspector.clazz(bClassName);
assertThat(impl, isPresentAndNotRenamed());
diff --git a/src/test/java/com/android/tools/r8/kotlin/metadata/MetadataRewriteInExtensionPropertyTest.java b/src/test/java/com/android/tools/r8/kotlin/metadata/MetadataRewriteInExtensionPropertyTest.java
index 67401c2..e5c43ed 100644
--- a/src/test/java/com/android/tools/r8/kotlin/metadata/MetadataRewriteInExtensionPropertyTest.java
+++ b/src/test/java/com/android/tools/r8/kotlin/metadata/MetadataRewriteInExtensionPropertyTest.java
@@ -24,10 +24,10 @@
import com.android.tools.r8.utils.codeinspector.KmFunctionSubject;
import com.android.tools.r8.utils.codeinspector.KmPackageSubject;
import com.android.tools.r8.utils.codeinspector.KmPropertySubject;
+import com.android.tools.r8.utils.codeinspector.Matchers;
import java.nio.file.Path;
import java.util.Collection;
import java.util.List;
-import org.junit.Ignore;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;
@@ -76,13 +76,20 @@
}
@Test
- @Ignore("b/154300326")
- public void testMetadataInExtensionProperty_merged() throws Exception {
+ public void testMetadataInExtensionProperty_merged_compat() throws Exception {
+ testMetadataInExtensionProperty_merged(false);
+ }
+
+ @Test
+ public void testMetadataInExtensionProperty_merged_full() throws Exception {
+ testMetadataInExtensionProperty_merged(true);
+ }
+
+ public void testMetadataInExtensionProperty_merged(boolean full) throws Exception {
Path libJar =
- testForR8(parameters.getBackend())
- .addProgramFiles(
- extLibJarMap.getForConfiguration(kotlinc, targetVersion),
- kotlinc.getKotlinAnnotationJar())
+ (full ? testForR8(parameters.getBackend()) : testForR8Compat(parameters.getBackend()))
+ .addClasspathFiles(kotlinc.getKotlinStdlibJar(), kotlinc.getKotlinAnnotationJar())
+ .addProgramFiles(extLibJarMap.getForConfiguration(kotlinc, targetVersion))
// Keep the B class and its interface (which has the doStuff method).
.addKeepRules("-keep class **.B")
.addKeepRules("-keep class **.I { <methods>; }")
@@ -91,7 +98,7 @@
.addKeepRules("-keep class **.BKt { <methods>; }")
.addKeepAttributes(ProguardKeepAttributes.RUNTIME_VISIBLE_ANNOTATIONS)
.compile()
- .inspect(this::inspectMerged)
+ .inspect(inspector -> inspectMerged(inspector, full))
.writeToZip();
Path output =
@@ -99,7 +106,10 @@
.addClasspathFiles(libJar)
.addSourceFiles(getKotlinFileInTest(PKG_PREFIX + "/extension_property_app", "main"))
.setOutputPath(temp.newFolder().toPath())
- .compile();
+ .compile(full);
+ if (full) {
+ return;
+ }
testForJvm()
.addRunClasspathFiles(kotlinc.getKotlinStdlibJar(), libJar)
@@ -108,12 +118,12 @@
.assertSuccessWithOutput(EXPECTED);
}
- private void inspectMerged(CodeInspector inspector) {
+ private void inspectMerged(CodeInspector inspector, boolean full) {
String superClassName = PKG + ".extension_property_lib.Super";
String bClassName = PKG + ".extension_property_lib.B";
String bKtClassName = PKG + ".extension_property_lib.BKt";
- assertThat(inspector.clazz(superClassName), not(isPresent()));
+ assertThat(inspector.clazz(superClassName), Matchers.notIf(isPresent(), full));
ClassSubject impl = inspector.clazz(bClassName);
assertThat(impl, isPresentAndNotRenamed());
@@ -124,7 +134,7 @@
assertTrue(superTypes.stream().noneMatch(
supertype -> supertype.getFinalDescriptor().contains("Super")));
KmFunctionSubject kmFunction = kmClass.kmFunctionWithUniqueName("doStuff");
- assertThat(kmFunction, isPresent());
+ assertThat(kmFunction, not(isPresent()));
assertThat(kmFunction, not(isExtensionFunction()));
ClassSubject bKt = inspector.clazz(bKtClassName);
diff --git a/src/test/java/com/android/tools/r8/kotlin/metadata/MetadataRewriteInFunctionTest.java b/src/test/java/com/android/tools/r8/kotlin/metadata/MetadataRewriteInFunctionTest.java
index 10afff3..ab548e9 100644
--- a/src/test/java/com/android/tools/r8/kotlin/metadata/MetadataRewriteInFunctionTest.java
+++ b/src/test/java/com/android/tools/r8/kotlin/metadata/MetadataRewriteInFunctionTest.java
@@ -22,11 +22,11 @@
import com.android.tools.r8.utils.codeinspector.KmClassSubject;
import com.android.tools.r8.utils.codeinspector.KmFunctionSubject;
import com.android.tools.r8.utils.codeinspector.KmPackageSubject;
+import com.android.tools.r8.utils.codeinspector.Matchers;
import com.android.tools.r8.utils.codeinspector.MethodSubject;
import java.nio.file.Path;
import java.util.Collection;
import java.util.List;
-import org.junit.Ignore;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;
@@ -75,13 +75,20 @@
}
@Test
- @Ignore("b/154300326")
- public void testMetadataInFunction_merged() throws Exception {
+ public void testMetadataInFunction_merged_compat() throws Exception {
+ testMetadataInFunction_merged(false);
+ }
+
+ @Test
+ public void testMetadataInFunction_merged_full() throws Exception {
+ testMetadataInFunction_merged(true);
+ }
+
+ public void testMetadataInFunction_merged(boolean full) throws Exception {
Path libJar =
- testForR8(parameters.getBackend())
- .addProgramFiles(
- funLibJarMap.getForConfiguration(kotlinc, targetVersion),
- kotlinc.getKotlinAnnotationJar())
+ (full ? testForR8(parameters.getBackend()) : testForR8Compat(parameters.getBackend()))
+ .addClasspathFiles(kotlinc.getKotlinStdlibJar(), kotlinc.getKotlinAnnotationJar())
+ .addProgramFiles(funLibJarMap.getForConfiguration(kotlinc, targetVersion))
// Keep the B class and its interface (which has the doStuff method).
.addKeepRules("-keep class **.B")
.addKeepRules("-keep class **.I { <methods>; }")
@@ -89,7 +96,7 @@
.addKeepRules("-keep class **.BKt { <methods>; }")
.addKeepAttributes(ProguardKeepAttributes.RUNTIME_VISIBLE_ANNOTATIONS)
.compile()
- .inspect(this::inspectMerged)
+ .inspect(inspector -> inspectMerged(inspector, full))
.writeToZip();
Path output =
@@ -97,7 +104,10 @@
.addClasspathFiles(libJar)
.addSourceFiles(getKotlinFileInTest(PKG_PREFIX + "/function_app", "main"))
.setOutputPath(temp.newFolder().toPath())
- .compile();
+ .compile(full);
+ if (full) {
+ return;
+ }
testForJvm()
.addRunClasspathFiles(kotlinc.getKotlinStdlibJar(), libJar)
@@ -106,12 +116,12 @@
.assertSuccessWithOutput(EXPECTED);
}
- private void inspectMerged(CodeInspector inspector) {
+ private void inspectMerged(CodeInspector inspector, boolean full) {
String superClassName = PKG + ".function_lib.Super";
String bClassName = PKG + ".function_lib.B";
String bKtClassName = PKG + ".function_lib.BKt";
- assertThat(inspector.clazz(superClassName), not(isPresent()));
+ assertThat(inspector.clazz(superClassName), Matchers.notIf(isPresent(), full));
ClassSubject impl = inspector.clazz(bClassName);
assertThat(impl, isPresentAndNotRenamed());