Search in sources :

Example 1 with Reporter

use of com.google.devtools.build.lib.events.Reporter in project bazel by bazelbuild.

the class FoundationTestCase method initializeLogging.

@Before
public final void initializeLogging() throws Exception {
    eventCollector = new EventCollector(EventKind.ERRORS_AND_WARNINGS);
    reporter = new Reporter(new EventBus(), eventCollector);
    reporter.addHandler(failFastHandler);
}
Also used : EventCollector(com.google.devtools.build.lib.events.EventCollector) Reporter(com.google.devtools.build.lib.events.Reporter) EventBus(com.google.common.eventbus.EventBus) Before(org.junit.Before)

Example 2 with Reporter

use of com.google.devtools.build.lib.events.Reporter 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 3 with Reporter

use of com.google.devtools.build.lib.events.Reporter 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 4 with Reporter

use of com.google.devtools.build.lib.events.Reporter in project bazel by bazelbuild.

the class BlazeExecutorTest method testDebugPrintActionContexts.

@Test
public void testDebugPrintActionContexts() throws Exception {
    TestExecutorBuilder builder = new TestExecutorBuilder(directories, binTools);
    OptionsParser parser = OptionsParser.newOptionsParser(TestExecutorBuilder.DEFAULT_OPTIONS);
    parser.parse("--debug_print_action_contexts");
    Reporter reporter = new Reporter(new EventBus());
    StoredEventHandler storedEventHandler = new StoredEventHandler();
    reporter.addHandler(storedEventHandler);
    SpawnActionContext mockStrategy = Mockito.mock(SpawnActionContext.class);
    builder.setReporter(reporter).setOptionsParser(parser).setExecution("mock", mockStrategy);
    builder.build();
    Event event = Iterables.find(storedEventHandler.getEvents(), new Predicate<Event>() {

        @Override
        public boolean apply(@Nullable Event event) {
            return event.getMessage().contains("SpawnActionContextMap: \"mock\" = ");
        }
    });
    assertThat(event).isNotNull();
    assertThat(event.getMessage()).contains("\"mock\" = " + mockStrategy.getClass().getSimpleName());
}
Also used : TestExecutorBuilder(com.google.devtools.build.lib.exec.util.TestExecutorBuilder) StoredEventHandler(com.google.devtools.build.lib.events.StoredEventHandler) Reporter(com.google.devtools.build.lib.events.Reporter) Event(com.google.devtools.build.lib.events.Event) EventBus(com.google.common.eventbus.EventBus) OptionsParser(com.google.devtools.common.options.OptionsParser) SpawnActionContext(com.google.devtools.build.lib.actions.SpawnActionContext) Test(org.junit.Test)

Example 5 with Reporter

use of com.google.devtools.build.lib.events.Reporter in project bazel by bazelbuild.

the class RuleFactoryTest method testWorkspaceRuleFailsInBuildFile.

@Test
public void testWorkspaceRuleFailsInBuildFile() throws Exception {
    Path myPkgPath = scratch.resolve("/foo/workspace/mypkg/BUILD");
    Package.Builder pkgBuilder = packageFactory.newPackageBuilder(PackageIdentifier.createInMainRepo("mypkg"), "TESTING").setFilename(myPkgPath).setMakeEnv(new MakeEnvironment.Builder());
    Map<String, Object> attributeValues = new HashMap<>();
    attributeValues.put("name", "foo");
    attributeValues.put("actual", "//bar:baz");
    RuleClass ruleClass = provider.getRuleClassMap().get("bind");
    try {
        RuleFactory.createAndAddRule(pkgBuilder, ruleClass, new BuildLangTypedAttributeValuesMap(attributeValues), new Reporter(new EventBus()), /*ast=*/
        null, LOCATION_42, /*env=*/
        null, new AttributeContainer(ruleClass));
        fail();
    } catch (RuleFactory.InvalidRuleException e) {
        assertThat(e.getMessage()).contains("must be in the WORKSPACE file");
    }
}
Also used : Path(com.google.devtools.build.lib.vfs.Path) HashMap(java.util.HashMap) Reporter(com.google.devtools.build.lib.events.Reporter) EventBus(com.google.common.eventbus.EventBus) BuildLangTypedAttributeValuesMap(com.google.devtools.build.lib.packages.RuleFactory.BuildLangTypedAttributeValuesMap) Test(org.junit.Test)

Aggregations

Reporter (com.google.devtools.build.lib.events.Reporter)17 EventBus (com.google.common.eventbus.EventBus)15 Test (org.junit.Test)8 Path (com.google.devtools.build.lib.vfs.Path)7 HashMap (java.util.HashMap)6 BuildLangTypedAttributeValuesMap (com.google.devtools.build.lib.packages.RuleFactory.BuildLangTypedAttributeValuesMap)5 Event (com.google.devtools.build.lib.events.Event)3 EventHandler (com.google.devtools.build.lib.events.EventHandler)3 SkyKey (com.google.devtools.build.skyframe.SkyKey)3 SkyValue (com.google.devtools.build.skyframe.SkyValue)3 EventCollector (com.google.devtools.build.lib.events.EventCollector)2 StoredEventHandler (com.google.devtools.build.lib.events.StoredEventHandler)2 ArrayList (java.util.ArrayList)2 Supplier (com.google.common.base.Supplier)1 ImmutableMap (com.google.common.collect.ImmutableMap)1 ImmutableSet (com.google.common.collect.ImmutableSet)1 Range (com.google.common.collect.Range)1 ActionCacheChecker (com.google.devtools.build.lib.actions.ActionCacheChecker)1 ActionExecutionStatusReporter (com.google.devtools.build.lib.actions.ActionExecutionStatusReporter)1 ActionInputFileCache (com.google.devtools.build.lib.actions.ActionInputFileCache)1