use of com.google.devtools.build.lib.actions.extra.EnvironmentVariable in project bazel by bazelbuild.
the class SpawnActionTest method testExtraActionInfoEnvironmentVariables.
/**
* Test that environment variables are not escaped or quoted.
*/
@Test
public void testExtraActionInfoEnvironmentVariables() throws Exception {
Map<String, String> env = ImmutableMap.of("P1", "simple", "P2", "spaces are not escaped", "P3", ":", "P4", "", "NONSENSE VARIABLE", "value");
SpawnInfo spawnInfo = createCopyFromWelcomeToDestination(env).getExtraActionInfo().build().getExtension(SpawnInfo.spawnInfo);
assertThat(env).hasSize(spawnInfo.getVariableCount());
for (EnvironmentVariable variable : spawnInfo.getVariableList()) {
assertThat(env).containsEntry(variable.getName(), variable.getValue());
}
}
use of com.google.devtools.build.lib.actions.extra.EnvironmentVariable in project bazel by bazelbuild.
the class SpawnActionTest method testExtraActionInfo.
@Test
public void testExtraActionInfo() throws Exception {
SpawnAction action = createCopyFromWelcomeToDestination(ImmutableMap.<String, String>of());
ExtraActionInfo info = action.getExtraActionInfo().build();
assertEquals("Dummy", info.getMnemonic());
SpawnInfo spawnInfo = info.getExtension(SpawnInfo.spawnInfo);
assertNotNull(spawnInfo);
assertThat(spawnInfo.getArgumentList()).containsExactlyElementsIn(action.getArguments());
Iterable<String> inputPaths = Artifact.toExecPaths(action.getInputs());
Iterable<String> outputPaths = Artifact.toExecPaths(action.getOutputs());
assertThat(spawnInfo.getInputFileList()).containsExactlyElementsIn(inputPaths);
assertThat(spawnInfo.getOutputFileList()).containsExactlyElementsIn(outputPaths);
Map<String, String> environment = action.getEnvironment();
assertEquals(environment.size(), spawnInfo.getVariableCount());
for (EnvironmentVariable variable : spawnInfo.getVariableList()) {
assertThat(environment).containsEntry(variable.getName(), variable.getValue());
}
}
Aggregations