diff options
Diffstat (limited to 'src/test/java/com/google/devtools/build/lib/analysis/BuildViewTest.java')
-rw-r--r-- | src/test/java/com/google/devtools/build/lib/analysis/BuildViewTest.java | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/src/test/java/com/google/devtools/build/lib/analysis/BuildViewTest.java b/src/test/java/com/google/devtools/build/lib/analysis/BuildViewTest.java index 63e7484e6d..d7be1ffaf4 100644 --- a/src/test/java/com/google/devtools/build/lib/analysis/BuildViewTest.java +++ b/src/test/java/com/google/devtools/build/lib/analysis/BuildViewTest.java @@ -167,6 +167,30 @@ public class BuildViewTest extends BuildViewTestBase { } @Test + public void testSyntaxErrorInDepPackage() throws Exception { + // Check that a loading error in a dependency is properly reported. + scratch.file("a/BUILD", + "genrule(name='x',", + " srcs = ['file.txt'],", + " outs = ['foo'],", + " cmd = 'echo')", + "@"); // syntax error + + scratch.file("b/BUILD", + "genrule(name= 'cc',", + " tools = ['//a:x'],", + " outs = ['bar'],", + " cmd = 'echo')"); + + reporter.removeHandler(failFastHandler); + EventBus eventBus = new EventBus(); + AnalysisResult result = update(eventBus, defaultFlags().with(Flag.KEEP_GOING), "//b:cc"); + + assertContainsEvent("invalid character: '@'"); + assertThat(result.hasError()).isTrue(); + } + + @Test public void testReportsAnalysisRootCauses() throws Exception { scratch.file("private/BUILD", "genrule(", @@ -1284,6 +1308,21 @@ public class BuildViewTest extends BuildViewTestBase { assertThat(owners).containsExactly("//x:b", "//x:b"); } + @Test + public void testErrorMessageForMissingPackageGroup() throws Exception { + scratch.file( + "apple/BUILD", + "py_library(name='apple', visibility=['//non:existent'])"); + reporter.removeHandler(failFastHandler); + try { + update("//apple"); + fail(); + } catch (ViewCreationFailedException e) { + // Expected. + } + assertDoesNotContainEvent("implicitly depends upon"); + } + /** Runs the same test with the reduced loading phase. */ @TestSpec(size = Suite.SMALL_TESTS) @RunWith(JUnit4.class) |