aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/test/java/com/google/devtools/build/lib/syntax/BuildFileASTTest.java
diff options
context:
space:
mode:
authorGravatar Laurent Le Brun <laurentlb@google.com>2016-10-11 12:23:01 +0000
committerGravatar Yue Gan <yueg@google.com>2016-10-11 13:26:55 +0000
commit884ca5ccf3c3241402149a4262d8a71da8e2e70f (patch)
tree3af8ca0b91a323feca69cf1aa91b5303ccd96bc1 /src/test/java/com/google/devtools/build/lib/syntax/BuildFileASTTest.java
parent44ad7fa47e99edbda73484760990980fe99931d9 (diff)
Minor cleanup
- Load prelude_bazel as a .bzl file (to simplify code paths) - Remove a function in BuildFileAST that was used only in tests -- MOS_MIGRATED_REVID=135785708
Diffstat (limited to 'src/test/java/com/google/devtools/build/lib/syntax/BuildFileASTTest.java')
-rw-r--r--src/test/java/com/google/devtools/build/lib/syntax/BuildFileASTTest.java21
1 files changed, 9 insertions, 12 deletions
diff --git a/src/test/java/com/google/devtools/build/lib/syntax/BuildFileASTTest.java b/src/test/java/com/google/devtools/build/lib/syntax/BuildFileASTTest.java
index c42ea93e3e..ff448339be 100644
--- a/src/test/java/com/google/devtools/build/lib/syntax/BuildFileASTTest.java
+++ b/src/test/java/com/google/devtools/build/lib/syntax/BuildFileASTTest.java
@@ -48,18 +48,16 @@ public class BuildFileASTTest extends EvaluationTestCase {
*/
private BuildFileAST parseBuildFile(String... lines) throws IOException {
Path file = scratch.file("/a/build/file/BUILD", lines);
- return BuildFileAST.parseBuildFile(file, getEventHandler());
+ return BuildFileAST.parseBuildFile(file, file.getFileSize(), getEventHandler());
}
@Test
public void testParseBuildFileOK() throws Exception {
- Path buildFile = scratch.file("/BUILD",
+ BuildFileAST buildfile = parseBuildFile(
"# a file in the build language",
"",
"x = [1,2,'foo',4] + [1,2, \"%s%d\" % ('foo', 1)]");
- BuildFileAST buildfile = BuildFileAST.parseBuildFile(buildFile, getEventHandler());
-
assertTrue(buildfile.exec(env, getEventHandler()));
// Test final environment is correctly modified:
@@ -72,15 +70,13 @@ public class BuildFileASTTest extends EvaluationTestCase {
@Test
public void testEvalException() throws Exception {
- Path buildFile = scratch.file("/input1.BUILD",
+ setFailFast(false);
+ BuildFileAST buildfile = parseBuildFile(
"x = 1",
"y = [2,3]",
"",
"z = x + y");
- setFailFast(false);
- BuildFileAST buildfile = BuildFileAST.parseBuildFile(buildFile, getEventHandler());
-
assertFalse(buildfile.exec(env, getEventHandler()));
Event e = assertContainsError("unsupported operand type(s) for +: 'int' and 'list'");
assertEquals(4, e.getLocation().getStartLineAndColumn().getLine());
@@ -88,10 +84,11 @@ public class BuildFileASTTest extends EvaluationTestCase {
@Test
public void testParsesFineWithNewlines() throws Exception {
- BuildFileAST buildFileAST = parseBuildFile("foo()\n"
- + "bar()\n"
- + "something = baz()\n"
- + "bar()");
+ BuildFileAST buildFileAST = parseBuildFile(
+ "foo()",
+ "bar(),",
+ "something = baz()",
+ "bar()");
assertThat(buildFileAST.getStatements()).hasSize(4);
}