experimental UI: show run-time for long-running actions in the progress bar
Currently, the progress bar shows the 3 earliest started still running actions.
While this might give some indication about which actions delay the build process,
it lacks quantitative information about how long the delay is. By adding the current
run time to the progress bar, at least some quantitative information is provided.
--
Change-Id: Ib90eda67d87384a4372cda7779a09a44cea2b8dd
Reviewed-on: https://bazel-review.googlesource.com/#/c/3205
MOS_MIGRATED_REVID=118933973
diff --git a/src/test/java/com/google/devtools/build/lib/runtime/ExperimentalStateTrackerTest.java b/src/test/java/com/google/devtools/build/lib/runtime/ExperimentalStateTrackerTest.java
index 0f833d1..1f2ac9a 100644
--- a/src/test/java/com/google/devtools/build/lib/runtime/ExperimentalStateTrackerTest.java
+++ b/src/test/java/com/google/devtools/build/lib/runtime/ExperimentalStateTrackerTest.java
@@ -34,6 +34,7 @@
import org.mockito.Mockito;
import java.io.IOException;
+import java.util.concurrent.TimeUnit;
/**
* Tests {@link ExperimentalStateTrackerTest}
@@ -162,4 +163,31 @@
"Longest running action '" + messageOld + "' should be visible in output: " + output,
output.contains(messageOld));
}
+
+ @Test
+ public void testTimesShown() throws IOException {
+ // For sufficiently long running actions, the time that has passed since their start is shown.
+
+ ManualClock clock = new ManualClock();
+ clock.advanceMillis(TimeUnit.SECONDS.toMillis(123));
+ ExperimentalStateTracker stateTracker = new ExperimentalStateTracker(clock);
+ clock.advanceMillis(TimeUnit.SECONDS.toMillis(2));
+
+ stateTracker.actionStarted(
+ new ActionStartedEvent(mockAction("First action", "foo"), clock.nanoTime()));
+ clock.advanceMillis(TimeUnit.SECONDS.toMillis(7));
+ stateTracker.actionStarted(
+ new ActionStartedEvent(mockAction("Second action", "bar"), clock.nanoTime()));
+ clock.advanceMillis(TimeUnit.SECONDS.toMillis(20));
+
+ LoggingTerminalWriter terminalWriter = new LoggingTerminalWriter();
+ stateTracker.writeProgressBar(terminalWriter);
+ String output = terminalWriter.getWritten();
+
+ assertTrue(
+ "Runtime of first action should be visible in output: " + output, output.contains("27s"));
+ assertTrue(
+ "Runtime of second action should be visible in output: " + output, output.contains("20s"));
+ }
+
}