Skip to content

Commit

Permalink
Enable --incompatible_disable_objc_provider_resources by default.
Browse files Browse the repository at this point in the history
#5710

RELNOTES: --incompatible_disable_objc_provider_resources is now enabled by default. This disables ObjcProvider's fields related to resource processing.
PiperOrigin-RevId: 231900540
  • Loading branch information
sergiocampama authored and Copybara-Service committed Feb 1, 2019
1 parent 29759d0 commit c1be54b
Show file tree
Hide file tree
Showing 3 changed files with 74 additions and 79 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ public static Builder builderWithDefaults() {
.incompatibleDepsetIsNotIterable(false)
.incompatibleDepsetUnion(false)
.incompatibleDisableDeprecatedAttrParams(false)
.incompatibleDisableObjcProviderResources(false)
.incompatibleDisableObjcProviderResources(true)
.incompatibleDisallowDataTransition(true)
.incompatibleDisallowDictPlus(false)
.incompatibleDisallowFileType(false)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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("<target //examples/apple_skylark:lib> (rule 'cc_library') "
+ "doesn't have provider 'objc'");
}
assertThat(e)
.hasMessageThat()
.contains(
"<target //examples/apple_skylark:lib> (rule 'cc_library') "
+ "doesn't have provider 'objc'");
}

@Test
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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");
Expand Down Expand Up @@ -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");
}

/**
Expand Down

0 comments on commit c1be54b

Please sign in to comment.