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());
}
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);
}
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());
}
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();
}
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();
}
Aggregations