Search in sources :

Example 1 with TestExecutorBuilder

use of com.google.devtools.build.lib.exec.util.TestExecutorBuilder in project bazel by bazelbuild.

the class SymlinkActionTest method testSymlink.

@Test
public void testSymlink() throws Exception {
    Executor executor = new TestExecutorBuilder(directories, null).build();
    action.execute(new ActionExecutionContext(executor, null, null, null, ImmutableMap.<String, String>of(), null));
    assertTrue(output.isSymbolicLink());
    assertEquals(input, output.resolveSymbolicLinks());
    assertEquals(inputArtifact, action.getPrimaryInput());
    assertEquals(outputArtifact, action.getPrimaryOutput());
}
Also used : TestExecutorBuilder(com.google.devtools.build.lib.exec.util.TestExecutorBuilder) Executor(com.google.devtools.build.lib.actions.Executor) ActionExecutionContext(com.google.devtools.build.lib.actions.ActionExecutionContext) Test(org.junit.Test)

Example 2 with TestExecutorBuilder

use of com.google.devtools.build.lib.exec.util.TestExecutorBuilder in project bazel by bazelbuild.

the class ParamFileWriteActionTest method actionExecutionContext.

private ActionExecutionContext actionExecutionContext() throws Exception {
    final Iterable<TreeFileArtifact> treeFileArtifacts = ImmutableList.of(createTreeFileArtifact(treeArtifact, "artifacts/treeFileArtifact1"), createTreeFileArtifact(treeArtifact, "artifacts/treeFileArtifact2"));
    ArtifactExpander artifactExpander = new ArtifactExpander() {

        @Override
        public void expand(Artifact artifact, Collection<? super Artifact> output) {
            for (TreeFileArtifact treeFileArtifact : treeFileArtifacts) {
                if (treeFileArtifact.getParent().equals(artifact)) {
                    output.add(treeFileArtifact);
                }
            }
        }
    };
    Executor executor = new TestExecutorBuilder(directories, binTools).build();
    return new ActionExecutionContext(executor, null, null, new FileOutErr(), ImmutableMap.<String, String>of(), artifactExpander);
}
Also used : TreeFileArtifact(com.google.devtools.build.lib.actions.Artifact.TreeFileArtifact) TestExecutorBuilder(com.google.devtools.build.lib.exec.util.TestExecutorBuilder) ArtifactExpander(com.google.devtools.build.lib.actions.Artifact.ArtifactExpander) Executor(com.google.devtools.build.lib.actions.Executor) FileOutErr(com.google.devtools.build.lib.util.io.FileOutErr) ActionExecutionContext(com.google.devtools.build.lib.actions.ActionExecutionContext) Collection(java.util.Collection) SpecialArtifact(com.google.devtools.build.lib.actions.Artifact.SpecialArtifact) Artifact(com.google.devtools.build.lib.actions.Artifact) TreeFileArtifact(com.google.devtools.build.lib.actions.Artifact.TreeFileArtifact)

Example 3 with TestExecutorBuilder

use of com.google.devtools.build.lib.exec.util.TestExecutorBuilder 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 4 with TestExecutorBuilder

use of com.google.devtools.build.lib.exec.util.TestExecutorBuilder in project bazel by bazelbuild.

the class LTOBackendActionTest method createExecutorAndContext.

@Before
public final void createExecutorAndContext() throws Exception {
    executor = new TestExecutorBuilder(directories, binTools).build();
    context = new ActionExecutionContext(executor, null, null, new FileOutErr(), ImmutableMap.<String, String>of(), null);
}
Also used : TestExecutorBuilder(com.google.devtools.build.lib.exec.util.TestExecutorBuilder) FileOutErr(com.google.devtools.build.lib.util.io.FileOutErr) ActionExecutionContext(com.google.devtools.build.lib.actions.ActionExecutionContext) Before(org.junit.Before)

Example 5 with TestExecutorBuilder

use of com.google.devtools.build.lib.exec.util.TestExecutorBuilder in project bazel by bazelbuild.

the class FileWriteActionTestCase method createExecutorAndContext.

@Before
public final void createExecutorAndContext() throws Exception {
    executor = new TestExecutorBuilder(directories, binTools).build();
    context = new ActionExecutionContext(executor, null, null, new FileOutErr(), ImmutableMap.<String, String>of(), null);
}
Also used : TestExecutorBuilder(com.google.devtools.build.lib.exec.util.TestExecutorBuilder) FileOutErr(com.google.devtools.build.lib.util.io.FileOutErr) ActionExecutionContext(com.google.devtools.build.lib.actions.ActionExecutionContext) Before(org.junit.Before)

Aggregations

TestExecutorBuilder (com.google.devtools.build.lib.exec.util.TestExecutorBuilder)7 ActionExecutionContext (com.google.devtools.build.lib.actions.ActionExecutionContext)4 Executor (com.google.devtools.build.lib.actions.Executor)4 FileOutErr (com.google.devtools.build.lib.util.io.FileOutErr)3 Test (org.junit.Test)3 Before (org.junit.Before)2 EventBus (com.google.common.eventbus.EventBus)1 Artifact (com.google.devtools.build.lib.actions.Artifact)1 ArtifactExpander (com.google.devtools.build.lib.actions.Artifact.ArtifactExpander)1 SpecialArtifact (com.google.devtools.build.lib.actions.Artifact.SpecialArtifact)1 TreeFileArtifact (com.google.devtools.build.lib.actions.Artifact.TreeFileArtifact)1 SpawnActionContext (com.google.devtools.build.lib.actions.SpawnActionContext)1 Event (com.google.devtools.build.lib.events.Event)1 Reporter (com.google.devtools.build.lib.events.Reporter)1 StoredEventHandler (com.google.devtools.build.lib.events.StoredEventHandler)1 OptionsParser (com.google.devtools.common.options.OptionsParser)1 Collection (java.util.Collection)1