diff options
author | dslomov <dslomov@google.com> | 2017-10-23 17:01:35 +0200 |
---|---|---|
committer | Dmitry Lomov <dslomov@google.com> | 2017-10-23 17:16:26 +0200 |
commit | 4256ce1915c69bb8a8cee0b5c09a094768b7cd02 (patch) | |
tree | d47d8ae04f078cbca4e92a3c282f096ff9450e48 /src/test/java/com | |
parent | c6fd7b22a056f38ae717ad87016f2f76df25998b (diff) |
Automated rollback of commit 1b98de65873054b148ced772cfa827a7bfb5ad9a.
*** Reason for rollback ***
If the 'set' function was used in a .bzl file but not called, --incompatible_disallow_set_constructor=True would allow the load of that .bzl file without error, but this change removes the 'set' function so loading that bzl file is an error.
Example failure: https://ci.bazel.io/blue/organizations/jenkins/Global%2FTensorFlow/detail/TensorFlow/245/pipeline/
*** Original change description ***
Remove the deprecated set constructor from Skylark
The `set` constructor used to be deprecated, but it was still possible to use
it by providing --incompatible_disallow_set_constructor=false.
RELNOTES[INC]: The flag --incompatible_disallow_set_constructor is no longer
available, the deprecated `set` constructor is not available anymore.
PiperOrigin-RevId: 173115983
Diffstat (limited to 'src/test/java/com')
3 files changed, 38 insertions, 0 deletions
diff --git a/src/test/java/com/google/devtools/build/lib/collect/nestedset/OrderTest.java b/src/test/java/com/google/devtools/build/lib/collect/nestedset/OrderTest.java index 00d8ca7551..30ef309089 100644 --- a/src/test/java/com/google/devtools/build/lib/collect/nestedset/OrderTest.java +++ b/src/test/java/com/google/devtools/build/lib/collect/nestedset/OrderTest.java @@ -30,6 +30,7 @@ public class OrderTest { public void testParsing() throws Exception { for (Order current : Order.values()) { assertThat(Order.parse(current.getSkylarkName())).isEqualTo(current); + assertThat(Order.parse(current.getDeprecatedSkylarkName())).isEqualTo(current); } } diff --git a/src/test/java/com/google/devtools/build/lib/packages/SkylarkSemanticsConsistencyTest.java b/src/test/java/com/google/devtools/build/lib/packages/SkylarkSemanticsConsistencyTest.java index f0f203e142..3e1708f3dd 100644 --- a/src/test/java/com/google/devtools/build/lib/packages/SkylarkSemanticsConsistencyTest.java +++ b/src/test/java/com/google/devtools/build/lib/packages/SkylarkSemanticsConsistencyTest.java @@ -112,6 +112,7 @@ public class SkylarkSemanticsConsistencyTest { "--incompatible_dict_literal_has_no_duplicates=" + rand.nextBoolean(), "--incompatible_disallow_dict_plus=" + rand.nextBoolean(), "--incompatible_disallow_keyword_only_args=" + rand.nextBoolean(), + "--incompatible_disallow_set_constructor=" + rand.nextBoolean(), "--incompatible_disallow_toplevel_if_statement=" + rand.nextBoolean(), "--incompatible_list_plus_equals_inplace=" + rand.nextBoolean(), "--incompatible_load_argument_is_label=" + rand.nextBoolean(), @@ -136,6 +137,7 @@ public class SkylarkSemanticsConsistencyTest { .incompatibleDictLiteralHasNoDuplicates(rand.nextBoolean()) .incompatibleDisallowDictPlus(rand.nextBoolean()) .incompatibleDisallowKeywordOnlyArgs(rand.nextBoolean()) + .incompatibleDisallowSetConstructor(rand.nextBoolean()) .incompatibleDisallowToplevelIfStatement(rand.nextBoolean()) .incompatibleListPlusEqualsInplace(rand.nextBoolean()) .incompatibleLoadArgumentIsLabel(rand.nextBoolean()) diff --git a/src/test/java/com/google/devtools/build/lib/syntax/SkylarkNestedSetTest.java b/src/test/java/com/google/devtools/build/lib/syntax/SkylarkNestedSetTest.java index c93311d3cd..d61cb8ab16 100644 --- a/src/test/java/com/google/devtools/build/lib/syntax/SkylarkNestedSetTest.java +++ b/src/test/java/com/google/devtools/build/lib/syntax/SkylarkNestedSetTest.java @@ -15,6 +15,7 @@ package com.google.devtools.build.lib.syntax; import static com.google.common.truth.Truth.assertThat; import static com.google.devtools.build.lib.testutil.MoreAsserts.assertThrows; +import static com.google.devtools.build.lib.testutil.MoreAsserts.expectThrows; import com.google.common.collect.ImmutableList; import com.google.devtools.build.lib.collect.nestedset.Order; @@ -36,6 +37,25 @@ import org.junit.runners.JUnit4; public class SkylarkNestedSetTest extends EvaluationTestCase { @Test + public void testLegacyConstructor() throws Exception { + env = newEnvironmentWithSkylarkOptions("--incompatible_disallow_set_constructor=false"); + eval("s = set([1, 2, 3], order='postorder')"); + SkylarkNestedSet s = get("s"); + assertThat(s.getOrder().getSkylarkName()).isEqualTo("postorder"); + assertThat(s.getSet(Object.class)).containsExactly(1, 2, 3); + } + + @Test + public void testLegacyConstructorDeprecation() throws Exception { + env = newEnvironmentWithSkylarkOptions("--incompatible_disallow_set_constructor=true"); + EvalException e = expectThrows( + EvalException.class, + () -> eval("s = set([1, 2, 3], order='postorder')") + ); + assertThat(e).hasMessageThat().contains("The `set` constructor for depsets is deprecated"); + } + + @Test public void testConstructor() throws Exception { eval("s = depset(order='default')"); assertThat(lookup("s")).isInstanceOf(SkylarkNestedSet.class); @@ -130,6 +150,21 @@ public class SkylarkNestedSetTest extends EvaluationTestCase { } @Test + public void testDeprecatedOrder() throws Exception { + env = newEnvironmentWithSkylarkOptions("--incompatible_disallow_set_constructor=false"); + eval("s = depset(['a', 'b'], order='compile')"); + assertThat(get("s").getSet(String.class).getOrder()).isEqualTo(Order.COMPILE_ORDER); + + env = newEnvironmentWithSkylarkOptions("--incompatible_disallow_set_constructor=true"); + Exception e = expectThrows( + Exception.class, + () -> eval("s = depset(['a', 'b'], order='compile')") + ); + assertThat(e).hasMessageThat().contains( + "Order name 'compile' is deprecated, use 'postorder' instead"); + } + + @Test public void testBadOrder() throws Exception { new BothModesTest().testIfExactError( "Invalid order: non_existing", |