diff --git a/dataset/GitHub_Java/bazelbuild.bazel/src/main/java/com/google/devtools/build/lib/rules/android/AndroidConfiguration.java b/dataset/GitHub_Java/bazelbuild.bazel/src/main/java/com/google/devtools/build/lib/rules/android/AndroidConfiguration.java index 0bae26352df..93599d2f8f2 100644 --- a/dataset/GitHub_Java/bazelbuild.bazel/src/main/java/com/google/devtools/build/lib/rules/android/AndroidConfiguration.java +++ b/dataset/GitHub_Java/bazelbuild.bazel/src/main/java/com/google/devtools/build/lib/rules/android/AndroidConfiguration.java @@ -1014,8 +1014,6 @@ public FragmentOptions getHost() { oneVersionEnforcementUseTransitiveJarsForBinaryUnderTest; host.persistentBusyboxTools = persistentBusyboxTools; - host.incompatibleProhibitAapt1 = incompatibleProhibitAapt1; - // Unless the build was started from an Android device, host means MAIN. host.configurationDistinguisher = ConfigurationDistinguisher.MAIN; return host; diff --git a/dataset/GitHub_Java/bazelbuild.bazel/src/test/java/com/google/devtools/build/lib/rules/android/AndroidResourcesTest.java b/dataset/GitHub_Java/bazelbuild.bazel/src/test/java/com/google/devtools/build/lib/rules/android/AndroidResourcesTest.java index 4c63ccabe86..fa8c6fc2c94 100644 --- a/dataset/GitHub_Java/bazelbuild.bazel/src/test/java/com/google/devtools/build/lib/rules/android/AndroidResourcesTest.java +++ b/dataset/GitHub_Java/bazelbuild.bazel/src/test/java/com/google/devtools/build/lib/rules/android/AndroidResourcesTest.java @@ -15,12 +15,12 @@ import static com.google.common.truth.Truth.assertThat; import static com.google.common.truth.Truth.assertWithMessage; +import static org.junit.Assert.fail; import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableMap; import com.google.common.collect.ImmutableSet; import com.google.common.collect.Iterables; -import com.google.devtools.build.lib.actions.ActionAnalysisMetadata; import com.google.devtools.build.lib.actions.Artifact; import com.google.devtools.build.lib.analysis.ConfiguredTarget; import com.google.devtools.build.lib.analysis.RuleContext; @@ -28,10 +28,8 @@ import com.google.devtools.build.lib.rules.android.AndroidConfiguration.AndroidAaptVersion; import com.google.devtools.build.lib.rules.android.databinding.DataBinding; import com.google.devtools.build.lib.rules.android.databinding.DataBindingContext; -import com.google.devtools.build.lib.testutil.MoreAsserts; import com.google.devtools.build.lib.vfs.PathFragment; import java.util.Optional; -import java.util.Set; import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; @@ -377,10 +375,6 @@ public void testValidateAapt() throws Exception { MergedAndroidResources merged = makeMergedResources(ruleContext, AndroidAaptVersion.AAPT); ValidatedAndroidResources validated = merged.validate(AndroidDataContext.forNative(ruleContext), AndroidAaptVersion.AAPT); - Set actionMnemonics = - ruleContext.getAnalysisEnvironment().getRegisteredActions().stream() - .map(ActionAnalysisMetadata::getMnemonic) - .collect(ImmutableSet.toImmutableSet()); // Inherited values should be equal assertThat(merged).isEqualTo(new MergedAndroidResources(validated)); @@ -391,14 +385,12 @@ public void testValidateAapt() throws Exception { /* inputs = */ ImmutableList.of(validated.getMergedResources(), validated.getManifest()), /* outputs = */ ImmutableList.of( validated.getRTxt(), validated.getJavaSourceJar(), validated.getApk())); - assertThat(actionMnemonics).contains("AndroidResourceValidator"); // aapt1 validation // aapt2 artifacts should not be generated assertThat(validated.getCompiledSymbols()).isNull(); assertThat(validated.getAapt2RTxt()).isNull(); assertThat(validated.getAapt2SourceJar()).isNull(); assertThat(validated.getStaticLibrary()).isNull(); - assertThat(actionMnemonics).doesNotContain("AndroidResourceLink"); // aapt2 validation } @Test @@ -439,24 +431,6 @@ public void testValidateAapt2() throws Exception { validated.getAapt2RTxt(), validated.getAapt2SourceJar(), validated.getStaticLibrary())); } - @Test - public void testValidateNoAapt1() throws Exception { - useConfiguration("--incompatible_prohibit_aapt1"); - RuleContext ruleContext = getRuleContext(); - - makeMergedResources(ruleContext, AndroidAaptVersion.AAPT2) - .validate(AndroidDataContext.forNative(ruleContext), AndroidAaptVersion.AAPT2); - - Set actionMnemonics = - ruleContext.getAnalysisEnvironment().getRegisteredActions().stream() - .map(ActionAnalysisMetadata::getMnemonic) - .collect(ImmutableSet.toImmutableSet()); - // These are unfortunately the mnemonics used in Bazel; these should be changed once aapt1 is - // removed. - assertThat(actionMnemonics).contains("AndroidResourceLink"); // aapt2 validation - assertThat(actionMnemonics).doesNotContain("AndroidResourceValidator"); // aapt1 validation - } - @Test public void testGenerateRClass() throws Exception { RuleContext ruleContext = getRuleContext(); @@ -533,32 +507,28 @@ public void test_incompatibleProhibitAapt1_targetsAapt2() throws Exception { public void test_incompatibleProhibitAapt1_aaptVersionAapt_throwsAttributeError() throws Exception { useConfiguration("--incompatible_prohibit_aapt1"); - AssertionError e = - MoreAsserts.assertThrows( - AssertionError.class, - () -> - getRuleContext( - "android_binary", - "aapt_version = 'aapt',", - "manifest = 'AndroidManifest.xml',")); - assertThat(e).hasMessageThat().contains("aapt_version"); - assertThat(e).hasMessageThat().contains("Attribute is no longer supported"); + try { + getRuleContext( + "android_binary", "aapt_version = 'aapt',", "manifest = 'AndroidManifest.xml',"); + fail("Expected AssertionError"); + } catch (AssertionError e) { + assertThat(e).hasMessageThat().contains("aapt_version"); + assertThat(e).hasMessageThat().contains("Attribute is no longer supported"); + } } @Test public void test_incompatibleProhibitAapt1_aaptVersionAapt2_throwsAttributeError() throws Exception { useConfiguration("--incompatible_prohibit_aapt1"); - AssertionError e = - MoreAsserts.assertThrows( - AssertionError.class, - () -> - getRuleContext( - "android_binary", - "aapt_version = 'aapt2',", - "manifest = 'AndroidManifest.xml',")); - assertThat(e).hasMessageThat().contains("aapt_version"); - assertThat(e).hasMessageThat().contains("Attribute is no longer supported"); + try { + getRuleContext( + "android_binary", "aapt_version = 'aapt2',", "manifest = 'AndroidManifest.xml',"); + fail("Expected AssertionError"); + } catch (AssertionError e) { + assertThat(e).hasMessageThat().contains("aapt_version"); + assertThat(e).hasMessageThat().contains("Attribute is no longer supported"); + } } /**