Search in sources :

Example 86 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 87 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 88 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 89 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 90 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)163 Test (org.junit.Test)73 Before (org.junit.Before)24 BuckEventBus (com.facebook.buck.event.BuckEventBus)21 HashMap (java.util.HashMap)20 FakeClock (com.facebook.buck.timing.FakeClock)19 Subscribe (com.google.common.eventbus.Subscribe)19 ArrayList (java.util.ArrayList)19 EasyMock.anyObject (org.easymock.EasyMock.anyObject)18 Reporter (com.google.devtools.build.lib.events.Reporter)15 List (java.util.List)14 WatchEvent (java.nio.file.WatchEvent)12 Test (org.junit.jupiter.api.Test)11 RefreshEndpointEvent (org.apache.servicecomb.http.client.event.RefreshEndpointEvent)10 AnalysisResult (com.google.devtools.build.lib.analysis.BuildView.AnalysisResult)8 Expectations (mockit.Expectations)8 Microservice (org.apache.servicecomb.registry.api.registry.Microservice)8 MicroserviceInstance (org.apache.servicecomb.registry.api.registry.MicroserviceInstance)8 Test (org.testng.annotations.Test)8 Path (com.google.devtools.build.lib.vfs.Path)7