aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/test/java/com/google/devtools
diff options
context:
space:
mode:
authorGravatar vladmos <vladmos@google.com>2017-11-21 04:40:08 -0800
committerGravatar Copybara-Service <copybara-piper@google.com>2017-11-21 04:41:35 -0800
commit9bb93ee8c0edae911f9e2adeaca8aebd406788b6 (patch)
treeec830914e13f142fe1079c92b342cbad38f067c3 /src/test/java/com/google/devtools
parent4d09a1de6a60c6f90cc88978151bcde83c8000d4 (diff)
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. It's still allowed to have `set` in parts of the code that are not executed, this will be deprecated later. You can check if your code is compatible with this future change by using the flag --incompatible_disallow_uncalled_set_constructor (currently the default is "false"). RELNOTES[INC]: The flag --incompatible_disallow_set_constructor is no longer available, the deprecated `set` constructor is not available anymore. PiperOrigin-RevId: 176491641
Diffstat (limited to 'src/test/java/com/google/devtools')
-rw-r--r--src/test/java/com/google/devtools/build/lib/packages/SkylarkSemanticsConsistencyTest.java5
-rw-r--r--src/test/java/com/google/devtools/build/lib/syntax/SkylarkNestedSetTest.java16
2 files changed, 17 insertions, 4 deletions
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..2d388ca348 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
@@ -113,13 +113,13 @@ public class SkylarkSemanticsConsistencyTest {
"--incompatible_disallow_dict_plus=" + rand.nextBoolean(),
"--incompatible_disallow_keyword_only_args=" + rand.nextBoolean(),
"--incompatible_disallow_toplevel_if_statement=" + rand.nextBoolean(),
+ "--incompatible_disallow_uncalled_set_constructor=" + rand.nextBoolean(),
"--incompatible_list_plus_equals_inplace=" + rand.nextBoolean(),
"--incompatible_load_argument_is_label=" + rand.nextBoolean(),
"--incompatible_new_actions_api=" + rand.nextBoolean(),
"--incompatible_string_is_not_iterable=" + rand.nextBoolean(),
"--internal_do_not_export_builtins=" + rand.nextBoolean(),
- "--internal_skylark_flag_test_canary=" + rand.nextBoolean()
- );
+ "--internal_skylark_flag_test_canary=" + rand.nextBoolean());
}
/**
@@ -137,6 +137,7 @@ public class SkylarkSemanticsConsistencyTest {
.incompatibleDisallowDictPlus(rand.nextBoolean())
.incompatibleDisallowKeywordOnlyArgs(rand.nextBoolean())
.incompatibleDisallowToplevelIfStatement(rand.nextBoolean())
+ .incompatibleDisallowUncalledSetConstructor(rand.nextBoolean())
.incompatibleListPlusEqualsInplace(rand.nextBoolean())
.incompatibleLoadArgumentIsLabel(rand.nextBoolean())
.incompatibleNewActionsApi(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 c8fdba5ab6..3ba85635d2 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
@@ -37,15 +37,27 @@ public class SkylarkNestedSetTest extends EvaluationTestCase {
@Test
public void testLegacyConstructorNotCalled() throws Exception {
- env = newEnvironmentWithSkylarkOptions();
+ env =
+ newEnvironmentWithSkylarkOptions("--incompatible_disallow_uncalled_set_constructor=false");
eval("s = set([1, 2]) if False else depset([3, 4])");
SkylarkNestedSet s = get("s");
assertThat(s.getSet(Object.class)).containsExactly(3, 4);
+
+ // Static check are only enabled in .bzl files
+ new SkylarkTest("--incompatible_disallow_uncalled_set_constructor=true")
+ .testIfErrorContains("The function 'set' has been removed in favor of 'depset'",
+ "s = set([1, 2]) if False else depset([3, 4])");
+ new BuildTest("--incompatible_disallow_uncalled_set_constructor=true")
+ .testEval("s = set([1, 2]) if False else depset([3, 4]); s.to_list()", "[3, 4]");
}
@Test
public void testLegacyConstructorCalled() throws Exception {
- new BothModesTest()
+ new BothModesTest("--incompatible_disallow_uncalled_set_constructor=false")
+ .testIfErrorContains("The function 'set' has been removed in favor of 'depset'",
+ "s = set([1, 2])");
+
+ new BothModesTest("--incompatible_disallow_uncalled_set_constructor=true")
.testIfErrorContains("The function 'set' has been removed in favor of 'depset'",
"s = set([1, 2])");
}