Search in sources :

Example 6 with EventBus

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);
    }
}
Also used : ActionExecutionMetadata(com.google.devtools.build.lib.actions.ActionExecutionMetadata) Executor(com.google.devtools.build.lib.actions.Executor) ResourceHandle(com.google.devtools.build.lib.actions.ResourceManager.ResourceHandle) StandaloneSpawnStrategy(com.google.devtools.build.lib.standalone.StandaloneSpawnStrategy) EventBus(com.google.common.eventbus.EventBus)

Example 7 with EventBus

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();
}
Also used : EventCollector(com.google.devtools.build.lib.events.EventCollector) Reporter(com.google.devtools.build.lib.events.Reporter) EventBus(com.google.common.eventbus.EventBus)

Example 8 with EventBus

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());
}
Also used : Action(com.google.devtools.build.lib.actions.Action) TestAction(com.google.devtools.build.lib.actions.util.TestAction) EventBus(com.google.common.eventbus.EventBus) Artifact(com.google.devtools.build.lib.actions.Artifact) TestAction(com.google.devtools.build.lib.actions.util.TestAction) Test(org.junit.Test)

Example 9 with EventBus

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());
}
Also used : SkyKey(com.google.devtools.build.skyframe.SkyKey) SkyValue(com.google.devtools.build.skyframe.SkyValue) Reporter(com.google.devtools.build.lib.events.Reporter) EventBus(com.google.common.eventbus.EventBus)

Example 10 with EventBus

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();
}
Also used : EventBus(com.google.common.eventbus.EventBus) AnalysisResult(com.google.devtools.build.lib.analysis.BuildView.AnalysisResult) Test(org.junit.Test)

Aggregations

EventBus (com.google.common.eventbus.EventBus)84 Test (org.junit.Test)56 BuckEventBus (com.facebook.buck.event.BuckEventBus)21 FakeClock (com.facebook.buck.timing.FakeClock)19 EasyMock.anyObject (org.easymock.EasyMock.anyObject)18 Reporter (com.google.devtools.build.lib.events.Reporter)15 WatchEvent (java.nio.file.WatchEvent)12 Subscribe (com.google.common.eventbus.Subscribe)11 AnalysisResult (com.google.devtools.build.lib.analysis.BuildView.AnalysisResult)8 Before (org.junit.Before)8 Path (com.google.devtools.build.lib.vfs.Path)7 FakeWatchmanClient (com.facebook.buck.io.FakeWatchmanClient)6 ActionExecutionMetadata (com.google.devtools.build.lib.actions.ActionExecutionMetadata)4 ResourceHandle (com.google.devtools.build.lib.actions.ResourceManager.ResourceHandle)4 BuildLangTypedAttributeValuesMap (com.google.devtools.build.lib.packages.RuleFactory.BuildLangTypedAttributeValuesMap)4 HashMap (java.util.HashMap)4 Executor (com.google.devtools.build.lib.actions.Executor)3 Event (com.google.devtools.build.lib.events.Event)3 SuiteHint (com.carrotsearch.ant.tasks.junit4.balancers.SuiteHint)2 AggregatedQuitEvent (com.carrotsearch.ant.tasks.junit4.events.aggregated.AggregatedQuitEvent)2