aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/test/java
diff options
context:
space:
mode:
authorGravatar vladmos <vladmos@google.com>2017-11-20 10:03:20 -0800
committerGravatar Copybara-Service <copybara-piper@google.com>2017-11-20 10:05:26 -0800
commitc5e9a4790288a24b22bc72761994775c029a676e (patch)
tree7c74bbe225244829f637e504393bc5a932fb29c4 /src/test/java
parent6364017ef95353969a8297c99a07c2a52102d9cc (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. RELNOTES[INC]: The deprecated `set` constructor is removed, along with the migration flag --incompatible_disallow_set_constructor. It is still temporarily allowed to refer to `set` from within unexecuted code. PiperOrigin-RevId: 176375859
Diffstat (limited to 'src/test/java')
-rw-r--r--src/test/java/com/google/devtools/build/lib/collect/nestedset/OrderTest.java1
-rw-r--r--src/test/java/com/google/devtools/build/lib/packages/SkylarkSemanticsConsistencyTest.java2
-rw-r--r--src/test/java/com/google/devtools/build/lib/syntax/SkylarkNestedSetTest.java36
3 files changed, 8 insertions, 31 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 30ef309089..00d8ca7551 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,7 +30,6 @@ 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 3e1708f3dd..f0f203e142 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,7 +112,6 @@ 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(),
@@ -137,7 +136,6 @@ 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 d61cb8ab16..c8fdba5ab6 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,7 +15,6 @@ 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;
@@ -37,22 +36,18 @@ 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')");
+ public void testLegacyConstructorNotCalled() throws Exception {
+ env = newEnvironmentWithSkylarkOptions();
+ eval("s = set([1, 2]) if False else depset([3, 4])");
SkylarkNestedSet s = get("s");
- assertThat(s.getOrder().getSkylarkName()).isEqualTo("postorder");
- assertThat(s.getSet(Object.class)).containsExactly(1, 2, 3);
+ assertThat(s.getSet(Object.class)).containsExactly(3, 4);
}
@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");
+ public void testLegacyConstructorCalled() throws Exception {
+ new BothModesTest()
+ .testIfErrorContains("The function 'set' has been removed in favor of 'depset'",
+ "s = set([1, 2])");
}
@Test
@@ -150,21 +145,6 @@ 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",