aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/test/java/com/google/devtools/build/lib/skylark
diff options
context:
space:
mode:
authorGravatar vladmos <vladmos@google.com>2017-10-12 15:35:17 +0200
committerGravatar Marcel Hlopko <hlopko@google.com>2017-10-13 13:51:30 +0200
commitcd6d8ae312701694b0a3ff9d59fbf3e7720dfe0c (patch)
treee423c3a35fa97cf7e5129b1241dd3e317ad6efc2 /src/test/java/com/google/devtools/build/lib/skylark
parentef143b46a48e3039e3a3ae6b4db3a0ab5210bbbb (diff)
Remove deprecated legacy string representations of Skylark objects
RELNOTES[INC]: The flag --incompatible_descriptive_string_representations is no longer available, old style string representations of objects are not supported anymore. PiperOrigin-RevId: 171952621
Diffstat (limited to 'src/test/java/com/google/devtools/build/lib/skylark')
-rw-r--r--src/test/java/com/google/devtools/build/lib/skylark/SkylarkRuleContextTest.java1
-rw-r--r--src/test/java/com/google/devtools/build/lib/skylark/SkylarkStringRepresentationsTest.java118
2 files changed, 0 insertions, 119 deletions
diff --git a/src/test/java/com/google/devtools/build/lib/skylark/SkylarkRuleContextTest.java b/src/test/java/com/google/devtools/build/lib/skylark/SkylarkRuleContextTest.java
index bf62065844..4a196f710b 100644
--- a/src/test/java/com/google/devtools/build/lib/skylark/SkylarkRuleContextTest.java
+++ b/src/test/java/com/google/devtools/build/lib/skylark/SkylarkRuleContextTest.java
@@ -568,7 +568,6 @@ public class SkylarkRuleContextTest extends SkylarkTestCase {
@Test
public void existingRuleWithSelect() throws Exception {
- setSkylarkSemanticsOptions("--incompatible_descriptive_string_representations=true");
scratch.file(
"test/existing_rule.bzl",
"def macro():",
diff --git a/src/test/java/com/google/devtools/build/lib/skylark/SkylarkStringRepresentationsTest.java b/src/test/java/com/google/devtools/build/lib/skylark/SkylarkStringRepresentationsTest.java
index 78618b5fd5..72f657df91 100644
--- a/src/test/java/com/google/devtools/build/lib/skylark/SkylarkStringRepresentationsTest.java
+++ b/src/test/java/com/google/devtools/build/lib/skylark/SkylarkStringRepresentationsTest.java
@@ -223,8 +223,6 @@ public class SkylarkStringRepresentationsTest extends SkylarkTestCase {
@Test
public void testStringRepresentations_Strings() throws Exception {
- setSkylarkSemanticsOptions("--incompatible_descriptive_string_representations=true");
-
assertThat(skylarkLoadingEval("str('foo')")).isEqualTo("foo");
assertThat(skylarkLoadingEval("'%s' % 'foo'")).isEqualTo("foo");
assertThat(skylarkLoadingEval("'{}'.format('foo')")).isEqualTo("foo");
@@ -234,8 +232,6 @@ public class SkylarkStringRepresentationsTest extends SkylarkTestCase {
@Test
public void testStringRepresentations_Labels() throws Exception {
- setSkylarkSemanticsOptions("--incompatible_descriptive_string_representations=true");
-
assertThat(skylarkLoadingEval("str(Label('//foo:bar'))")).isEqualTo("//foo:bar");
assertThat(skylarkLoadingEval("'%s' % Label('//foo:bar')")).isEqualTo("//foo:bar");
assertThat(skylarkLoadingEval("'{}'.format(Label('//foo:bar'))")).isEqualTo("//foo:bar");
@@ -248,8 +244,6 @@ public class SkylarkStringRepresentationsTest extends SkylarkTestCase {
@Test
public void testStringRepresentations_Primitives() throws Exception {
// Strings are tested in a separate test case as they have different str and repr values.
- setSkylarkSemanticsOptions("--incompatible_descriptive_string_representations=true");
-
assertStringRepresentation("1543", "1543");
assertStringRepresentation("True", "True");
assertStringRepresentation("False", "False");
@@ -257,8 +251,6 @@ public class SkylarkStringRepresentationsTest extends SkylarkTestCase {
@Test
public void testStringRepresentations_Containers() throws Exception {
- setSkylarkSemanticsOptions("--incompatible_descriptive_string_representations=true");
-
assertStringRepresentation("['a', 'b']", "[\"a\", \"b\"]");
assertStringRepresentation("('a', 'b')", "(\"a\", \"b\")");
assertStringRepresentation("{'a': 'b', 'c': 'd'}", "{\"a\": \"b\", \"c\": \"d\"}");
@@ -267,31 +259,23 @@ public class SkylarkStringRepresentationsTest extends SkylarkTestCase {
@Test
public void testStringRepresentations_Functions() throws Exception {
- setSkylarkSemanticsOptions("--incompatible_descriptive_string_representations=true");
-
assertStringRepresentation("all", "<built-in function all>");
assertStringRepresentation("def f(): pass", "f", "<function f from //eval:eval.bzl>");
}
@Test
public void testStringRepresentations_Rules() throws Exception {
- setSkylarkSemanticsOptions("--incompatible_descriptive_string_representations=true");
-
assertStringRepresentation("native.cc_library", "<built-in rule cc_library>");
assertStringRepresentation("rule(implementation=str)", "<rule>");
}
@Test
public void testStringRepresentations_Aspects() throws Exception {
- setSkylarkSemanticsOptions("--incompatible_descriptive_string_representations=true");
-
assertStringRepresentation("aspect(implementation=str)", "<aspect>");
}
@Test
public void testStringRepresentations_Providers() throws Exception {
- setSkylarkSemanticsOptions("--incompatible_descriptive_string_representations=true");
-
assertStringRepresentation("provider()", "<provider>");
assertStringRepresentation(
"p = provider()", "p(b = 'foo', a = 1)", "struct(a = 1, b = \"foo\")");
@@ -299,8 +283,6 @@ public class SkylarkStringRepresentationsTest extends SkylarkTestCase {
@Test
public void testStringRepresentations_Select() throws Exception {
- setSkylarkSemanticsOptions("--incompatible_descriptive_string_representations=true");
-
assertStringRepresentation(
"select({'//foo': ['//bar']}) + select({'//foo2': ['//bar2']})",
"select({\"//foo\": [\"//bar\"]}) + select({\"//foo2\": [\"//bar2\"]})");
@@ -308,8 +290,6 @@ public class SkylarkStringRepresentationsTest extends SkylarkTestCase {
@Test
public void testStringRepresentations_RuleContext() throws Exception {
- setSkylarkSemanticsOptions("--incompatible_descriptive_string_representations=true");
-
generateFilesToTestStrings();
ConfiguredTarget target = getConfiguredTarget("//test/skylark:check");
@@ -325,8 +305,6 @@ public class SkylarkStringRepresentationsTest extends SkylarkTestCase {
@Test
public void testStringRepresentations_Files() throws Exception {
- setSkylarkSemanticsOptions("--incompatible_descriptive_string_representations=true");
-
generateFilesToTestStrings();
ConfiguredTarget target = getConfiguredTarget("//test/skylark:check");
@@ -340,8 +318,6 @@ public class SkylarkStringRepresentationsTest extends SkylarkTestCase {
@Test
public void testStringRepresentations_Root() throws Exception {
- setSkylarkSemanticsOptions("--incompatible_descriptive_string_representations=true");
-
generateFilesToTestStrings();
ConfiguredTarget target = getConfiguredTarget("//test/skylark:check");
@@ -353,8 +329,6 @@ public class SkylarkStringRepresentationsTest extends SkylarkTestCase {
@Test
public void testStringRepresentations_Glob() throws Exception {
- setSkylarkSemanticsOptions("--incompatible_descriptive_string_representations=true");
-
scratch.file("eval/one.txt");
scratch.file("eval/two.txt");
scratch.file("eval/three.txt");
@@ -366,8 +340,6 @@ public class SkylarkStringRepresentationsTest extends SkylarkTestCase {
@Test
public void testStringRepresentations_Attr() throws Exception {
- setSkylarkSemanticsOptions("--incompatible_descriptive_string_representations=true");
-
assertStringRepresentation("attr", "<attr>");
assertStringRepresentation("attr.int()", "<attr.int>");
assertStringRepresentation("attr.string()", "<attr.string>");
@@ -386,8 +358,6 @@ public class SkylarkStringRepresentationsTest extends SkylarkTestCase {
@Test
public void testStringRepresentations_Targets() throws Exception {
- setSkylarkSemanticsOptions("--incompatible_descriptive_string_representations=true");
-
generateFilesToTestStrings();
ConfiguredTarget target = getConfiguredTarget("//test/skylark:check");
@@ -415,92 +385,4 @@ public class SkylarkStringRepresentationsTest extends SkylarkTestCase {
assertThat(eval("'%s' % mock")).isEqualTo("<unknown object java.lang.Object>");
assertThat(eval("'%r' % mock")).isEqualTo("<unknown object java.lang.Object>");
}
-
- @Test
- public void testLegacyStringRepresentations_Labels() throws Exception {
- setSkylarkSemanticsOptions("--incompatible_descriptive_string_representations=false");
-
- assertThat(skylarkLoadingEval("str(Label('//foo:bar'))")).isEqualTo("//foo:bar");
- assertThat(skylarkLoadingEval("'%s' % Label('//foo:bar')")).isEqualTo("//foo:bar");
- assertThat(skylarkLoadingEval("'{}'.format(Label('//foo:bar'))")).isEqualTo("//foo:bar");
- assertThat(skylarkLoadingEval("repr(Label('//foo:bar'))")).isEqualTo("\"//foo:bar\"");
- assertThat(skylarkLoadingEval("'%r' % Label('//foo:bar')")).isEqualTo("\"//foo:bar\"");
-
- // Also test that str representations (as opposed to repr) also use legacy formatting
- // They are equivalent for labels, but not equivalent for lists of labels, because
- // containers always render their items with repr
- assertThat(skylarkLoadingEval("str([Label('//foo:bar')])")).isEqualTo("[\"//foo:bar\"]");
- assertThat(skylarkLoadingEval("'{}'.format([Label('//foo:bar')])")).isEqualTo("[\"//foo:bar\"]");
- assertThat(skylarkLoadingEval("'%s' % [Label('//foo:bar')]")).isEqualTo("[\"//foo:bar\"]");
- }
-
- @Test
- public void testLegacyStringRepresentations_Functions() throws Exception {
- setSkylarkSemanticsOptions("--incompatible_descriptive_string_representations=false");
-
- assertStringRepresentation("all", "<function all>");
- assertStringRepresentation("def f(): pass", "f", "<function f>");
- }
-
- @Test
- public void testLegacyStringRepresentations_Rules() throws Exception {
- setSkylarkSemanticsOptions("--incompatible_descriptive_string_representations=false");
-
- assertStringRepresentation("native.cc_library", "<function cc_library>");
- assertStringRepresentation("rule(implementation=str)", "<function rule>");
- }
-
- @Test
- public void testLegacyStringRepresentations_Aspects() throws Exception {
- setSkylarkSemanticsOptions("--incompatible_descriptive_string_representations=false");
-
- assertStringRepresentation("aspect(implementation=str)", "Aspect:<function str>");
- }
-
- @Test
- public void testLegacyStringRepresentations_Providers() throws Exception {
- setSkylarkSemanticsOptions("--incompatible_descriptive_string_representations=false");
-
- assertStringRepresentation("provider()", "<function <no name>>");
- assertStringRepresentation("p = provider()", "p(b = 'foo', a = 1)", "p(a = 1, b = \"foo\")");
- }
-
- @Test
- public void testLegacyStringRepresentations_Select() throws Exception {
- setSkylarkSemanticsOptions("--incompatible_descriptive_string_representations=false");
-
- assertStringRepresentation(
- "select({'//foo': ['//bar']}) + select({'//foo2': ['//bar2']})",
- "selector({\"//foo\": [\"//bar\"]}) + selector({\"//foo2\": [\"//bar2\"]})");
- }
-
- @Test
- public void testLegacyStringRepresentations_RuleContext() throws Exception {
- setSkylarkSemanticsOptions("--incompatible_descriptive_string_representations=false");
-
- generateFilesToTestStrings();
- ConfiguredTarget target = getConfiguredTarget("//test/skylark:check");
-
- for (String suffix : SUFFIXES) {
- assertThat(target.get("rule_ctx" + suffix)).isEqualTo("//test/skylark:check");
- assertThat(target.get("aspect_ctx" + suffix)).isEqualTo("//test/skylark:bar");
- assertThat(target.get("aspect_ctx.rule" + suffix))
- .isEqualTo("rule_collection://test/skylark:bar");
- }
- }
-
- @Test
- public void testLegacyStringRepresentations_Files() throws Exception {
- setSkylarkSemanticsOptions("--incompatible_descriptive_string_representations=false");
-
- generateFilesToTestStrings();
- ConfiguredTarget target = getConfiguredTarget("//test/skylark:check");
-
- for (String suffix : SUFFIXES) {
- assertThat(target.get("source_file" + suffix))
- .isEqualTo("File:[/workspace[source]]test/skylark/input.txt");
- assertThat((String) target.get("generated_file" + suffix))
- .endsWith("test/skylark/output.txt");
- }
- }
}