Skip to content

Commit

Permalink
propagate hasError and hasWarning
Browse files Browse the repository at this point in the history
  • Loading branch information
LeFrosch committed Oct 18, 2024
1 parent 2abc9c4 commit e2ac26a
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,9 @@ protected SyncOutput runSync(BlazeSyncParams params) {
PlatformTestUtil.dispatchAllInvocationEventsInIdeEventQueue();
}

output.setHasErrors(context.hasErrors());
output.setHasWarnings(context.hasWarnings());

context.close();
LOG.info(String.format("PROJECT SYNC LOG:%n%s", output.collectLog()));

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.google.idea.blaze.base;

import static com.google.common.truth.Truth.assertThat;
import static com.google.common.truth.Truth.assertWithMessage;

import com.google.idea.blaze.base.scope.BlazeContext;
import com.google.idea.blaze.base.scope.OutputSink.Propagation;
Expand All @@ -12,8 +13,12 @@
import java.util.ArrayList;
import java.util.List;
import java.util.function.Consumer;
import org.jetbrains.annotations.Nullable;

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

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

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

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

public boolean getHasErrors() {
assertThat(hasErrors).isNotNull();
return hasErrors;
}

void setHasWarnings(boolean hasWarnings) {
this.hasWarnings = hasWarnings;
}

public boolean getHasWarnings() {
assertThat(hasWarnings).isNotNull();
return hasWarnings;
}

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 @@ -55,6 +78,8 @@ public void assertNoErrors() {
collectLog()
);

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

0 comments on commit e2ac26a

Please sign in to comment.