use of com.google.devtools.build.lib.analysis.BuildView.AnalysisResult in project bazel by bazelbuild.
the class BuildViewTest method testAnalysisErrorMessageWithKeepGoing.
@Test
public void testAnalysisErrorMessageWithKeepGoing() throws Exception {
scratch.file("a/BUILD", "sh_binary(name='a', srcs=['a1.sh', 'a2.sh'])");
reporter.removeHandler(failFastHandler);
AnalysisResult result = update(defaultFlags().with(Flag.KEEP_GOING), "//a");
assertThat(result.hasError()).isTrue();
assertContainsEvent("errors encountered while analyzing target '//a:a'");
}
use of com.google.devtools.build.lib.analysis.BuildView.AnalysisResult in project bazel by bazelbuild.
the class BuildViewTest method testMultipleRootCauseReporting.
@Test
public void testMultipleRootCauseReporting() throws Exception {
scratch.file("gp/BUILD", "sh_library(name = 'gp', deps = ['//p:p'])");
scratch.file("p/BUILD", "sh_library(name = 'p', deps = ['//c1:not', '//c2:not'])");
scratch.file("c1/BUILD");
scratch.file("c2/BUILD");
reporter.removeHandler(failFastHandler);
EventBus eventBus = new EventBus();
LoadingFailureRecorder recorder = new LoadingFailureRecorder();
eventBus.register(recorder);
AnalysisResult result = update(eventBus, defaultFlags().with(Flag.KEEP_GOING), "//gp");
assertThat(result.hasError()).isTrue();
assertThat(recorder.events).hasSize(2);
assertTrue(recorder.events.toString(), recorder.events.contains(Pair.of(Label.parseAbsolute("//gp"), Label.parseAbsolute("//c1:not"))));
assertThat(recorder.events).contains(Pair.of(Label.parseAbsolute("//gp"), Label.parseAbsolute("//c2:not")));
}
use of com.google.devtools.build.lib.analysis.BuildView.AnalysisResult in project bazel by bazelbuild.
the class BuildViewTest method testRootCauseReportingFileSymlinks.
/**
* Tests that skyframe reports the root cause as being the target that depended on the symlink
* cycle.
*/
@Test
public void testRootCauseReportingFileSymlinks() throws Exception {
scratch.file("gp/BUILD", "sh_library(name = 'gp', deps = ['//p'])");
scratch.file("p/BUILD", "sh_library(name = 'p', deps = ['//c'])");
scratch.file("c/BUILD", "sh_library(name = 'c', deps = [':c1', ':c2'])", "sh_library(name = 'c1', deps = ['//cycles1'])", "sh_library(name = 'c2', deps = ['//cycles2'])");
Path cycles1BuildFilePath = scratch.file("cycles1/BUILD", "sh_library(name = 'cycles1', srcs = glob(['*.sh']))");
Path cycles2BuildFilePath = scratch.file("cycles2/BUILD", "sh_library(name = 'cycles2', srcs = glob(['*.sh']))");
cycles1BuildFilePath.getParentDirectory().getRelative("cycles1.sh").createSymbolicLink(new PathFragment("cycles1.sh"));
cycles2BuildFilePath.getParentDirectory().getRelative("cycles2.sh").createSymbolicLink(new PathFragment("cycles2.sh"));
reporter.removeHandler(failFastHandler);
EventBus eventBus = new EventBus();
LoadingFailureRecorder recorder = new LoadingFailureRecorder();
eventBus.register(recorder);
AnalysisResult result = update(eventBus, defaultFlags().with(Flag.KEEP_GOING), "//gp");
assertThat(result.hasError()).isTrue();
assertThat(recorder.events).hasSize(2);
assertTrue(recorder.events.toString(), recorder.events.contains(Pair.of(Label.parseAbsolute("//gp"), Label.parseAbsolute("//cycles1"))));
assertTrue(recorder.events.toString(), recorder.events.contains(Pair.of(Label.parseAbsolute("//gp"), Label.parseAbsolute("//cycles2"))));
}
use of com.google.devtools.build.lib.analysis.BuildView.AnalysisResult in project bazel by bazelbuild.
the class BuildViewTest method testConvolutedLoadRootCauseAnalysis.
@Test
public void testConvolutedLoadRootCauseAnalysis() throws Exception {
// You need license declarations in third_party. We use this constraint to
// create targets that are loadable, but are in error.
scratch.file("third_party/first/BUILD", "sh_library(name='first', deps=['//third_party/second'], licenses=['notice'])");
scratch.file("third_party/second/BUILD", "sh_library(name='second', deps=['//third_party/third'], licenses=['notice'])");
scratch.file("third_party/third/BUILD", "sh_library(name='third', deps=['//third_party/fourth'], licenses=['notice'])");
scratch.file("third_party/fourth/BUILD", "sh_library(name='fourth', deps=['//third_party/fifth'])");
scratch.file("third_party/fifth/BUILD", "sh_library(name='fifth', licenses=['notice'])");
reporter.removeHandler(failFastHandler);
EventBus eventBus = new EventBus();
LoadingFailureRecorder recorder = new LoadingFailureRecorder();
eventBus.register(recorder);
// Note: no need to run analysis for a loading failure.
AnalysisResult result = update(eventBus, defaultFlags().with(Flag.KEEP_GOING), "//third_party/first", "//third_party/third");
assertThat(result.hasError()).isTrue();
assertThat(recorder.events).hasSize(2);
assertTrue(recorder.events.toString(), recorder.events.contains(Pair.of(Label.parseAbsolute("//third_party/first"), Label.parseAbsolute("//third_party/fourth"))));
assertThat(recorder.events).contains(Pair.of(Label.parseAbsolute("//third_party/third"), Label.parseAbsolute("//third_party/fourth")));
}
Aggregations