diff options
Diffstat (limited to 'src')
3 files changed, 10 insertions, 24 deletions
diff --git a/src/main/java/com/google/devtools/build/lib/skyframe/ASTFileLookupFunction.java b/src/main/java/com/google/devtools/build/lib/skyframe/ASTFileLookupFunction.java index 7419f31b7e..e6b3a958a3 100644 --- a/src/main/java/com/google/devtools/build/lib/skyframe/ASTFileLookupFunction.java +++ b/src/main/java/com/google/devtools/build/lib/skyframe/ASTFileLookupFunction.java @@ -103,12 +103,9 @@ public class ASTFileLookupFunction implements SkyFunction { // BuildFileAST ast = null; Path path = rootedPath.asPath(); - // Skylark files end with bzl - boolean parseAsSkylark = filePathFragment.getPathString().endsWith(".bzl"); try { long astFileSize = fileValue.getSize(); - if (parseAsSkylark) { - try (Mutability mutability = Mutability.create("validate")) { + try (Mutability mutability = Mutability.create("validate")) { ValidationEnvironment validationEnv = new ValidationEnvironment( ruleClassProvider @@ -124,9 +121,6 @@ public class ASTFileLookupFunction implements SkyFunction { ast = BuildFileAST.parseSkylarkFile(path, astFileSize, env.getListener()); ast = ast.validate(validationEnv, env.getListener()); } - } else { - ast = BuildFileAST.parseBuildFile(path, astFileSize, env.getListener()); - } } catch (IOException e) { throw new ASTLookupFunctionException(new ErrorReadingSkylarkExtensionException(e), Transience.TRANSIENT); diff --git a/src/main/java/com/google/devtools/build/lib/syntax/BuildFileAST.java b/src/main/java/com/google/devtools/build/lib/syntax/BuildFileAST.java index 497715adeb..934c7f2003 100644 --- a/src/main/java/com/google/devtools/build/lib/syntax/BuildFileAST.java +++ b/src/main/java/com/google/devtools/build/lib/syntax/BuildFileAST.java @@ -234,11 +234,6 @@ public class BuildFileAST extends ASTNode { * * @throws IOException if the file cannot not be read. */ - public static BuildFileAST parseBuildFile(Path buildFile, EventHandler eventHandler) - throws IOException { - return parseBuildFile(buildFile, buildFile.getFileSize(), eventHandler); - } - public static BuildFileAST parseBuildFile(Path buildFile, long fileSize, EventHandler eventHandler) throws IOException { 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); } |