aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/test/java/com/google/devtools/build/lib
diff options
context:
space:
mode:
authorGravatar Philipp Wollermann <philwo@google.com>2015-10-06 11:35:52 +0000
committerGravatar Laszlo Csomor <laszlocsomor@google.com>2015-10-06 11:41:05 +0000
commitb504305394b284e872eefdaaec8ba56bb607cebb (patch)
treec126ca0890958975be99128c33de78b380698957 /src/test/java/com/google/devtools/build/lib
parent2ab01ef8a837c071cd75b774e8584dcca1f06c2c (diff)
Ensure that the LinuxSandboxedStrategy tests actually test the correct strategy.
-- MOS_MIGRATED_REVID=104749361
Diffstat (limited to 'src/test/java/com/google/devtools/build/lib')
-rw-r--r--src/test/java/com/google/devtools/build/lib/sandbox/LinuxSandboxedStrategyTestCase.java8
-rw-r--r--src/test/java/com/google/devtools/build/lib/sandbox/LocalLinuxSandboxedStrategyTest.java4
2 files changed, 10 insertions, 2 deletions
diff --git a/src/test/java/com/google/devtools/build/lib/sandbox/LinuxSandboxedStrategyTestCase.java b/src/test/java/com/google/devtools/build/lib/sandbox/LinuxSandboxedStrategyTestCase.java
index 8c157628ef..b2f5c550ca 100644
--- a/src/test/java/com/google/devtools/build/lib/sandbox/LinuxSandboxedStrategyTestCase.java
+++ b/src/test/java/com/google/devtools/build/lib/sandbox/LinuxSandboxedStrategyTestCase.java
@@ -13,6 +13,8 @@
// limitations under the License.
package com.google.devtools.build.lib.sandbox;
+import static com.google.common.truth.Truth.assertThat;
+
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap;
import com.google.common.eventbus.EventBus;
@@ -107,6 +109,12 @@ public class LinuxSandboxedStrategyTestCase {
ImmutableList.<ActionContextProvider>of());
}
+ protected LinuxSandboxedStrategy getLinuxSandboxedStrategy() {
+ SpawnActionContext spawnActionContext = executor.getSpawnActionContext("");
+ assertThat(spawnActionContext).isInstanceOf(LinuxSandboxedStrategy.class);
+ return (LinuxSandboxedStrategy) spawnActionContext;
+ }
+
private Path createTestRoot() throws IOException {
fileSystem = FileSystems.initDefaultAsNative();
Path testRoot = fileSystem.getPath(TestUtils.tmpDir());
diff --git a/src/test/java/com/google/devtools/build/lib/sandbox/LocalLinuxSandboxedStrategyTest.java b/src/test/java/com/google/devtools/build/lib/sandbox/LocalLinuxSandboxedStrategyTest.java
index f4703a3e28..d47051bc62 100644
--- a/src/test/java/com/google/devtools/build/lib/sandbox/LocalLinuxSandboxedStrategyTest.java
+++ b/src/test/java/com/google/devtools/build/lib/sandbox/LocalLinuxSandboxedStrategyTest.java
@@ -67,7 +67,7 @@ public class LocalLinuxSandboxedStrategyTest extends LinuxSandboxedStrategyTestC
@Test
public void testExecutionSuccess() throws Exception {
Spawn spawn = createSpawn("/bin/sh", "-c", "echo Hello, world.; touch dummy");
- executor.getSpawnActionContext(spawn.getMnemonic()).exec(spawn, createContext());
+ getLinuxSandboxedStrategy().exec(spawn, createContext());
assertThat(out()).isEqualTo("Hello, world.\n");
assertThat(err()).isEmpty();
}
@@ -76,7 +76,7 @@ public class LocalLinuxSandboxedStrategyTest extends LinuxSandboxedStrategyTestC
public void testExecutionFailurePrintsCorrectMessage() throws Exception {
Spawn spawn = createSpawn("/bin/sh", "-c", "echo ERROR >&2; exit 1");
try {
- executor.getSpawnActionContext(spawn.getMnemonic()).exec(spawn, createContext());
+ getLinuxSandboxedStrategy().exec(spawn, createContext());
fail();
} catch (UserExecException e) {
assertThat(err()).isEqualTo("ERROR\n");