aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/test/java/com/google/devtools/build/lib/syntax
diff options
context:
space:
mode:
authorGravatar laurentlb <laurentlb@google.com>2017-05-10 12:26:15 -0400
committerGravatar Kristina Chodorow <kchodorow@google.com>2017-05-10 13:37:36 -0400
commita0fd766637d5a7ce0e052e971d2e00dceb091bfc (patch)
tree65ae81f8a630217a5a53a5b6c4cf6b46bcb10998 /src/test/java/com/google/devtools/build/lib/syntax
parented3327827d654d42337bddb053cbd47ed921fe86 (diff)
New flag --incompatible_bzl_disallow_load_after_statement
This disallows to have any statement in a .bzl file before a load() statement. RELNOTES: load() statements should be called at the top of .bzl files, before any other statement. This convention will be enforced in the future. PiperOrigin-RevId: 155636719
Diffstat (limited to 'src/test/java/com/google/devtools/build/lib/syntax')
-rw-r--r--src/test/java/com/google/devtools/build/lib/syntax/ValidationTest.java16
1 files changed, 16 insertions, 0 deletions
diff --git a/src/test/java/com/google/devtools/build/lib/syntax/ValidationTest.java b/src/test/java/com/google/devtools/build/lib/syntax/ValidationTest.java
index 85a8f8c725..9b17d4b9e4 100644
--- a/src/test/java/com/google/devtools/build/lib/syntax/ValidationTest.java
+++ b/src/test/java/com/google/devtools/build/lib/syntax/ValidationTest.java
@@ -44,6 +44,22 @@ public class ValidationTest extends EvaluationTestCase {
}
@Test
+ public void testLoadAfterStatement() throws Exception {
+ env = newEnvironmentWithSkylarkOptions("--incompatible_bzl_disallow_load_after_statement=true");
+ checkError(
+ "load() statements must be called before any other statement",
+ "a = 5",
+ "load(':b.bzl', 'c')");
+ }
+
+ @Test
+ public void testAllowLoadAfterStatement() throws Exception {
+ env =
+ newEnvironmentWithSkylarkOptions("--incompatible_bzl_disallow_load_after_statement=false");
+ parse("a = 5", "load(':b.bzl', 'c')");
+ }
+
+ @Test
public void testTwoFunctionsWithTheSameName() throws Exception {
checkError(
"Variable foo is read only", "def foo():", " return 1", "def foo(x, y):", " return 1");