diff options
author | 2016-05-24 12:58:09 +0000 | |
---|---|---|
committer | 2016-05-25 08:33:53 +0000 | |
commit | c6d3cccfc647071eb9bd03fb60043922b8560931 (patch) | |
tree | e1cb8f07a390f40d62e1ecab42fb919d7a363cf6 /src/test/java/com/google/devtools/build/lib/runtime | |
parent | 8958f1688c895ffb23134102634d5c8ea674b2a3 (diff) |
experimental UI: group test actions by label
When reporting about actions that are still running, groups those belonging
to the same test. In this way, more useful information can be presented in the
progress bar, instead of wasting a whole line for a single shard.
--
Change-Id: Id1f5a0595767906d6a75f6533be54f3c262ddd67
Reviewed-on: https://bazel-review.googlesource.com/#/c/3646
MOS_MIGRATED_REVID=123097744
Diffstat (limited to 'src/test/java/com/google/devtools/build/lib/runtime')
-rw-r--r-- | src/test/java/com/google/devtools/build/lib/runtime/ExperimentalStateTrackerTest.java | 56 |
1 files changed, 56 insertions, 0 deletions
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 83ff4795dc..a276bc516b 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 @@ -379,4 +379,60 @@ public class ExperimentalStateTrackerTest extends FoundationTestCase { doTestOutputLength(false, i); } } + + @Test + public void testAggregation() throws Exception { + // Assert that actions for the same test are aggregated so that an action afterwards + // is still shown. + ManualClock clock = new ManualClock(); + clock.advanceMillis(TimeUnit.SECONDS.toMillis(1234)); + ExperimentalStateTracker stateTracker = new ExperimentalStateTracker(clock, 80); + + Label labelFooTest = Label.parseAbsolute("//foo/bar:footest"); + ConfiguredTarget targetFooTest = Mockito.mock(ConfiguredTarget.class); + when(targetFooTest.getLabel()).thenReturn(labelFooTest); + ActionOwner fooOwner = new ActionOwner(labelFooTest, null, null, null, "abcdef", null); + + Label labelBarTest = Label.parseAbsolute("//baz:bartest"); + ConfiguredTarget targetBarTest = Mockito.mock(ConfiguredTarget.class); + when(targetBarTest.getLabel()).thenReturn(labelBarTest); + TestFilteringCompleteEvent filteringComplete = Mockito.mock(TestFilteringCompleteEvent.class); + when(filteringComplete.getTestTargets()) + .thenReturn(ImmutableSet.of(targetFooTest, targetBarTest)); + ActionOwner barOwner = new ActionOwner(labelBarTest, null, null, null, "fedcba", null); + + stateTracker.testFilteringComplete(filteringComplete); + + // First produce 10 actions for footest... + for (int i = 0; i < 10; i++) { + clock.advanceMillis(TimeUnit.SECONDS.toMillis(1)); + Action action = mockAction("Testing foo, shard " + i, "testlog_foo_" + i); + when(action.getOwner()).thenReturn(fooOwner); + stateTracker.actionStarted(new ActionStartedEvent(action, clock.nanoTime())); + } + // ...then produce 10 actions for bartest... + for (int i = 0; i < 10; i++) { + clock.advanceMillis(TimeUnit.SECONDS.toMillis(1)); + Action action = mockAction("Testing bar, shard " + i, "testlog_bar_" + i); + when(action.getOwner()).thenReturn(barOwner); + stateTracker.actionStarted(new ActionStartedEvent(action, clock.nanoTime())); + } + // ...and finally a completely unrelated action + clock.advanceMillis(TimeUnit.SECONDS.toMillis(1)); + stateTracker.actionStarted( + new ActionStartedEvent(mockAction("Other action", "other/action"), clock.nanoTime())); + clock.advanceMillis(TimeUnit.SECONDS.toMillis(1)); + + LoggingTerminalWriter terminalWriter = new LoggingTerminalWriter(/*discardHighlight=*/ true); + stateTracker.writeProgressBar(terminalWriter); + String output = terminalWriter.getTranscript(); + + assertTrue( + "Progress bar should contain ':footest', but was:\n" + output, output.contains(":footest")); + assertTrue( + "Progress bar should contain ':bartest', but was:\n" + output, output.contains(":bartest")); + assertTrue( + "Progress bar should contain 'Other action', but was:\n" + output, + output.contains("Other action")); + } } |