aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/test/java/com/google/devtools/build/lib/runtime/ProcessWrapperUtilTest.java
diff options
context:
space:
mode:
authorGravatar Philipp Wollermann <philwo@google.com>2018-03-23 07:39:27 -0700
committerGravatar Copybara-Service <copybara-piper@google.com>2018-03-23 07:40:39 -0700
commit23e1c5d8d267e5825552ce5b05ddfb8ae8972688 (patch)
treec8427eb39a03d0c586f24aaed2cce6cc58065423 /src/test/java/com/google/devtools/build/lib/runtime/ProcessWrapperUtilTest.java
parentd58bd26ea754a189c87ef0af795998acd2ad2874 (diff)
Refactor and cleanup the sandboxing code.
- Remove Optional<> where it's not needed. It's nice for return values, but IMHO it was overused in this code (e.g. Optional<List<X>> is an anti-pattern, as the list itself can already signal that it is empty). - Use Bazel's own Path class when dealing with paths, not String or java.io.File. - Move LinuxSandboxUtil into the "sandbox" package. - Remove dead code and unused fields. - Migrate deprecated VFS method calls to their replacements. - Fix a bug in ExecutionStatistics where a FileInputStream was not closed. Closes #4868. PiperOrigin-RevId: 190217476
Diffstat (limited to 'src/test/java/com/google/devtools/build/lib/runtime/ProcessWrapperUtilTest.java')
-rw-r--r--src/test/java/com/google/devtools/build/lib/runtime/ProcessWrapperUtilTest.java15
1 files changed, 12 insertions, 3 deletions
diff --git a/src/test/java/com/google/devtools/build/lib/runtime/ProcessWrapperUtilTest.java b/src/test/java/com/google/devtools/build/lib/runtime/ProcessWrapperUtilTest.java
index 7dc1bff177..ff1fdd50d5 100644
--- a/src/test/java/com/google/devtools/build/lib/runtime/ProcessWrapperUtilTest.java
+++ b/src/test/java/com/google/devtools/build/lib/runtime/ProcessWrapperUtilTest.java
@@ -17,8 +17,12 @@ package com.google.devtools.build.lib.runtime;
import static com.google.common.truth.Truth.assertThat;
import com.google.common.collect.ImmutableList;
+import com.google.devtools.build.lib.vfs.FileSystem;
+import com.google.devtools.build.lib.vfs.Path;
+import com.google.devtools.build.lib.vfs.inmemoryfs.InMemoryFileSystem;
import java.time.Duration;
import java.util.List;
+import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.JUnit4;
@@ -26,7 +30,12 @@ import org.junit.runners.JUnit4;
/** Unit tests for {@link ProcessWrapperUtil}. */
@RunWith(JUnit4.class)
public final class ProcessWrapperUtilTest {
+ private FileSystem testFS;
+ @Before
+ public final void createFileSystem() {
+ testFS = new InMemoryFileSystem();
+ }
@Test
public void testProcessWrapperCommandLineBuilder_BuildsWithoutOptionalArguments() {
@@ -51,9 +60,9 @@ public final class ProcessWrapperUtilTest {
Duration timeout = Duration.ofSeconds(10);
Duration killDelay = Duration.ofSeconds(2);
- String stdoutPath = "stdout.txt";
- String stderrPath = "stderr.txt";
- String statisticsPath = "stats.out";
+ Path stdoutPath = testFS.getPath("/stdout.txt");
+ Path stderrPath = testFS.getPath("/stderr.txt");
+ Path statisticsPath = testFS.getPath("/stats.out");
ImmutableList<String> expectedCommandLine =
ImmutableList.<String>builder()