diff options
author | 2017-07-14 12:25:11 +0200 | |
---|---|---|
committer | 2017-07-14 12:55:28 +0200 | |
commit | 57ff834702f75760e2d611590e44c13f7b3c580d (patch) | |
tree | d9dadcccd13fd42581599eafa34d9722017a07e0 | |
parent | 678c852b33974ca573a382f3a4392c007fcefe62 (diff) |
experimental UI: keep console updated till the end
For commands that do not send a BuildFinishedEvent, we normally use the
NoBuildEvent to determine the end of the build and hence the moment
where the UI should not any more interfere with the output. For some
requests, like fetch, however, we should continue to report progress
till the very end (as there is no output to interfere with). Do so,
and also be sure that the experimental UI also reports downloads if
not explicitly in a loading or analysis phase.
While there, also group digits in the number of downloaded bytes, to
increase readability.
Change-Id: I31efeee5bdb1d29b2ecf842acb3e383e297707f8
PiperOrigin-RevId: 161935456
5 files changed, 49 insertions, 5 deletions
diff --git a/src/main/java/com/google/devtools/build/lib/analysis/NoBuildEvent.java b/src/main/java/com/google/devtools/build/lib/analysis/NoBuildEvent.java index cd0b83f170..61f808997d 100644 --- a/src/main/java/com/google/devtools/build/lib/analysis/NoBuildEvent.java +++ b/src/main/java/com/google/devtools/build/lib/analysis/NoBuildEvent.java @@ -28,11 +28,21 @@ public final class NoBuildEvent implements BuildEvent { private final String command; private final Long startTimeMillis; private final boolean separateFinishedEvent; + private final boolean keepShowingProgress; - public NoBuildEvent(String command, Long startTimeMillis, boolean separateFinishedEvent) { + public NoBuildEvent( + String command, + Long startTimeMillis, + boolean separateFinishedEvent, + boolean keepShowingProgress) { this.command = command; this.startTimeMillis = startTimeMillis; this.separateFinishedEvent = separateFinishedEvent; + this.keepShowingProgress = keepShowingProgress; + } + + public NoBuildEvent(String command, Long startTimeMillis, boolean separateFinishedEvent) { + this(command, startTimeMillis, separateFinishedEvent, false); } public NoBuildEvent() { @@ -70,4 +80,8 @@ public final class NoBuildEvent implements BuildEvent { public boolean separateFinishedEvent() { return separateFinishedEvent; } + + public boolean keepShowingProgress() { + return keepShowingProgress; + } } diff --git a/src/main/java/com/google/devtools/build/lib/bazel/commands/FetchCommand.java b/src/main/java/com/google/devtools/build/lib/bazel/commands/FetchCommand.java index b47fa353b3..833642b80a 100644 --- a/src/main/java/com/google/devtools/build/lib/bazel/commands/FetchCommand.java +++ b/src/main/java/com/google/devtools/build/lib/bazel/commands/FetchCommand.java @@ -111,7 +111,9 @@ public final class FetchCommand implements BlazeCommand { return ExitCode.COMMAND_LINE_ERROR; } - env.getReporter().post(new NoBuildEvent(env.getCommandName(), env.getCommandStartTime(), true)); + env.getReporter() + .post(new NoBuildEvent(env.getCommandName(), env.getCommandStartTime(), true, true)); + // 2. Evaluate expression: try { queryEnv.evaluateQuery(expr, new ThreadSafeOutputFormatterCallback<Target>() { diff --git a/src/main/java/com/google/devtools/build/lib/bazel/repository/downloader/DownloadProgressEvent.java b/src/main/java/com/google/devtools/build/lib/bazel/repository/downloader/DownloadProgressEvent.java index 86d2ef6b4d..5d74ddc676 100644 --- a/src/main/java/com/google/devtools/build/lib/bazel/repository/downloader/DownloadProgressEvent.java +++ b/src/main/java/com/google/devtools/build/lib/bazel/repository/downloader/DownloadProgressEvent.java @@ -16,6 +16,8 @@ package com.google.devtools.build.lib.bazel.repository.downloader; import com.google.devtools.build.lib.events.ExtendedEventHandler; import java.net.URL; +import java.text.NumberFormat; +import java.util.Locale; /** * Postable event reporting on progress made downloading an URL. It can be used to report the URL @@ -70,6 +72,12 @@ public class DownloadProgressEvent implements ExtendedEventHandler.FetchProgress @Override public String getProgress() { - return bytesRead > 0 ? "" + bytesRead + "b" : ""; + if (bytesRead > 0) { + NumberFormat formatter = NumberFormat.getIntegerInstance(Locale.ENGLISH); + formatter.setGroupingUsed(true); + return formatter.format(bytesRead) + "b"; + } else { + return ""; + } } } 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 391a6c1dff..0235a32ff8 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 @@ -22,6 +22,7 @@ import com.google.devtools.build.lib.actions.ActionStartedEvent; import com.google.devtools.build.lib.actions.ActionStatusMessage; import com.google.devtools.build.lib.analysis.AnalysisPhaseCompleteEvent; import com.google.devtools.build.lib.analysis.NoBuildEvent; +import com.google.devtools.build.lib.analysis.NoBuildRequestFinishedEvent; import com.google.devtools.build.lib.buildeventstream.AnnounceBuildEventTransportsEvent; import com.google.devtools.build.lib.buildeventstream.BuildEventTransport; import com.google.devtools.build.lib.buildeventstream.BuildEventTransportClosedEvent; @@ -470,9 +471,11 @@ public class ExperimentalEventHandler implements EventHandler { } } - @Subscribe - public void noBuild(NoBuildEvent event) { + private void completeBuild() { synchronized (this) { + if (buildComplete) { + return; + } buildComplete = true; } stopUpdateThread(); @@ -480,6 +483,19 @@ public class ExperimentalEventHandler implements EventHandler { } @Subscribe + public void noBuild(NoBuildEvent event) { + if (event.keepShowingProgress()) { + return; + } + completeBuild(); + } + + @Subscribe + public void noBuildFinished(NoBuildRequestFinishedEvent event) { + completeBuild(); + } + + @Subscribe public void afterCommand(AfterCommandEvent event) { synchronized (this) { buildComplete = true; diff --git a/src/main/java/com/google/devtools/build/lib/runtime/ExperimentalStateTracker.java b/src/main/java/com/google/devtools/build/lib/runtime/ExperimentalStateTracker.java index ea6329d94e..921a6dccb9 100644 --- a/src/main/java/com/google/devtools/build/lib/runtime/ExperimentalStateTracker.java +++ b/src/main/java/com/google/devtools/build/lib/runtime/ExperimentalStateTracker.java @@ -776,6 +776,10 @@ class ExperimentalStateTracker { sampleOldestActions(terminalWriter); } } + if (!shortVersion) { + reportOnDownloads(terminalWriter); + maybeReportBepTransports(terminalWriter); + } } void writeProgressBar(AnsiTerminalWriter terminalWriter, boolean shortVersion) |