Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Only try to create groups of test actions in the ui. #16176

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -525,7 +525,7 @@ void actionStarted(ActionStartedEvent event) {

getActionState(action, actionId, event.getNanoTimeStart());

if (action.getOwner() != null) {
if (action.getOwner() != null && "TestRunner".equals(action.getOwner().getMnemonic())) {
Label owner = action.getOwner().getLabel();
if (owner != null) {
Set<Artifact> testActionsForOwner = testActions.get(owner);
Expand Down Expand Up @@ -599,7 +599,7 @@ void actionCompletion(ActionCompletionEvent event) {

checkNotNull(activeActions.remove(actionId), "%s not active after %s", actionId, event);

if (action.getOwner() != null) {
if (action.getOwner() != null && "TestRunner".equals(action.getOwner().getMnemonic())) {
Label owner = action.getOwner().getLabel();
if (owner != null) {
Set<Artifact> testActionsForOwner = testActions.get(owner);
Expand Down Expand Up @@ -745,7 +745,7 @@ private String describeActionProgress(ActionState action, int desiredWidth) {
protected String describeAction(
ActionState actionState, long nanoTime, int desiredWidth, Set<Artifact> toSkip) {
ActionExecutionMetadata action = actionState.action;
if (action.getOwner() != null) {
if (action.getOwner() != null && "TestRunner".equals(action.getOwner().getMnemonic())) {
Label owner = action.getOwner().getLabel();
if (owner != null) {
Set<Artifact> allRelatedActions = testActions.get(owner);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1159,6 +1159,7 @@ public void testAggregation() throws Exception {
ManualClock clock = new ManualClock();
clock.advanceMillis(TimeUnit.SECONDS.toMillis(1234));
UiStateTracker stateTracker = getUiStateTracker(clock, /*targetWidth=*/ 80);
stateTracker.setProgressSampleSize(4);
// Mimic being at the execution phase.
simulateExecutionPhase(stateTracker);

Expand All @@ -1170,7 +1171,7 @@ public void testAggregation() throws Exception {
labelFooTest,
ImmutableList.of(),
new Location("dummy-file", 0, 0),
"dummy-mnemonic",
"TestRunner",
"dummy-target-kind",
"abcdef",
new BuildConfigurationEvent(
Expand All @@ -1183,15 +1184,12 @@ public void testAggregation() throws Exception {
Label labelBarTest = Label.parseCanonical("//baz:bartest");
ConfiguredTarget targetBarTest = mock(ConfiguredTarget.class);
when(targetBarTest.getLabel()).thenReturn(labelBarTest);
TestFilteringCompleteEvent filteringComplete = mock(TestFilteringCompleteEvent.class);
when(filteringComplete.getTestTargets())
.thenReturn(ImmutableSet.of(targetFooTest, targetBarTest));
ActionOwner barOwner =
ActionOwner.create(
labelBarTest,
ImmutableList.of(),
new Location("dummy-file", 0, 0),
"dummy-mnemonic",
"TestRunner",
"dummy-target-kind",
"fedcba",
new BuildConfigurationEvent(
Expand All @@ -1201,6 +1199,27 @@ public void testAggregation() throws Exception {
ImmutableMap.of(),
null);

Label labelBazTest = Label.parseCanonical("//baz:baztest");
ConfiguredTarget targetBazTest = mock(ConfiguredTarget.class);
when(targetBazTest.getLabel()).thenReturn(labelBazTest);
ActionOwner bazOwner =
ActionOwner.create(
labelBazTest,
ImmutableList.of(),
new Location("dummy-file", 0, 0),
"NonTestAction",
"dummy-target-kind",
"fedcba",
new BuildConfigurationEvent(
BuildEventStreamProtos.BuildEventId.getDefaultInstance(),
BuildEventStreamProtos.BuildEvent.getDefaultInstance()),
null,
ImmutableMap.of(),
null);

TestFilteringCompleteEvent filteringComplete = mock(TestFilteringCompleteEvent.class);
when(filteringComplete.getTestTargets())
.thenReturn(ImmutableSet.of(targetFooTest, targetBarTest, targetBazTest));
stateTracker.testFilteringComplete(filteringComplete);

// First produce 10 actions for footest...
Expand All @@ -1217,10 +1236,17 @@ public void testAggregation() throws Exception {
when(action.getOwner()).thenReturn(barOwner);
stateTracker.actionStarted(new ActionStartedEvent(action, clock.nanoTime()));
}
// ...and finally a completely unrelated action
// ...run a completely unrelated action..
clock.advanceMillis(TimeUnit.SECONDS.toMillis(1));
stateTracker.actionStarted(
new ActionStartedEvent(mockAction("Other action", "other/action"), clock.nanoTime()));
// ...and finally, run actions that are associated with baztest but are not a test.
for (int i = 0; i < 10; i++) {
clock.advanceMillis(1_000);
Action action = mockAction("Doing something " + i, "someartifact_" + i);
when(action.getOwner()).thenReturn(bazOwner);
stateTracker.actionStarted(new ActionStartedEvent(action, clock.nanoTime()));
}
clock.advanceMillis(TimeUnit.SECONDS.toMillis(1));

LoggingTerminalWriter terminalWriter = new LoggingTerminalWriter(/*discardHighlight=*/ true);
Expand All @@ -1236,6 +1262,8 @@ public void testAggregation() throws Exception {
assertWithMessage("Progress bar should contain 'Other action', but was:\n" + output)
.that(output.contains("Other action"))
.isTrue();
assertThat(output).doesNotContain("Testing //baz:baztest");
assertThat(output).contains("Doing something");
}

@Test
Expand Down