use of com.google.devtools.build.lib.events.Event in project bazel by bazelbuild.
the class SkyframeActionExecutor method printError.
/**
* For the action 'action' that failed due to 'ex' with the output
* 'actionOutput', notify the user about the error. To notify the user, the
* method first displays the output of the action and then reports an error
* via the reporter. The method ensures that the two messages appear next to
* each other by locking the outErr object where the output is displayed.
*
* @param message The reason why the action failed
* @param action The action that failed, must not be null.
* @param actionOutput The output of the failed Action.
* May be null, if there is no output to display
*/
private void printError(String message, Action action, FileOutErr actionOutput) {
synchronized (reporter) {
if (keepGoing) {
message = "Couldn't " + describeAction(action) + ": " + message;
}
Event event = Event.error(action.getOwner().getLocation(), message);
dumpRecordedOutErr(event, actionOutput);
recordExecutionError();
}
}
use of com.google.devtools.build.lib.events.Event in project bazel by bazelbuild.
the class EventCollectorTest method collectsEvents.
@Test
public void collectsEvents() {
EventCollector collector = new EventCollector();
collector.handle(event);
Iterator<Event> collectedEventIt = collector.iterator();
Event onlyEvent = collectedEventIt.next();
assertEquals(event.getMessage(), onlyEvent.getMessage());
assertSame(location, onlyEvent.getLocation());
assertEquals(event.getKind(), onlyEvent.getKind());
assertEquals(event.getLocation().getStartOffset(), onlyEvent.getLocation().getStartOffset());
assertFalse(collectedEventIt.hasNext());
}
use of com.google.devtools.build.lib.events.Event in project bazel by bazelbuild.
the class ValidationTest method testDollarErrorDoesNotLeak.
@Test
public void testDollarErrorDoesNotLeak() throws Exception {
setFailFast(false);
parseFile("def GenerateMapNames():", " a = 2", " b = [3, 4]", " if a not b:", " print(a)");
assertContainsError("syntax error at 'b': expected in");
// It should not be used in error messages.
for (Event event : getEventCollector()) {
assertThat(event.getMessage()).doesNotContain("$error$");
}
}
use of com.google.devtools.build.lib.events.Event in project bazel by bazelbuild.
the class BuildFileASTTest method testImplicitStringConcatenationAcrossLinesIsIllegal.
@Test
public void testImplicitStringConcatenationAcrossLinesIsIllegal() throws Exception {
setFailFast(false);
BuildFileAST buildFileAST = parseBuildFile("a = 'foo'\n 'bar'");
Event event = assertContainsError("indentation error");
assertEquals("/a/build/file/BUILD", event.getLocation().getPath().toString());
assertEquals(2, event.getLocation().getStartLineAndColumn().getLine());
assertEquals(2, event.getLocation().getStartLineAndColumn().getColumn());
assertTrue(buildFileAST.containsErrors());
}
use of com.google.devtools.build.lib.events.Event in project bazel by bazelbuild.
the class BuildFileASTTest method testFailsIfNewlinesAreMissing.
@Test
public void testFailsIfNewlinesAreMissing() throws Exception {
setFailFast(false);
BuildFileAST buildFileAST = parseBuildFile("foo() bar() something = baz() bar()");
Event event = assertContainsError("syntax error at \'bar\': expected newline");
assertEquals("/a/build/file/BUILD", event.getLocation().getPath().toString());
assertEquals(1, event.getLocation().getStartLineAndColumn().getLine());
assertTrue(buildFileAST.containsErrors());
}
Aggregations