Skip to content

Commit

Permalink
improved error reporting by tests
Browse files Browse the repository at this point in the history
  • Loading branch information
LeFrosch committed Oct 10, 2024
1 parent 5ac22de commit 914485d
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -878,7 +878,7 @@ private static void logSyncError(BlazeContext context, Throwable e) {
}
cause = cause.getCause();
}
logger.error(e);
IssueOutput.error("Internal error: " + e.getMessage()).submit(context);
logger.error(e);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,7 @@ protected SyncOutput runSync(BlazeSyncParams params) {
context.close();
LOG.info(String.format("PROJECT SYNC LOG:%n%s", output.collectLog()));

output.setHasErrors(context.hasErrors());
return output;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,11 @@
import java.util.ArrayList;
import java.util.List;
import java.util.function.Consumer;
import java.util.stream.Collectors;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

public class SyncOutput {
private @Nullable Boolean hasErrors = null;

private final List<IssueOutput> issues = new ArrayList<>();
private final List<String> messages = new ArrayList<>();

Expand All @@ -28,6 +29,10 @@ void install(BlazeContext context) {
addOutputSink(context, SummaryOutput.class, (it) -> messages.add(it.getText()));
}

void setHasErrors(boolean hasErrors) {
this.hasErrors = hasErrors;
}

private <T extends Output> void addOutputSink(BlazeContext context, Class<T> clazz, Consumer<T> consumer) {
context.addOutputSink(clazz, (it) -> {
consumer.accept(it);
Expand Down Expand Up @@ -59,6 +64,7 @@ public void assertNoErrors() {
collectLog()
);

assertThat(issues).isEmpty();
assertWithMessage(message).that(issues).isEmpty();
assertWithMessage(message).that(hasErrors).isFalse();
}
}

0 comments on commit 914485d

Please sign in to comment.