use of com.google.common.eventbus.EventBus in project bazel by bazelbuild.
the class WorkerSpawnStrategy method exec.
@Override
public void exec(Spawn spawn, ActionExecutionContext actionExecutionContext, AtomicReference<Class<? extends SpawnActionContext>> writeOutputFiles) throws ExecException, InterruptedException {
Executor executor = actionExecutionContext.getExecutor();
if (!spawn.getExecutionInfo().containsKey("supports-workers") || !spawn.getExecutionInfo().get("supports-workers").equals("1")) {
StandaloneSpawnStrategy standaloneStrategy = Preconditions.checkNotNull(executor.getContext(StandaloneSpawnStrategy.class));
executor.getEventHandler().handle(Event.warn(String.format(ERROR_MESSAGE_PREFIX + REASON_NO_EXECUTION_INFO, spawn.getMnemonic())));
standaloneStrategy.exec(spawn, actionExecutionContext);
return;
}
EventBus eventBus = actionExecutionContext.getExecutor().getEventBus();
ActionExecutionMetadata owner = spawn.getResourceOwner();
eventBus.post(ActionStatusMessage.schedulingStrategy(owner));
try (ResourceHandle handle = ResourceManager.instance().acquireResources(owner, spawn.getLocalResources())) {
eventBus.post(ActionStatusMessage.runningStrategy(spawn.getResourceOwner(), "worker"));
actuallyExec(spawn, actionExecutionContext, writeOutputFiles);
}
}
use of com.google.common.eventbus.EventBus in project bazel by bazelbuild.
the class MemoizingEvaluatorTest method initializeReporter.
private void initializeReporter() {
eventCollector = new EventCollector();
reporter = new Reporter(new EventBus(), eventCollector);
tester.resetPlayedEvents();
}
use of com.google.common.eventbus.EventBus in project bazel by bazelbuild.
the class ParallelBuilderTest method testReportsActionExecutedEvent.
@Test
public void testReportsActionExecutedEvent() throws Exception {
Artifact pear = createDerivedArtifact("pear");
ActionEventRecorder recorder = new ActionEventRecorder();
EventBus eventBus = new EventBus();
eventBusRef.set(eventBus);
eventBus.register(recorder);
Action action = registerAction(new TestAction(Runnables.doNothing(), emptySet, asSet(pear)));
buildArtifacts(createBuilder(DEFAULT_NUM_JOBS, true), pear);
assertThat(recorder.actionExecutedEvents).hasSize(1);
assertEquals(action, recorder.actionExecutedEvents.get(0).getAction());
}
use of com.google.common.eventbus.EventBus in project bazel by bazelbuild.
the class PrepareDepsOfPatternsFunctionSmartNegationTest method getGraphFromPatternsEvaluation.
// Helpers:
private WalkableGraph getGraphFromPatternsEvaluation(ImmutableList<String> patternSequence, boolean successExpected, boolean keepGoing) throws InterruptedException {
SkyKey independentTarget = PrepareDepsOfPatternsValue.key(patternSequence, "");
ImmutableList<SkyKey> singletonTargetPattern = ImmutableList.of(independentTarget);
// When PrepareDepsOfPatternsFunction completes evaluation,
EvaluationResult<SkyValue> evaluationResult = getSkyframeExecutor().getDriverForTesting().evaluate(singletonTargetPattern, keepGoing, LOADING_PHASE_THREADS, new Reporter(new EventBus(), eventCollector));
// The evaluation has no errors if success was expected.
assertThat(evaluationResult.hasError()).isNotEqualTo(successExpected);
return Preconditions.checkNotNull(evaluationResult.getWalkableGraph());
}
use of com.google.common.eventbus.EventBus in project bazel by bazelbuild.
the class BuildViewTest method testCircularDependencyWithLateBoundLabel.
@Test
public void testCircularDependencyWithLateBoundLabel() throws Exception {
scratch.file("cycle/BUILD", "cc_library(name = 'foo', deps = [':bar'])", "cc_library(name = 'bar')");
useConfiguration("--experimental_stl=//cycle:foo");
reporter.removeHandler(failFastHandler);
EventBus eventBus = new EventBus();
LoadingFailureRecorder loadingFailureRecorder = new LoadingFailureRecorder();
AnalysisFailureRecorder analysisFailureRecorder = new AnalysisFailureRecorder();
eventBus.register(loadingFailureRecorder);
eventBus.register(analysisFailureRecorder);
AnalysisResult result = update(eventBus, defaultFlags().with(Flag.KEEP_GOING), "//cycle:foo");
assertThat(result.hasError()).isTrue();
assertContainsEvent("in cc_library rule //cycle:foo: cycle in dependency graph:");
// This needs to be reported as an anlysis-phase cycle; the cycle only occurs due to the stl
// command-line option, which is part of the configuration, and which is used due to the
// late-bound label.
assertThat(Iterables.transform(analysisFailureRecorder.events, ANALYSIS_EVENT_TO_STRING_PAIR)).containsExactly(Pair.of("//cycle:foo", "//cycle:foo"));
assertThat(loadingFailureRecorder.events).isEmpty();
}
Aggregations