aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/test/java/com/google/devtools
diff options
context:
space:
mode:
Diffstat (limited to 'src/test/java/com/google/devtools')
-rw-r--r--src/test/java/com/google/devtools/build/lib/syntax/SkylarkEvaluationTest.java44
-rw-r--r--src/test/java/com/google/devtools/build/lib/syntax/util/EvaluationTestCase.java8
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);