Search in sources :

Example 66 with EventBus

use of com.google.common.eventbus.EventBus in project bazel by bazelbuild.

the class TestResultAnalyzerTest method createMocks.

@Before
public final void createMocks() throws Exception {
    Path mockPath = mock(Path.class);
    OptionsParser testSpecificOptions = OptionsParser.newOptionsParser(TestSummaryOptions.class, ExecutionOptions.class);
    EventBus mockBus = mock(EventBus.class);
    underTest = new TestResultAnalyzer(mockPath, testSpecificOptions.getOptions(TestSummaryOptions.class), testSpecificOptions.getOptions(ExecutionOptions.class), mockBus);
}
Also used : Path(com.google.devtools.build.lib.vfs.Path) EventBus(com.google.common.eventbus.EventBus) OptionsParser(com.google.devtools.common.options.OptionsParser) Before(org.junit.Before)

Example 67 with EventBus

use of com.google.common.eventbus.EventBus in project bazel by bazelbuild.

the class ParallelEvaluatorTest method signalValueEnqueuedAndEvaluated.

@Test
public void signalValueEnqueuedAndEvaluated() throws Exception {
    final Set<SkyKey> enqueuedValues = Sets.newConcurrentHashSet();
    final Set<SkyKey> evaluatedValues = Sets.newConcurrentHashSet();
    EvaluationProgressReceiver progressReceiver = new EvaluationProgressReceiver() {

        @Override
        public void invalidated(SkyKey skyKey, InvalidationState state) {
            throw new IllegalStateException();
        }

        @Override
        public void enqueueing(SkyKey skyKey) {
            enqueuedValues.add(skyKey);
        }

        @Override
        public void computed(SkyKey skyKey, long elapsedTimeNanos) {
        }

        @Override
        public void evaluated(SkyKey skyKey, Supplier<SkyValue> skyValueSupplier, EvaluationState state) {
            evaluatedValues.add(skyKey);
        }
    };
    ExtendedEventHandler reporter = new Reporter(new EventBus(), new EventHandler() {

        @Override
        public void handle(Event e) {
            throw new IllegalStateException();
        }
    });
    MemoizingEvaluator aug = new InMemoryMemoizingEvaluator(ImmutableMap.of(GraphTester.NODE_TYPE, tester.getFunction()), new RecordingDifferencer(), progressReceiver);
    SequentialBuildDriver driver = new SequentialBuildDriver(aug);
    tester.getOrCreate("top1").setComputedValue(CONCATENATE).addDependency("d1").addDependency("d2");
    tester.getOrCreate("top2").setComputedValue(CONCATENATE).addDependency("d3");
    tester.getOrCreate("top3");
    assertThat(enqueuedValues).isEmpty();
    assertThat(evaluatedValues).isEmpty();
    tester.set("d1", new StringValue("1"));
    tester.set("d2", new StringValue("2"));
    tester.set("d3", new StringValue("3"));
    driver.evaluate(ImmutableList.of(GraphTester.toSkyKey("top1")), false, 200, reporter);
    assertThat(enqueuedValues).containsExactlyElementsIn(Arrays.asList(GraphTester.toSkyKeys("top1", "d1", "d2")));
    assertThat(evaluatedValues).containsExactlyElementsIn(Arrays.asList(GraphTester.toSkyKeys("top1", "d1", "d2")));
    enqueuedValues.clear();
    evaluatedValues.clear();
    driver.evaluate(ImmutableList.of(GraphTester.toSkyKey("top2")), false, 200, reporter);
    assertThat(enqueuedValues).containsExactlyElementsIn(Arrays.asList(GraphTester.toSkyKeys("top2", "d3")));
    assertThat(evaluatedValues).containsExactlyElementsIn(Arrays.asList(GraphTester.toSkyKeys("top2", "d3")));
    enqueuedValues.clear();
    evaluatedValues.clear();
    driver.evaluate(ImmutableList.of(GraphTester.toSkyKey("top1")), false, 200, reporter);
    assertThat(enqueuedValues).isEmpty();
    assertThat(evaluatedValues).containsExactlyElementsIn(Arrays.asList(GraphTester.toSkyKeys("top1")));
}
Also used : Reporter(com.google.devtools.build.lib.events.Reporter) ExtendedEventHandler(com.google.devtools.build.lib.events.ExtendedEventHandler) EventHandler(com.google.devtools.build.lib.events.EventHandler) EventBus(com.google.common.eventbus.EventBus) ExtendedEventHandler(com.google.devtools.build.lib.events.ExtendedEventHandler) MoreAsserts.assertContainsEvent(com.google.devtools.build.lib.testutil.MoreAsserts.assertContainsEvent) Event(com.google.devtools.build.lib.events.Event) Supplier(com.google.common.base.Supplier) StringValue(com.google.devtools.build.skyframe.GraphTester.StringValue) Test(org.junit.Test)

Example 68 with EventBus

use of com.google.common.eventbus.EventBus in project bazel by bazelbuild.

the class ParallelEvaluatorTest method makeEvaluator.

private ParallelEvaluator makeEvaluator(ProcessableGraph graph, ImmutableMap<SkyFunctionName, ? extends SkyFunction> builders, boolean keepGoing, EventFilter storedEventFilter) {
    Version oldGraphVersion = graphVersion;
    graphVersion = graphVersion.next();
    return new ParallelEvaluator(graph, oldGraphVersion, builders, new Reporter(new EventBus(), eventCollector), new MemoizingEvaluator.EmittedEventState(), storedEventFilter, keepGoing, 150, revalidationReceiver);
}
Also used : Reporter(com.google.devtools.build.lib.events.Reporter) EventBus(com.google.common.eventbus.EventBus)

Example 69 with EventBus

use of com.google.common.eventbus.EventBus in project bazel by bazelbuild.

the class EagerInvalidatorTest method eval.

protected <T extends SkyValue> EvaluationResult<T> eval(boolean keepGoing, SkyKey... keys) throws InterruptedException {
    Reporter reporter = new Reporter(new EventBus());
    ParallelEvaluator evaluator = new ParallelEvaluator(graph, graphVersion, tester.getSkyFunctionMap(), reporter, new MemoizingEvaluator.EmittedEventState(), InMemoryMemoizingEvaluator.DEFAULT_STORED_EVENT_FILTER, keepGoing, 200, new DirtyTrackingProgressReceiver(null));
    graphVersion = graphVersion.next();
    return evaluator.eval(ImmutableList.copyOf(keys));
}
Also used : Reporter(com.google.devtools.build.lib.events.Reporter) EventBus(com.google.common.eventbus.EventBus)

Example 70 with EventBus

use of com.google.common.eventbus.EventBus in project bazel by bazelbuild.

the class AndroidStudioInfoAspectTestBase method buildTarget.

private void buildTarget(String target) throws Exception {
    AnalysisResult analysisResult = update(ImmutableList.of(target), ImmutableList.of(AndroidStudioInfoAspect.NAME), false, LOADING_PHASE_THREADS, true, new EventBus());
    Collection<AspectValue> aspects = analysisResult.getAspects();
    assertThat(aspects.size()).isEqualTo(1);
    AspectValue value = aspects.iterator().next();
    this.configuredAspect = value.getConfiguredAspect();
    assertThat(configuredAspect.getName()).isEqualTo(AndroidStudioInfoAspect.NAME);
}
Also used : AspectValue(com.google.devtools.build.lib.skyframe.AspectValue) EventBus(com.google.common.eventbus.EventBus) AnalysisResult(com.google.devtools.build.lib.analysis.BuildView.AnalysisResult)

Aggregations

EventBus (com.google.common.eventbus.EventBus)85 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