use of com.google.devtools.build.lib.analysis.actions.SpawnAction in project bazel by bazelbuild.
the class SkylarkRuleImplementationFunctionsTest method testCreateSpawnActionShellCommandList.
@Test
public void testCreateSpawnActionShellCommandList() throws Exception {
SkylarkRuleContext ruleContext = createRuleContext("//foo:foo");
evalRuleContextCode(ruleContext, "ruleContext.action(", " inputs = ruleContext.files.srcs,", " outputs = ruleContext.files.srcs,", " mnemonic = 'DummyMnemonic',", " command = ['dummy_command', '--arg1', '--arg2'],", " progress_message = 'dummy_message')");
SpawnAction action = (SpawnAction) Iterables.getOnlyElement(ruleContext.getRuleContext().getAnalysisEnvironment().getRegisteredActions());
assertThat(action.getArguments()).containsExactly("dummy_command", "--arg1", "--arg2").inOrder();
}
use of com.google.devtools.build.lib.analysis.actions.SpawnAction in project bazel by bazelbuild.
the class SkylarkRuleImplementationFunctionsTest method testCreateSpawnActionEnvAndExecInfo.
@Test
public void testCreateSpawnActionEnvAndExecInfo() throws Exception {
SkylarkRuleContext ruleContext = createRuleContext("//foo:foo");
evalRuleContextCode(ruleContext, "env = {'a' : 'b'}", "ruleContext.action(", " inputs = ruleContext.files.srcs,", " outputs = ruleContext.files.srcs,", " env = env,", " execution_requirements = env,", " mnemonic = 'DummyMnemonic',", " command = 'dummy_command',", " progress_message = 'dummy_message')");
SpawnAction action = (SpawnAction) Iterables.getOnlyElement(ruleContext.getRuleContext().getAnalysisEnvironment().getRegisteredActions());
assertEquals(ImmutableMap.of("a", "b"), action.getEnvironment());
assertEquals(ImmutableMap.of("a", "b"), action.getExecutionInfo());
}
use of com.google.devtools.build.lib.analysis.actions.SpawnAction in project bazel by bazelbuild.
the class SkylarkRuleImplementationFunctionsTest method testCreateSpawnActionArgumentsWithCommand.
@Test
public void testCreateSpawnActionArgumentsWithCommand() throws Exception {
SkylarkRuleContext ruleContext = createRuleContext("//foo:foo");
createTestSpawnAction(ruleContext);
SpawnAction action = (SpawnAction) Iterables.getOnlyElement(ruleContext.getRuleContext().getAnalysisEnvironment().getRegisteredActions());
assertArtifactFilenames(action.getInputs(), "a.txt", "b.img");
assertArtifactFilenames(action.getOutputs(), "a.txt", "b.img");
MoreAsserts.assertContainsSublist(action.getArguments(), "-c", "dummy_command", "", "--a", "--b");
assertEquals("DummyMnemonic", action.getMnemonic());
assertEquals("dummy_message", action.getProgressMessage());
assertEquals(targetConfig.getLocalShellEnvironment(), action.getEnvironment());
}
use of com.google.devtools.build.lib.analysis.actions.SpawnAction in project bazel by bazelbuild.
the class AarImport method singleJarSpawnActionBuilder.
// Adds the appropriate SpawnAction options depending on if SingleJar is a jar or not.
private static SpawnAction.Builder singleJarSpawnActionBuilder(RuleContext ruleContext) {
SpawnAction.Builder builder = new SpawnAction.Builder();
Artifact singleJar = JavaToolchainProvider.fromRuleContext(ruleContext).getSingleJar();
if (singleJar.getFilename().endsWith(".jar")) {
builder.setJarExecutable(ruleContext.getHostConfiguration().getFragment(Jvm.class).getJavaExecutable(), singleJar, JavaToolchainProvider.fromRuleContext(ruleContext).getJvmOptions()).addTransitiveInputs(JavaHelper.getHostJavabaseInputs(ruleContext));
} else {
builder.setExecutable(singleJar);
}
return builder;
}
use of com.google.devtools.build.lib.analysis.actions.SpawnAction in project bazel by bazelbuild.
the class AarImportTest method testNativeLibsZipMakesItIntoApk.
@Test
public void testNativeLibsZipMakesItIntoApk() throws Exception {
scratch.file("java/com/google/android/hello/BUILD", "aar_import(", " name = 'my_aar',", " aar = 'my_aar.aar',", ")", "android_binary(", " name = 'my_app',", " srcs = ['HelloApp.java'],", " deps = [':my_aar'],", " manifest = 'AndroidManifest.xml',", ")");
ConfiguredTarget binary = getConfiguredTarget("//java/com/google/android/hello:my_app");
SpawnAction apkBuilderAction = (SpawnAction) actionsTestUtil().getActionForArtifactEndingWith(getFilesToBuild(binary), "my_app_unsigned.apk");
assertThat(Iterables.find(apkBuilderAction.getArguments(), Predicates.containsPattern("_aar/my_aar/native_libs.zip$"))).isNotEmpty();
}
Aggregations