Search in sources :

Example 1 with EnvironmentVariable

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());
    }
}
Also used : SpawnInfo(com.google.devtools.build.lib.actions.extra.SpawnInfo) EnvironmentVariable(com.google.devtools.build.lib.actions.extra.EnvironmentVariable) Test(org.junit.Test)

Example 2 with EnvironmentVariable

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());
    }
}
Also used : SpawnInfo(com.google.devtools.build.lib.actions.extra.SpawnInfo) EnvironmentVariable(com.google.devtools.build.lib.actions.extra.EnvironmentVariable) ExtraActionInfo(com.google.devtools.build.lib.actions.extra.ExtraActionInfo) Test(org.junit.Test)

Aggregations

EnvironmentVariable (com.google.devtools.build.lib.actions.extra.EnvironmentVariable)2 SpawnInfo (com.google.devtools.build.lib.actions.extra.SpawnInfo)2 Test (org.junit.Test)2 ExtraActionInfo (com.google.devtools.build.lib.actions.extra.ExtraActionInfo)1