Search in sources :

Example 41 with EventBus

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

the class SpawnActionTest method testGetExtraActionInfoOnAspects.

/**
   * Tests that the ExtraActionInfo proto that's generated from an action, contains Aspect-related
   * information.
   */
@Test
public void testGetExtraActionInfoOnAspects() throws Exception {
    scratch.file("a/BUILD", "load('//a:def.bzl', 'testrule')", "testrule(name='a', deps=[':b'])", "testrule(name='b')");
    scratch.file("a/def.bzl", "def _aspect_impl(target, ctx):", "  f = ctx.new_file('foo.txt')", "  ctx.action(outputs = [f], command = 'echo foo > \"$1\"')", "  return struct(output=f)", "def _rule_impl(ctx):", "  return struct(files=depset([artifact.output for artifact in ctx.attr.deps]))", "aspect1 = aspect(_aspect_impl, attr_aspects=['deps'], ", "    attrs = {'parameter': attr.string(values = ['param_value'])})", "testrule = rule(_rule_impl, attrs = { ", "    'deps' : attr.label_list(aspects = [aspect1]), ", "    'parameter': attr.string(default='param_value') })");
    update(ImmutableList.of("//a:a"), false, /* keepGoing */
    1, /* loadingPhaseThreads */
    true, /* doAnalysis */
    new EventBus());
    Artifact artifact = getOnlyElement(getFilesToBuild(getConfiguredTarget("//a:a")));
    ExtraActionInfo.Builder extraActionInfo = getGeneratingAction(artifact).getExtraActionInfo();
    assertThat(extraActionInfo.getAspectName()).isEqualTo("//a:def.bzl%aspect1");
    assertThat(extraActionInfo.getAspectParametersMap()).containsExactly("parameter", ExtraActionInfo.StringList.newBuilder().addValue("param_value").build());
}
Also used : EventBus(com.google.common.eventbus.EventBus) Artifact(com.google.devtools.build.lib.actions.Artifact) ExtraActionInfo(com.google.devtools.build.lib.actions.extra.ExtraActionInfo) Test(org.junit.Test)

Example 42 with EventBus

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

the class SimpleReportersTest method addsHandlers.

@Test
public void addsHandlers() {
    EventHandler handler = new EventHandler() {

        @Override
        public void handle(Event event) {
            handlerCount++;
        }
    };
    Reporter reporter = new Reporter(new EventBus(), handler);
    reporter.handle(Event.info(location, "Add to handlerCount."));
    reporter.handle(Event.info(location, "Add to handlerCount."));
    reporter.handle(Event.info(location, "Add to handlerCount."));
    assertEquals(3, handlerCount);
}
Also used : EventBus(com.google.common.eventbus.EventBus) Test(org.junit.Test)

Example 43 with EventBus

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

the class SkylarkJavaLiteProtoLibraryTest method testProtoLibraryInterop.

@Test
public void testProtoLibraryInterop() throws Exception {
    scratch.file("proto/BUILD", "load('//tools/build_rules/java_lite_proto_library:java_lite_proto_library.bzl',", "      'java_lite_proto_library')", "proto_library(", "    name = 'proto',", "    srcs = [ 'file.proto' ],", "    java_api_version = 2,", ")", "java_lite_proto_library(name = 'lite_pb2', deps = [':proto'])");
    update(ImmutableList.of("//proto:lite_pb2"), false, /* keepGoing */
    1, /* loadingPhaseThreads */
    true, /* doAnalysis */
    new EventBus());
}
Also used : EventBus(com.google.common.eventbus.EventBus) Test(org.junit.Test)

Example 44 with EventBus

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

the class ProtoLangToolchainTest method optionalFieldsAreEmpty.

@Test
public void optionalFieldsAreEmpty() throws Exception {
    scratch.file("foo/BUILD", "proto_lang_toolchain(", "    name = 'toolchain',", "    command_line = 'cmd-line',", ")");
    update(ImmutableList.of("//foo:toolchain"), false, 1, true, new EventBus());
    ProtoLangToolchainProvider toolchain = getConfiguredTarget("//foo:toolchain").getProvider(ProtoLangToolchainProvider.class);
    assertThat(toolchain.pluginExecutable()).isNull();
    assertThat(toolchain.runtime()).isNull();
    assertThat(toolchain.blacklistedProtos()).isEmpty();
}
Also used : EventBus(com.google.common.eventbus.EventBus) Test(org.junit.Test)

Example 45 with EventBus

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

the class StandaloneSpawnStrategyTest method setUp.

@Before
public final void setUp() throws Exception {
    Path testRoot = createTestRoot();
    Path workspaceDir = testRoot.getRelative("workspace-name");
    workspaceDir.createDirectory();
    // setup output base & directories
    Path outputBase = testRoot.getRelative("outputBase");
    outputBase.createDirectory();
    BlazeDirectories directories = new BlazeDirectories(outputBase, outputBase, workspaceDir, "mock-product-name");
    // This call implicitly symlinks the integration bin tools into the exec root.
    IntegrationMock.get().getIntegrationBinTools(directories);
    OptionsParser optionsParser = OptionsParser.newOptionsParser(ExecutionOptions.class);
    optionsParser.parse("--verbose_failures");
    EventBus bus = new EventBus();
    ResourceManager resourceManager = ResourceManager.instanceForTestingOnly();
    resourceManager.setAvailableResources(ResourceSet.create(/*memoryMb=*/
    1, /*cpuUsage=*/
    1, /*ioUsage=*/
    1, /*localTestCount=*/
    1));
    this.executor = new BlazeExecutor(directories.getExecRoot(), reporter, bus, BlazeClock.instance(), optionsParser, ImmutableList.<ActionContext>of(), ImmutableMap.<String, SpawnActionContext>of("", new StandaloneSpawnStrategy(directories.getExecRoot(), false, "mock-product-name", resourceManager)), ImmutableList.<ActionContextProvider>of());
    executor.getExecRoot().createDirectory();
}
Also used : Path(com.google.devtools.build.lib.vfs.Path) BlazeDirectories(com.google.devtools.build.lib.analysis.BlazeDirectories) BlazeExecutor(com.google.devtools.build.lib.exec.BlazeExecutor) EventBus(com.google.common.eventbus.EventBus) ResourceManager(com.google.devtools.build.lib.actions.ResourceManager) OptionsParser(com.google.devtools.common.options.OptionsParser) ActionContext(com.google.devtools.build.lib.actions.Executor.ActionContext) SpawnActionContext(com.google.devtools.build.lib.actions.SpawnActionContext) SpawnActionContext(com.google.devtools.build.lib.actions.SpawnActionContext) ActionContextProvider(com.google.devtools.build.lib.exec.ActionContextProvider) Before(org.junit.Before)

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