From 43165797311ba62dd9dc63d1bbb75bb6371d23cc Mon Sep 17 00:00:00 2001 From: Luca Di Grazia Date: Sun, 4 Sep 2022 20:35:41 +0200 Subject: [PATCH] Enable --incompatible_disable_objc_provider_resources by default. https://github.com/bazelbuild/bazel/issues/5710 RELNOTES: --incompatible_disable_objc_provider_resources is now enabled by default. This disables ObjcProvider's fields related to resource processing. PiperOrigin-RevId: 231900540 --- .../lib/packages/SkylarkSemanticsOptions.java | 15 +- .../build/lib/syntax/SkylarkSemantics.java | 2 +- .../build/lib/rules/objc/ObjcSkylarkTest.java | 136 +++++++++--------- 3 files changed, 74 insertions(+), 79 deletions(-) diff --git a/dataset/GitHub_Java/bazelbuild.bazel/src/main/java/com/google/devtools/build/lib/packages/SkylarkSemanticsOptions.java b/dataset/GitHub_Java/bazelbuild.bazel/src/main/java/com/google/devtools/build/lib/packages/SkylarkSemanticsOptions.java index 9cfdb6fdabe..fef0df11477 100644 --- a/dataset/GitHub_Java/bazelbuild.bazel/src/main/java/com/google/devtools/build/lib/packages/SkylarkSemanticsOptions.java +++ b/dataset/GitHub_Java/bazelbuild.bazel/src/main/java/com/google/devtools/build/lib/packages/SkylarkSemanticsOptions.java @@ -237,16 +237,15 @@ public class SkylarkSemanticsOptions extends OptionsBase implements Serializable public boolean requireFeatureConfigurationForPic; @Option( - name = "incompatible_disable_objc_provider_resources", - defaultValue = "false", + name = "incompatible_disable_objc_provider_resources", + defaultValue = "true", documentationCategory = OptionDocumentationCategory.SKYLARK_SEMANTICS, effectTags = {OptionEffectTag.BUILD_FILE_SEMANTICS}, - metadataTags = { - OptionMetadataTag.INCOMPATIBLE_CHANGE, - OptionMetadataTag.TRIGGERED_BY_ALL_INCOMPATIBLE_CHANGES - }, - help = "If set to true, disallow use of deprecated resource fields on the Objc provider." - ) + metadataTags = { + OptionMetadataTag.INCOMPATIBLE_CHANGE, + OptionMetadataTag.TRIGGERED_BY_ALL_INCOMPATIBLE_CHANGES + }, + help = "If set to true, disallow use of deprecated resource fields on the Objc provider.") public boolean incompatibleDisableObjcProviderResources; @Option( diff --git a/dataset/GitHub_Java/bazelbuild.bazel/src/main/java/com/google/devtools/build/lib/syntax/SkylarkSemantics.java b/dataset/GitHub_Java/bazelbuild.bazel/src/main/java/com/google/devtools/build/lib/syntax/SkylarkSemantics.java index 03bbef6f945..6a37573ded8 100644 --- a/dataset/GitHub_Java/bazelbuild.bazel/src/main/java/com/google/devtools/build/lib/syntax/SkylarkSemantics.java +++ b/dataset/GitHub_Java/bazelbuild.bazel/src/main/java/com/google/devtools/build/lib/syntax/SkylarkSemantics.java @@ -217,7 +217,7 @@ public static Builder builderWithDefaults() { .incompatibleDepsetIsNotIterable(false) .incompatibleDepsetUnion(false) .incompatibleDisableDeprecatedAttrParams(false) - .incompatibleDisableObjcProviderResources(false) + .incompatibleDisableObjcProviderResources(true) .incompatibleDisallowDataTransition(true) .incompatibleDisallowDictPlus(false) .incompatibleDisallowFileType(false) diff --git a/dataset/GitHub_Java/bazelbuild.bazel/src/test/java/com/google/devtools/build/lib/rules/objc/ObjcSkylarkTest.java b/dataset/GitHub_Java/bazelbuild.bazel/src/test/java/com/google/devtools/build/lib/rules/objc/ObjcSkylarkTest.java index e1db675061d..91bc85060f9 100644 --- a/dataset/GitHub_Java/bazelbuild.bazel/src/test/java/com/google/devtools/build/lib/rules/objc/ObjcSkylarkTest.java +++ b/dataset/GitHub_Java/bazelbuild.bazel/src/test/java/com/google/devtools/build/lib/rules/objc/ObjcSkylarkTest.java @@ -17,7 +17,7 @@ import static com.google.common.truth.Truth.assertThat; import static com.google.devtools.build.lib.rules.objc.BundleableFile.BUNDLED_FIELD; import static com.google.devtools.build.lib.rules.objc.BundleableFile.BUNDLE_PATH_FIELD; -import static org.junit.Assert.fail; +import static com.google.devtools.build.lib.testutil.MoreAsserts.assertThrows; import com.google.common.collect.ImmutableMap; import com.google.common.collect.Iterables; @@ -115,23 +115,22 @@ public void testSkylarkProviderRetrievalNoneIfNoProvider() throws Exception { " srcs = ['a.cc'],", " hdrs = ['b.h']", ")"); - try { - getConfiguredTarget("//examples/apple_skylark:my_target"); - fail("Should throw assertion error"); - } catch (AssertionError e) { - assertThat(e) - .hasMessageThat() - .contains("File \"/workspace/examples/apple_skylark/BUILD\", line 3"); + AssertionError e = + assertThrows( + AssertionError.class, () -> getConfiguredTarget("//examples/apple_skylark:my_target")); + assertThat(e) + .hasMessageThat() + .contains("File \"/workspace/examples/apple_skylark/BUILD\", line 3"); assertThat(e).hasMessageThat().contains("my_rule(name = 'my_target')"); assertThat(e) .hasMessageThat() .contains("File \"/workspace/examples/rule/apple_rules.bzl\", line 3, in my_rule_impl"); assertThat(e).hasMessageThat().contains("dep.objc"); - assertThat(e) - .hasMessageThat() - .contains(" (rule 'cc_library') " - + "doesn't have provider 'objc'"); - } + assertThat(e) + .hasMessageThat() + .contains( + " (rule 'cc_library') " + + "doesn't have provider 'objc'"); } @Test @@ -971,73 +970,71 @@ public void testRuleReturnsObjcProviderInList() throws Exception { @Test public void testSkylarkErrorOnBadObjcProviderInputKey() throws Exception { - try { - createObjcProviderSkylarkTarget( - " created_provider = apple_common.new_objc_provider(foo=depset(['bar']))", - " return struct(objc=created_provider)"); - fail("Should throw AssertionError"); - } catch (AssertionError e) { - assertThat(e) - .hasMessageThat() - .contains(String.format(AppleSkylarkCommon.BAD_KEY_ERROR, "foo")); - } + AssertionError e = + assertThrows( + AssertionError.class, + () -> + createObjcProviderSkylarkTarget( + " created_provider = apple_common.new_objc_provider(foo=depset(['bar']))", + " return struct(objc=created_provider)")); + assertThat(e).hasMessageThat().contains(String.format(AppleSkylarkCommon.BAD_KEY_ERROR, "foo")); } @Test public void testSkylarkErrorOnNonSetObjcProviderInputValue() throws Exception { - try { - createObjcProviderSkylarkTarget( - " created_provider = apple_common.new_objc_provider(library='bar')", - " return struct(objc=created_provider)"); - fail("Should throw AssertionError"); - } catch (AssertionError e) { - assertThat(e) - .hasMessageThat() - .contains(String.format(AppleSkylarkCommon.NOT_SET_ERROR, "library", "string")); - } + AssertionError e = + assertThrows( + AssertionError.class, + () -> + createObjcProviderSkylarkTarget( + " created_provider = apple_common.new_objc_provider(library='bar')", + " return struct(objc=created_provider)")); + assertThat(e) + .hasMessageThat() + .contains(String.format(AppleSkylarkCommon.NOT_SET_ERROR, "library", "string")); } @Test public void testSkylarkErrorOnObjcProviderInputValueWrongSetType() throws Exception { - try { - createObjcProviderSkylarkTarget( - " created_provider = apple_common.new_objc_provider(library=depset(['bar']))", - " return struct(objc=created_provider)"); - fail("Should throw AssertionError"); - } catch (AssertionError e) { - assertThat(e) - .hasMessageThat() - .contains( - String.format(AppleSkylarkCommon.BAD_SET_TYPE_ERROR, "library", "File", "string")); - } + AssertionError e = + assertThrows( + AssertionError.class, + () -> + createObjcProviderSkylarkTarget( + " created_provider = apple_common.new_objc_provider(library=depset(['bar']))", + " return struct(objc=created_provider)")); + assertThat(e) + .hasMessageThat() + .contains( + String.format(AppleSkylarkCommon.BAD_SET_TYPE_ERROR, "library", "File", "string")); } @Test public void testSkylarkErrorOnNonIterableObjcProviderProviderValue() throws Exception { - try { - createObjcProviderSkylarkTarget( - " created_provider = apple_common.new_objc_provider(providers='bar')", - " return struct(objc=created_provider)"); - fail("Should throw AssertionError"); - } catch (AssertionError e) { - assertThat(e) - .hasMessageThat() - .contains(String.format(AppleSkylarkCommon.BAD_PROVIDERS_ITER_ERROR, "string")); - } + AssertionError e = + assertThrows( + AssertionError.class, + () -> + createObjcProviderSkylarkTarget( + " created_provider = apple_common.new_objc_provider(providers='bar')", + " return struct(objc=created_provider)")); + assertThat(e) + .hasMessageThat() + .contains(String.format(AppleSkylarkCommon.BAD_PROVIDERS_ITER_ERROR, "string")); } @Test public void testSkylarkErrorOnBadIterableObjcProviderProviderValue() throws Exception { - try { - createObjcProviderSkylarkTarget( - " created_provider = apple_common.new_objc_provider(providers=['bar'])", - " return struct(objc=created_provider)"); - fail("Should throw AssertionError"); - } catch (AssertionError e) { - assertThat(e) - .hasMessageThat() - .contains(String.format(AppleSkylarkCommon.BAD_PROVIDERS_ELEM_ERROR, "string")); - } + AssertionError e = + assertThrows( + AssertionError.class, + () -> + createObjcProviderSkylarkTarget( + " created_provider = apple_common.new_objc_provider(providers=['bar'])", + " return struct(objc=created_provider)")); + assertThat(e) + .hasMessageThat() + .contains(String.format(AppleSkylarkCommon.BAD_PROVIDERS_ELEM_ERROR, "string")); } @Test @@ -1079,6 +1076,7 @@ public void testEmptyObjcProviderKeysArePresent() throws Exception { @Test public void testSkylarkCanAccessProvidedBundleFiles() throws Exception { + setSkylarkSemanticsOptions("--incompatible_disable_objc_provider_resources=false"); // Since the collections of structs with Artifact values are extremely difficult to test with // Truth, we fudge them in the Skylark side to return easily comparable dictionaries instead. scratch.file("examples/rule/BUILD"); @@ -1337,12 +1335,10 @@ public void testDottedVersion_invalid() throws Exception { " name = 'my_target',", ")"); - try { - getConfiguredTarget("//examples/apple_skylark:my_target"); - fail("Expected an error to be thrown for invalid dotted version string"); - } catch (AssertionError e) { - assertThat(e).hasMessageThat().contains("Dotted version components must all be of the form"); - } + AssertionError e = + assertThrows( + AssertionError.class, () -> getConfiguredTarget("//examples/apple_skylark:my_target")); + assertThat(e).hasMessageThat().contains("Dotted version components must all be of the form"); } /**