use of com.google.devtools.build.lib.actions.ActionOwner in project bazel by bazelbuild.
the class ExperimentalStateTrackerTest method testAggregation.
@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 = ActionOwner.create(labelFooTest, ImmutableList.<AspectDescriptor>of(), 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 = ActionOwner.create(labelBarTest, ImmutableList.<AspectDescriptor>of(), 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"));
}
use of com.google.devtools.build.lib.actions.ActionOwner in project bazel by bazelbuild.
the class ExperimentalStateTrackerTest method testSensibleShortening.
@Test
public void testSensibleShortening() throws Exception {
// Verify that in the typical case, we shorten the progress message by shortening
// the path implicit in it, that can also be extracted from the label. In particular,
// the parts
ManualClock clock = new ManualClock();
ExperimentalStateTracker stateTracker = new ExperimentalStateTracker(clock, 70);
Action action = mockAction("Building some/very/very/long/path/for/some/library/directory/foo.jar (42 source files)", "/home/user/bazel/out/abcdef/some/very/very/long/path/for/some/library/directory/foo.jar");
Label label = Label.parseAbsolute("//some/very/very/long/path/for/some/library/directory:libfoo");
ActionOwner owner = ActionOwner.create(label, ImmutableList.<AspectDescriptor>of(), null, null, null, "fedcba", null);
when(action.getOwner()).thenReturn(owner);
clock.advanceMillis(TimeUnit.SECONDS.toMillis(3));
stateTracker.actionStarted(new ActionStartedEvent(action, clock.nanoTime()));
clock.advanceMillis(TimeUnit.SECONDS.toMillis(5));
LoggingTerminalWriter terminalWriter = new LoggingTerminalWriter(/*discardHighlight=*/
true);
stateTracker.writeProgressBar(terminalWriter);
String output = terminalWriter.getTranscript();
assertTrue("Progress bar should contain 'Building ', but was:\n" + output, output.contains("Building "));
assertTrue("Progress bar should contain 'foo.jar (42 source files)', but was:\n" + output, output.contains("foo.jar (42 source files)"));
}
use of com.google.devtools.build.lib.actions.ActionOwner in project bazel by bazelbuild.
the class BlazeExecutor method reportSubcommand.
@Override
public void reportSubcommand(Spawn spawn) {
String reason;
ActionOwner owner = spawn.getResourceOwner().getOwner();
if (owner == null) {
reason = spawn.getResourceOwner().prettyPrint();
} else {
reason = Label.print(owner.getLabel()) + " [" + spawn.getResourceOwner().prettyPrint() + "]";
}
String message = Spawns.asShellCommand(spawn, getExecRoot());
reporter.handle(Event.of(EventKind.SUBCOMMAND, null, "# " + reason + "\n" + message));
}
use of com.google.devtools.build.lib.actions.ActionOwner in project bazel by bazelbuild.
the class AggregatingTestListener method testEvent.
/**
* Records a new test run result and incrementally updates the target status.
* This event is sent upon completion of executed test runs.
*/
@Subscribe
@AllowConcurrentEvents
public void testEvent(TestResult result) {
Preconditions.checkState(statusMap.put(result.getTestStatusArtifact(), result) == null, "Duplicate result reported for an individual test shard");
ActionOwner testOwner = result.getTestAction().getOwner();
LabelAndConfiguration targetLabel = LabelAndConfiguration.of(testOwner.getLabel(), result.getTestAction().getConfiguration());
// executed. Hence report that fact as a cached attempt.
if (result.isCached()) {
eventBus.post(TestAttempt.fromCachedTestResult(result));
}
TestSummary finalTestSummary = null;
synchronized (summaryLock) {
TestSummary.Builder summary = summaries.get(targetLabel);
preconditionHelper.checkNotNull(summary);
if (!remainingRuns.remove(targetLabel, result.getTestStatusArtifact())) {
// This situation is likely to happen if --notest_keep_going is set with multiple targets.
return;
}
summary = analyzer.incrementalAnalyze(summary, result);
// If all runs are processed, the target is finished and ready to report.
if (!remainingRuns.containsKey(targetLabel)) {
finalTestSummary = summary.build();
}
}
// Report finished targets.
if (finalTestSummary != null) {
eventBus.post(finalTestSummary);
}
}
Aggregations