experimental UI: don't update progress bar after end of build
After completion of the build, there is no need to update the
progress bar any more. Its last line can just move to the scrollback
buffer. The advantage of doing so, is that we then can pass through
STDOUT and STDERR events without additional interference, like line
ending to be sure to know where we position the progress bar and
additional control characters to position the progress bar itself.
In particular, the preformated status report of the tests that were
run will be displayed properly. This makes the experimental UI also
minimally usable for tests.
--
Change-Id: Idaa389b93fc8c9c46c0930f66b4f69b16c3d2e0b
Reviewed-on: https://bazel-review.googlesource.com/#/c/3046
MOS_MIGRATED_REVID=116350626
diff --git a/src/main/java/com/google/devtools/build/lib/runtime/ExperimentalEventHandler.java b/src/main/java/com/google/devtools/build/lib/runtime/ExperimentalEventHandler.java
index a57b3a8..5b38f0f 100644
--- a/src/main/java/com/google/devtools/build/lib/runtime/ExperimentalEventHandler.java
+++ b/src/main/java/com/google/devtools/build/lib/runtime/ExperimentalEventHandler.java
@@ -43,6 +43,7 @@
private final boolean debugAllEvents;
private final ExperimentalStateTracker stateTracker;
private int numLinesProgressBar;
+ private boolean buildComplete;
public final int terminalWidth;
@@ -70,17 +71,23 @@
switch (event.getKind()) {
case STDOUT:
case STDERR:
- clearProgressBar();
- terminal.flush();
+ if (!buildComplete) {
+ clearProgressBar();
+ terminal.flush();
+ }
OutputStream stream =
event.getKind() == EventKind.STDOUT
? outErr.getOutputStream()
: outErr.getErrorStream();
stream.write(event.getMessageBytes());
- stream.write(new byte[] {10, 13});
+ if (!buildComplete) {
+ stream.write(new byte[] {10, 13});
+ }
stream.flush();
- addProgressBar();
- terminal.flush();
+ if (!buildComplete) {
+ addProgressBar();
+ terminal.flush();
+ }
break;
case ERROR:
case WARNING:
@@ -148,6 +155,7 @@
public void buildComplete(BuildCompleteEvent event) {
stateTracker.buildComplete(event);
refresh();
+ buildComplete = true;
}
@Subscribe