use of com.google.devtools.build.lib.analysis.actions.SpawnAction in project bazel by bazelbuild.
the class AarImportTest method testClassesJarProvided.
@Test
public void testClassesJarProvided() throws Exception {
ConfiguredTarget aarImportTarget = getConfiguredTarget("//a:foo");
Iterable<OutputJar> outputJars = aarImportTarget.getProvider(JavaRuleOutputJarsProvider.class).getOutputJars();
assertThat(outputJars).hasSize(1);
Artifact classesJar = outputJars.iterator().next().getClassJar();
assertThat(classesJar.getFilename()).isEqualTo("classes_and_libs_merged.jar");
SpawnAction jarMergingAction = ((SpawnAction) getGeneratingAction(classesJar));
assertThat(jarMergingAction.getArguments()).contains("--dont_change_compression");
}
use of com.google.devtools.build.lib.analysis.actions.SpawnAction in project bazel by bazelbuild.
the class GenRuleConfiguredTargetTest method testJavaMakeVarExpansion.
/** Ensure that Java make variables get expanded under the *host* configuration. */
@Test
public void testJavaMakeVarExpansion() throws Exception {
String ruleTemplate = "genrule(name = '%s'," + " srcs = []," + " cmd = 'echo $(%s) > $@'," + " outs = ['%s'])";
scratch.file("foo/BUILD", String.format(ruleTemplate, "java_rule", "JAVA", "java.txt"), String.format(ruleTemplate, "javabase_rule", "JAVABASE", "javabase.txt"));
Artifact javaOutput = getFileConfiguredTarget("//foo:java.txt").getArtifact();
Artifact javabaseOutput = getFileConfiguredTarget("//foo:javabase.txt").getArtifact();
String expectedPattern = "echo %s > %s";
BuildConfiguration hostConfig = getHostConfiguration();
String expectedJava = hostConfig.getFragment(Jvm.class).getJavaExecutable().getPathString();
String expectedJavabase = hostConfig.getFragment(Jvm.class).getJavaHome().getPathString();
assertCommandEquals(String.format(expectedPattern, expectedJava, javaOutput.getExecPathString()), ((SpawnAction) getGeneratingAction(javaOutput)).getArguments().get(2));
assertCommandEquals(String.format(expectedPattern, expectedJavabase, javabaseOutput.getExecPathString()), ((SpawnAction) getGeneratingAction(javabaseOutput)).getArguments().get(2));
}
use of com.google.devtools.build.lib.analysis.actions.SpawnAction in project bazel by bazelbuild.
the class GenRuleConfiguredTargetTest method testActionIsShellCommand.
@Test
public void testActionIsShellCommand() throws Exception {
scratch.file("genrule1/BUILD", "genrule(name = 'hello_world',", "srcs = ['ignore_me.txt'],", "outs = ['message.txt'],", "cmd = 'echo \"Hello, world.\" >$(location message.txt)')");
Artifact messageArtifact = getFileConfiguredTarget("//genrule1:message.txt").getArtifact();
SpawnAction shellAction = (SpawnAction) getGeneratingAction(messageArtifact);
Artifact ignoreMeArtifact = getFileConfiguredTarget("//genrule1:ignore_me.txt").getArtifact();
Artifact genruleSetupArtifact = getFileConfiguredTarget(GENRULE_SETUP).getArtifact();
assertNotNull(shellAction);
assertEquals(Sets.newHashSet(ignoreMeArtifact, genruleSetupArtifact), Sets.newHashSet(shellAction.getInputs()));
assertEquals(Sets.newHashSet(messageArtifact), Sets.newHashSet(shellAction.getOutputs()));
String expected = "echo \"Hello, world.\" >" + messageArtifact.getExecPathString();
assertEquals(targetConfig.getShellExecutable().getPathString(), shellAction.getArguments().get(0));
assertEquals("-c", shellAction.getArguments().get(1));
assertCommandEquals(expected, shellAction.getArguments().get(2));
}
use of com.google.devtools.build.lib.analysis.actions.SpawnAction in project bazel by bazelbuild.
the class GenRuleConfiguredTargetTest method testDependentGenrule.
@Test
public void testDependentGenrule() throws Exception {
scratch.file("genrule1/BUILD", "genrule(name = 'hello_world',", "srcs = ['ignore_me.txt'],", "outs = ['message.txt'],", "cmd = 'echo \"Hello, world.\" >$(location message.txt)')");
scratch.file("genrule2/BUILD", "genrule(name = 'goodbye_world',", "srcs = ['goodbye.txt', '//genrule1:hello_world'],", "outs = ['farewell.txt'],", "cmd = 'echo $(SRCS) >$(location farewell.txt)')");
getConfiguredTarget("//genrule2:goodbye_world");
Artifact farewellArtifact = getFileConfiguredTarget("//genrule2:farewell.txt").getArtifact();
Artifact goodbyeArtifact = getFileConfiguredTarget("//genrule2:goodbye.txt").getArtifact();
Artifact messageArtifact = getFileConfiguredTarget("//genrule1:message.txt").getArtifact();
Artifact genruleSetupArtifact = getFileConfiguredTarget(GENRULE_SETUP).getArtifact();
SpawnAction shellAction = (SpawnAction) getGeneratingAction(farewellArtifact);
// inputs = { "goodbye.txt", "//genrule1:message.txt" }
assertEquals(Sets.newHashSet(goodbyeArtifact, messageArtifact, genruleSetupArtifact), Sets.newHashSet(shellAction.getInputs()));
// outputs = { "farewell.txt" }
assertEquals(Sets.newHashSet(farewellArtifact), Sets.newHashSet(shellAction.getOutputs()));
String expected = "echo " + goodbyeArtifact.getExecPathString() + " " + messageArtifact.getExecPathString() + " >" + farewellArtifact.getExecPathString();
assertCommandEquals(expected, shellAction.getArguments().get(2));
}
use of com.google.devtools.build.lib.analysis.actions.SpawnAction in project bazel by bazelbuild.
the class AndroidStudioInfoAspectTestBase method verifyPackageManifestSpawnAction.
protected final void verifyPackageManifestSpawnAction(Action genAction) {
assertEquals(genAction.getMnemonic(), "JavaPackageManifest");
SpawnAction action = (SpawnAction) genAction;
assertFalse(action.isShellCommand());
}
Aggregations