diff options
author | 2017-07-06 12:16:18 -0400 | |
---|---|---|
committer | 2017-07-07 07:07:20 -0400 | |
commit | 3feea74d8b594d4e061478264468e21d90e95625 (patch) | |
tree | d4d7f4dae89f83966d1e1aa43d9a63de96171021 /src/test/java/com/google/devtools/build/lib/skylark | |
parent | 3a2025da4da746cf6b067abb5093db5de6c2ecf7 (diff) |
Clean up string representations for functions
If --incompatible_descriptive_string_representations is passed, functions and rule
classes are converted to strings using `str`, `repr` and `print` functions
differently (more descriptive, without leaking information that shouldn't
be accessible).
PiperOrigin-RevId: 161087777
Diffstat (limited to 'src/test/java/com/google/devtools/build/lib/skylark')
-rw-r--r-- | src/test/java/com/google/devtools/build/lib/skylark/SkylarkStringRepresentationsTest.java | 23 |
1 files changed, 23 insertions, 0 deletions
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 7c777e28f5..d503ec9803 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 @@ -214,6 +214,23 @@ public class SkylarkStringRepresentationsTest extends SkylarkTestCase { assertStringRepresentation("struct(d = 4, c = 3)", "struct(c = 3, d = 4)"); } + + @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 testLegacyStringRepresentations_Labels() throws Exception { setSkylarkSemanticsOptions("--incompatible_descriptive_string_representations=false"); @@ -246,6 +263,12 @@ public class SkylarkStringRepresentationsTest extends SkylarkTestCase { 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>"); } |