diff options
author | László Csomor <laszlocsomor@google.com> | 2017-10-16 17:11:55 +0200 |
---|---|---|
committer | Jakob Buchgraber <buchgr@google.com> | 2017-10-16 17:49:14 +0200 |
commit | cfccdf1f6e93125d894ff40e0ccecaf20cc20ef5 (patch) | |
tree | 31514750f08dafef373e2632f9643887a011836c /src/test/java/com/google/devtools/build/lib | |
parent | 573a47ad80eb3553566087180d3f02149a2dc9f4 (diff) |
Actions now have a temp envvar.
Every build and test action that creates a Spawn
will now have platform-specific environment
variables for temp directories:
- on Windows: TMP and TEMP
- on Linux/Darwin: TMPDIR
This is particularly important on Windows where
e.g. Java programs cannot create temp directories
unless there's a valid TMP or TEMP environment
variable set.
Fixes:
- https://github.com/bazelbuild/bazel/issues/1590
- https://github.com/bazelbuild/bazel/issues/2349
- https://github.com/bazelbuild/bazel/issues/2870
Change-Id: Ib758307daf6b3a51b0f71ae5e65e5bb564dad643
PiperOrigin-RevId: 172326371
Diffstat (limited to 'src/test/java/com/google/devtools/build/lib')
-rw-r--r-- | src/test/java/com/google/devtools/build/lib/exec/local/LocalSpawnRunnerTest.java | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/src/test/java/com/google/devtools/build/lib/exec/local/LocalSpawnRunnerTest.java b/src/test/java/com/google/devtools/build/lib/exec/local/LocalSpawnRunnerTest.java index 50ddfbe4db..7e6e4db987 100644 --- a/src/test/java/com/google/devtools/build/lib/exec/local/LocalSpawnRunnerTest.java +++ b/src/test/java/com/google/devtools/build/lib/exec/local/LocalSpawnRunnerTest.java @@ -253,6 +253,7 @@ public class LocalSpawnRunnerTest { policy.timeoutMillis = 123 * 1000L; outErr = new FileOutErr(fs.getPath("/out/stdout"), fs.getPath("/out/stderr")); + assertThat(fs.getPath("/execroot").createDirectory()).isTrue(); SpawnResult result = runner.exec(SIMPLE_SPAWN, policy); verify(factory).create(any(SubprocessBuilder.class)); assertThat(result.status()).isEqualTo(SpawnResult.Status.SUCCESS); @@ -299,6 +300,7 @@ public class LocalSpawnRunnerTest { policy.timeoutMillis = 123 * 1000L; outErr = new FileOutErr(fs.getPath("/out/stdout"), fs.getPath("/out/stderr")); + assertThat(fs.getPath("/execroot").createDirectory()).isTrue(); SpawnResult result = runner.exec(SIMPLE_SPAWN, policy); verify(factory).create(any()); assertThat(result.status()).isEqualTo(SpawnResult.Status.SUCCESS); @@ -334,6 +336,7 @@ public class LocalSpawnRunnerTest { "product-name", LocalEnvProvider.UNMODIFIED); outErr = new FileOutErr(fs.getPath("/out/stdout"), fs.getPath("/out/stderr")); + assertThat(fs.getPath("/execroot").createDirectory()).isTrue(); SpawnResult result = runner.exec(SIMPLE_SPAWN, policy); verify(factory).create(any(SubprocessBuilder.class)); assertThat(result.status()).isEqualTo(SpawnResult.Status.SUCCESS); @@ -371,6 +374,7 @@ public class LocalSpawnRunnerTest { assertThat(fs.getPath("/out").createDirectory()).isTrue(); outErr = new FileOutErr(fs.getPath("/out/stdout"), fs.getPath("/out/stderr")); + assertThat(fs.getPath("/execroot").createDirectory()).isTrue(); SpawnResult result = runner.exec(SIMPLE_SPAWN, policy); verify(factory).create(any(SubprocessBuilder.class)); assertThat(result.status()).isEqualTo(SpawnResult.Status.EXECUTION_FAILED); @@ -394,6 +398,7 @@ public class LocalSpawnRunnerTest { "product-name", LocalEnvProvider.UNMODIFIED); outErr = new FileOutErr(); + assertThat(fs.getPath("/execroot").createDirectory()).isTrue(); SpawnResult reply = runner.exec(SIMPLE_SPAWN, policy); assertThat(reply.status()).isEqualTo(SpawnResult.Status.LOCAL_ACTION_NOT_ALLOWED); assertThat(reply.exitCode()).isEqualTo(-1); @@ -433,6 +438,7 @@ public class LocalSpawnRunnerTest { "product-name", LocalEnvProvider.UNMODIFIED); outErr = new FileOutErr(fs.getPath("/out/stdout"), fs.getPath("/out/stderr")); + assertThat(fs.getPath("/execroot").createDirectory()).isTrue(); try { runner.exec(SIMPLE_SPAWN, policy); fail(); @@ -456,6 +462,7 @@ public class LocalSpawnRunnerTest { policy.timeoutMillis = 123 * 1000L; outErr = new FileOutErr(fs.getPath("/out/stdout"), fs.getPath("/out/stderr")); + assertThat(fs.getPath("/execroot").createDirectory()).isTrue(); runner.exec(SIMPLE_SPAWN, policy); assertThat(policy.prefetchCalled).isTrue(); } @@ -476,6 +483,7 @@ public class LocalSpawnRunnerTest { Spawn spawn = new SpawnBuilder("/bin/echo", "Hi!") .withExecutionInfo(ExecutionRequirements.DISABLE_LOCAL_PREFETCH, "").build(); + assertThat(fs.getPath("/execroot").createDirectory()).isTrue(); runner.exec(spawn, policy); assertThat(policy.prefetchCalled).isFalse(); } @@ -494,10 +502,15 @@ public class LocalSpawnRunnerTest { policy.timeoutMillis = 123 * 1000L; outErr = new FileOutErr(fs.getPath("/out/stdout"), fs.getPath("/out/stderr")); + assertThat(fs.getPath("/execroot").createDirectory()).isTrue(); runner.exec(SIMPLE_SPAWN, policy); verify(localEnvProvider) - .rewriteLocalEnv(any(), eq(fs.getPath("/execroot")), eq("product-name")); + .rewriteLocalEnv( + any(), + eq(fs.getPath("/execroot")), + eq(fs.getPath("/execroot/tmp1")), + eq("product-name")); } @Test @@ -521,6 +534,7 @@ public class LocalSpawnRunnerTest { policy.timeoutMillis = 321 * 1000L; outErr = new FileOutErr(fs.getPath("/out/stdout"), fs.getPath("/out/stderr")); + assertThat(fs.getPath("/execroot").createDirectory()).isTrue(); SpawnResult result = runner.exec(SIMPLE_SPAWN, policy); verify(factory).create(any(SubprocessBuilder.class)); assertThat(result.status()).isEqualTo(SpawnResult.Status.SUCCESS); |