diff options
author | Kevin Gessner <kgessner@etsy.com> | 2017-09-06 20:14:49 +0200 |
---|---|---|
committer | Yun Peng <pcloudy@google.com> | 2017-09-07 09:57:26 +0200 |
commit | b864db2a6cc48edd6c7925c6699409b22e5b995b (patch) | |
tree | f0e57796d3573b05dcf721bd2135078ae2057d0c /src/test/java/com/google/devtools/build/lib | |
parent | 64cc3d333cc777104346fe789027e660c41dca74 (diff) |
Support labels referencing external targets (with '@') in load with --incompatible_load_argument_is_label enabled (fixes #3560)
Closes #3562.
PiperOrigin-RevId: 167745885
Diffstat (limited to 'src/test/java/com/google/devtools/build/lib')
-rw-r--r-- | src/test/java/com/google/devtools/build/lib/syntax/SkylarkEvaluationTest.java | 44 | ||||
-rw-r--r-- | src/test/java/com/google/devtools/build/lib/syntax/util/EvaluationTestCase.java | 8 |
2 files changed, 50 insertions, 2 deletions
diff --git a/src/test/java/com/google/devtools/build/lib/syntax/SkylarkEvaluationTest.java b/src/test/java/com/google/devtools/build/lib/syntax/SkylarkEvaluationTest.java index f3d2b09074..e27cb6372f 100644 --- a/src/test/java/com/google/devtools/build/lib/syntax/SkylarkEvaluationTest.java +++ b/src/test/java/com/google/devtools/build/lib/syntax/SkylarkEvaluationTest.java @@ -1568,7 +1568,15 @@ public class SkylarkEvaluationTest extends EvaluationTest { public void testLoadStatementWithAbsolutePath() throws Exception { env = newEnvironmentWithSkylarkOptions("--incompatible_load_argument_is_label"); checkEvalErrorContains( - "First argument of 'load' must be a label and start with either '//' or ':'", + "First argument of 'load' must be a label and start with either '//', ':', or '@'.", + "load('/tmp/foo', 'arg')"); + } + + @Test + public void testAllowLoadStatementWithAbsolutePath() throws Exception { + env = newEnvironmentWithSkylarkOptions("--incompatible_load_argument_is_label=false"); + checkEvalErrorDoesNotContain( + "First argument of 'load' must be a label and start with either '//', ':', or '@'.", "load('/tmp/foo', 'arg')"); } @@ -1576,7 +1584,39 @@ public class SkylarkEvaluationTest extends EvaluationTest { public void testLoadStatementWithRelativePath() throws Exception { env = newEnvironmentWithSkylarkOptions("--incompatible_load_argument_is_label"); checkEvalErrorContains( - "First argument of 'load' must be a label and start with either '//' or ':'", + "First argument of 'load' must be a label and start with either '//', ':', or '@'.", + "load('foo', 'arg')"); + } + + @Test + public void testAllowLoadStatementWithRelativePath() throws Exception { + env = newEnvironmentWithSkylarkOptions("--incompatible_load_argument_is_label=false"); + checkEvalErrorDoesNotContain( + "First argument of 'load' must be a label and start with either '//', ':', or '@'.", "load('foo', 'arg')"); } + + @Test + public void testLoadStatementWithExternalLabel() throws Exception { + env = newEnvironmentWithSkylarkOptions("--incompatible_load_argument_is_label"); + checkEvalErrorDoesNotContain( + "First argument of 'load' must be a label and start with either '//', ':', or '@'.", + "load('@other//foo.bzl', 'arg')"); + } + + @Test + public void testLoadStatementWithAbsoluteLabel() throws Exception { + env = newEnvironmentWithSkylarkOptions("--incompatible_load_argument_is_label"); + checkEvalErrorDoesNotContain( + "First argument of 'load' must be a label and start with either '//', ':', or '@'.", + "load('//foo.bzl', 'arg')"); + } + + @Test + public void testLoadStatementWithRelativeLabel() throws Exception { + env = newEnvironmentWithSkylarkOptions("--incompatible_load_argument_is_label"); + checkEvalErrorDoesNotContain( + "First argument of 'load' must be a label and start with either '//', ':', or '@'.", + "load(':foo.bzl', 'arg')"); + } } diff --git a/src/test/java/com/google/devtools/build/lib/syntax/util/EvaluationTestCase.java b/src/test/java/com/google/devtools/build/lib/syntax/util/EvaluationTestCase.java index 8ff4bf1401..428aefedd3 100644 --- a/src/test/java/com/google/devtools/build/lib/syntax/util/EvaluationTestCase.java +++ b/src/test/java/com/google/devtools/build/lib/syntax/util/EvaluationTestCase.java @@ -201,6 +201,14 @@ public class EvaluationTestCase { } } + public void checkEvalErrorDoesNotContain(String msg, String... input) throws Exception { + try { + eval(input); + } catch (EvalException | FailFastException e) { + assertThat(e).hasMessageThat().doesNotContain(msg); + } + } + // Forward relevant methods to the EventCollectionApparatus public EvaluationTestCase setFailFast(boolean failFast) { eventCollectionApparatus.setFailFast(failFast); |