aboutsummaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authorGravatar Klaus Aehlig <aehlig@google.com>2016-06-14 14:00:27 +0000
committerGravatar Yue Gan <yueg@google.com>2016-06-15 08:34:48 +0000
commitadae32a636d05c02d116fc944faa672a8d980415 (patch)
treeb7a63a69742ae1b3a49eacc53aeff2143351d01a /src
parentf7b5e46edc17d3316b7e1df7a3e522039723b35e (diff)
Make experimental UI honor --noshow_progress
While there is little value in using the experimental UI if no progress output is desired, we still want the experimental UI to serve as a drop-in replacement for the old one, including the ability to not show any progress. -- Change-Id: I54c67a6f432541611da8b4ab7e7f88bb85926391 Reviewed-on: https://bazel-review.googlesource.com/#/c/3803 MOS_MIGRATED_REVID=124833575
Diffstat (limited to 'src')
-rw-r--r--src/main/java/com/google/devtools/build/lib/runtime/ExperimentalEventHandler.java20
-rwxr-xr-xsrc/test/shell/integration/experimental_ui_test.sh9
2 files changed, 21 insertions, 8 deletions
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 09720400ef..0a67b244b3 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
@@ -61,6 +61,7 @@ public class ExperimentalEventHandler extends BlazeCommandEventHandler {
private final boolean debugAllEvents;
private final ExperimentalStateTracker stateTracker;
private final long minimalUpdateInterval;
+ private final boolean showProgress;
private long lastRefreshMillis;
private int numLinesProgressBar;
private boolean buildComplete;
@@ -77,6 +78,7 @@ public class ExperimentalEventHandler extends BlazeCommandEventHandler {
this.cursorControl = options.useCursorControl();
this.terminal = new AnsiTerminal(outErr.getErrorStream());
this.terminalWidth = (options.terminalColumns > 0 ? options.terminalColumns : 80);
+ this.showProgress = options.showProgress;
this.clock = clock;
this.debugAllEvents = options.experimentalUiDebugAllEvents;
// If we have cursor control, we try to fit in the terminal width to avoid having
@@ -135,7 +137,7 @@ public class ExperimentalEventHandler extends BlazeCommandEventHandler {
stderrBuffer = restMessage;
}
stream.flush();
- if (cursorControl) {
+ if (showProgress && cursorControl) {
addProgressBar();
}
terminal.flush();
@@ -153,7 +155,7 @@ public class ExperimentalEventHandler extends BlazeCommandEventHandler {
case WARNING:
case INFO:
case SUBCOMMAND:
- if (!buildComplete) {
+ if (showProgress && !buildComplete) {
clearProgressBar();
}
outErr.getOutputStream().write(stdoutBuffer);
@@ -173,7 +175,7 @@ public class ExperimentalEventHandler extends BlazeCommandEventHandler {
terminal.writeString(event.getMessage());
}
crlf();
- if (!buildComplete) {
+ if (showProgress && !buildComplete) {
addProgressBar();
}
terminal.flush();
@@ -307,7 +309,7 @@ public class ExperimentalEventHandler extends BlazeCommandEventHandler {
if (summary.getFailedLogs().size() > 0) {
crlf();
}
- if (cursorControl) {
+ if (showProgress && cursorControl) {
addProgressBar();
}
terminal.flush();
@@ -320,8 +322,10 @@ public class ExperimentalEventHandler extends BlazeCommandEventHandler {
}
private void refresh() {
- progressBarNeedsRefresh = true;
- doRefresh();
+ if (showProgress) {
+ progressBarNeedsRefresh = true;
+ doRefresh();
+ }
}
private void doRefresh() {
@@ -329,7 +333,7 @@ public class ExperimentalEventHandler extends BlazeCommandEventHandler {
if (lastRefreshMillis + minimalDelayMillis < nowMillis) {
synchronized (this) {
try {
- if (progressBarNeedsRefresh || timeBasedRefresh()) {
+ if (showProgress && (progressBarNeedsRefresh || timeBasedRefresh())) {
progressBarNeedsRefresh = false;
lastRefreshMillis = nowMillis;
clearProgressBar();
@@ -355,7 +359,7 @@ public class ExperimentalEventHandler extends BlazeCommandEventHandler {
* Decide wheter the progress bar should be redrawn only for the reason
* that time has passed.
*/
- private synchronized boolean timeBasedRefresh () {
+ private synchronized boolean timeBasedRefresh() {
if (!stateTracker.progressBarTimeDependent()) {
return false;
}
diff --git a/src/test/shell/integration/experimental_ui_test.sh b/src/test/shell/integration/experimental_ui_test.sh
index 3734b7bb24..2ec869f8a9 100755
--- a/src/test/shell/integration/experimental_ui_test.sh
+++ b/src/test/shell/integration/experimental_ui_test.sh
@@ -92,6 +92,15 @@ function test_basic_progress() {
expect_log 'Analy.*pkg:true'
}
+function test_noshow_progress() {
+ bazel test --experimental_ui --noshow_progress --curses=yes --color=yes \
+ pkg:true 2>$TEST_log || fail "bazel test failed"
+ # Info messages should still go through
+ expect_log 'Elapsed time'
+ # no progress indicator is shown
+ expect_not_log '\[[0-9,]* / [0-9,]*\]'
+}
+
function test_basic_progress_no_curses() {
bazel test --experimental_ui --curses=no --color=yes pkg:true 2>$TEST_log \
|| fail "bazel test failed"