From 7e0f3329834029c75a4057854f18e8443e72742e Mon Sep 17 00:00:00 2001 From: vladmos Date: Thu, 6 Jul 2017 17:19:32 -0400 Subject: Clean up string representations for select values If --incompatible_descriptive_string_representations is passed, select values are converted to strings using `str`, `repr` and `print` functions differently: "select(...)" instead of "selector(...)". PiperOrigin-RevId: 161129809 --- .../devtools/build/lib/skylark/SkylarkRuleContextTest.java | 2 +- .../build/lib/skylark/SkylarkStringRepresentationsTest.java | 9 +++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) (limited to 'src/test/java') 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 860f1d702f..5dde93b421 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 @@ -509,7 +509,7 @@ public class SkylarkRuleContextTest extends SkylarkTestCase { "macro()", "cc_library(name = 'a', srcs = [])"); getConfiguredTarget("//test:a"); - assertContainsEvent("selector({Label(\"//foo:foo\"): [Label(\"//bar:bar\")]})"); + assertContainsEvent("selector({\"//foo:foo\": [\"//bar:bar\"]})"); } @Test 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 35d4d1d0d4..ea68ddc9f6 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 @@ -238,6 +238,15 @@ public class SkylarkStringRepresentationsTest extends SkylarkTestCase { assertStringRepresentation("aspect(implementation=str)", ""); } + @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\"]})"); + } + @Test public void testLegacyStringRepresentations_Labels() throws Exception { setSkylarkSemanticsOptions("--incompatible_descriptive_string_representations=false"); -- cgit v1.2.3