Search in sources :

Example 11 with RunfilesSupplierImpl

use of com.google.devtools.build.lib.analysis.RunfilesSupplierImpl in project bazel by bazelbuild.

the class LTOBackendActionTest method testComputeKey.

@Test
public void testComputeKey() throws Exception {
    final Artifact artifactA = getSourceArtifact("a");
    final Artifact artifactB = getSourceArtifact("b");
    final Artifact artifactAimports = getSourceArtifact("a.imports");
    final Artifact artifactBimports = getSourceArtifact("b.imports");
    ActionTester.runTest(64, new ActionCombinationFactory() {

        @Override
        public Action generate(int i) {
            LTOBackendAction.Builder builder = new LTOBackendAction.Builder();
            builder.addOutput(destinationArtifact);
            PathFragment executable = (i & 1) == 0 ? artifactA.getExecPath() : artifactB.getExecPath();
            builder.setExecutable(executable);
            if ((i & 2) == 0) {
                builder.addImportsInfo(new HashMap<PathFragment, Artifact>(), artifactAimports);
            } else {
                builder.addImportsInfo(new HashMap<PathFragment, Artifact>(), artifactBimports);
            }
            builder.setMnemonic((i & 4) == 0 ? "a" : "b");
            if ((i & 8) == 0) {
                builder.addRunfilesSupplier(new RunfilesSupplierImpl(new PathFragment("a"), Runfiles.EMPTY, artifactA));
            } else {
                builder.addRunfilesSupplier(new RunfilesSupplierImpl(new PathFragment("a"), Runfiles.EMPTY, artifactB));
            }
            if ((i & 16) == 0) {
                builder.addInput(artifactA);
            } else {
                builder.addInput(artifactB);
            }
            Map<String, String> env = new HashMap<>();
            if ((i & 32) == 0) {
                env.put("foo", "bar");
            }
            builder.setEnvironment(env);
            Action[] actions = builder.build(ActionsTestUtil.NULL_ACTION_OWNER, collectingAnalysisEnvironment, targetConfig);
            collectingAnalysisEnvironment.registerAction(actions);
            return actions[0];
        }
    });
}
Also used : AbstractAction(com.google.devtools.build.lib.actions.AbstractAction) Action(com.google.devtools.build.lib.actions.Action) HashMap(java.util.HashMap) TestExecutorBuilder(com.google.devtools.build.lib.exec.util.TestExecutorBuilder) PathFragment(com.google.devtools.build.lib.vfs.PathFragment) RunfilesSupplierImpl(com.google.devtools.build.lib.analysis.RunfilesSupplierImpl) Artifact(com.google.devtools.build.lib.actions.Artifact) ActionCombinationFactory(com.google.devtools.build.lib.analysis.util.ActionTester.ActionCombinationFactory) ImmutableMap(com.google.common.collect.ImmutableMap) HashMap(java.util.HashMap) Map(java.util.Map) Test(org.junit.Test)

Example 12 with RunfilesSupplierImpl

use of com.google.devtools.build.lib.analysis.RunfilesSupplierImpl in project bazel by bazelbuild.

the class SpawnActionTest method testInputManifestsRemovedIfSupplied.

@Test
public void testInputManifestsRemovedIfSupplied() throws Exception {
    Artifact manifest = getSourceArtifact("MANIFEST");
    Action[] actions = builder().addInput(manifest).addRunfilesSupplier(new RunfilesSupplierImpl(new PathFragment("/destination/"), Runfiles.EMPTY, manifest)).addOutput(getBinArtifactWithNoOwner("output")).setExecutable(scratch.file("/bin/xxx").asFragment()).setProgressMessage("Test").build(ActionsTestUtil.NULL_ACTION_OWNER, collectingAnalysisEnvironment, targetConfig);
    collectingAnalysisEnvironment.registerAction(actions);
    SpawnAction action = (SpawnAction) actions[0];
    List<String> inputFiles = actionInputsToPaths(action.getSpawn().getInputFiles());
    assertThat(inputFiles).isEmpty();
}
Also used : AbstractAction(com.google.devtools.build.lib.actions.AbstractAction) Action(com.google.devtools.build.lib.actions.Action) PathFragment(com.google.devtools.build.lib.vfs.PathFragment) RunfilesSupplierImpl(com.google.devtools.build.lib.analysis.RunfilesSupplierImpl) Artifact(com.google.devtools.build.lib.actions.Artifact) Test(org.junit.Test)

Aggregations

RunfilesSupplierImpl (com.google.devtools.build.lib.analysis.RunfilesSupplierImpl)12 PathFragment (com.google.devtools.build.lib.vfs.PathFragment)11 Test (org.junit.Test)10 Artifact (com.google.devtools.build.lib.actions.Artifact)9 Runfiles (com.google.devtools.build.lib.analysis.Runfiles)7 ActionInputFileCache (com.google.devtools.build.lib.actions.ActionInputFileCache)6 EmptyRunfilesSupplier (com.google.devtools.build.lib.actions.EmptyRunfilesSupplier)6 RunfilesSupplier (com.google.devtools.build.lib.actions.RunfilesSupplier)6 AbstractAction (com.google.devtools.build.lib.actions.AbstractAction)2 Action (com.google.devtools.build.lib.actions.Action)2 IOException (java.io.IOException)2 HashMap (java.util.HashMap)2 ImmutableList (com.google.common.collect.ImmutableList)1 ImmutableMap (com.google.common.collect.ImmutableMap)1 EnvironmentalExecException (com.google.devtools.build.lib.actions.EnvironmentalExecException)1 Executor (com.google.devtools.build.lib.actions.Executor)1 SimpleSpawn (com.google.devtools.build.lib.actions.SimpleSpawn)1 Spawn (com.google.devtools.build.lib.actions.Spawn)1 SpawnAction (com.google.devtools.build.lib.analysis.actions.SpawnAction)1 ActionCombinationFactory (com.google.devtools.build.lib.analysis.util.ActionTester.ActionCombinationFactory)1