Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support BUILD.bazel files along BUILDin errors parsing #5206

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@
/** Parses blaze output for compile errors. */
public class BlazeIssueParser {

private static final String BAZEL_BUILD_FILES_PATTERN = "(/.*?BUILD(?:\\.bazel)?)";

public static ImmutableList<BlazeIssueParser.Parser> defaultIssueParsers(
Project project,
WorkspaceRoot workspaceRoot,
Expand Down Expand Up @@ -294,7 +296,7 @@ public ParseResult parse(String currentLine, List<String> previousLines) {

static class BuildParser extends SingleLineParser {
BuildParser() {
super("^ERROR: (/.*?BUILD):([0-9]+):([0-9]+): (.*)$");
super("^ERROR: " + BAZEL_BUILD_FILES_PATTERN + ":([0-9]+):([0-9]+): (.*)$");
}

@Nullable
Expand Down Expand Up @@ -440,7 +442,7 @@ static class GenericErrorParser extends SingleLineParser {
+ "(.*: Process exited with status [0-9]+\\.)|"
+ "(build interrupted\\.)|"
+ "(Couldn't start the build. Unable to run tests.)|"
+ "(/.*?BUILD:[0-9]+:[0-9]+: Couldn't build file .*)|"
+ "(" + BAZEL_BUILD_FILES_PATTERN + ":[0-9]+:[0-9]+: Couldn't build file .*)|"
+ "(.*))$";

private GenericErrorParser() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,26 @@ public void testParseBuildError() {
"ERROR: ".length(), "ERROR: /root/javatests/package_path/BUILD:42:12".length()));
}

@Test
public void testParseBuildBazelError() {
BlazeIssueParser blazeIssueParser = new BlazeIssueParser(parsers);
IssueOutput issue =
blazeIssueParser.parseIssue(
"ERROR: /root/javatests/package_path/BUILD.bazel:42:12: "
+ "Target '//java/package_path:helloroot_visibility' failed");
assertThat(issue).isNotNull();
assertThat(issue.getFile().getPath()).isEqualTo("/root/javatests/package_path/BUILD.bazel");
assertThat(issue.getLine()).isEqualTo(42);
assertThat(issue.getColumn()).isEqualTo(12);
assertThat(issue.getMessage())
.isEqualTo("Target '//java/package_path:helloroot_visibility' failed");
assertThat(issue.getCategory()).isEqualTo(ERROR);
assertThat(issue.getConsoleHyperlinkRange())
.isEqualTo(
TextRange.create(
"ERROR: ".length(), "ERROR: /root/javatests/package_path/BUILD.bazel:42:12".length()));
}

@Test
public void testParseSkylarkError() {
BlazeIssueParser blazeIssueParser = new BlazeIssueParser(parsers);
Expand Down
Loading