aboutsummaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authorGravatar Yue Gan <yueg@google.com>2016-12-20 09:46:39 +0000
committerGravatar Klaus Aehlig <aehlig@google.com>2016-12-20 11:06:52 +0000
commit87532156cf3ed7b66c6db5cb1e57dff7424031ab (patch)
tree1f503682598ac7101f3c612dbcebefe03f2cdde0 /src
parentd6297fb8b924dda41111356c0c32d4a5a297a11b (diff)
Gives detailed error message when fail to re-create directories during testing. Also
fixes bazel_test_test. Fixes #2228. -- PiperOrigin-RevId: 142532524 MOS_MIGRATED_REVID=142532524
Diffstat (limited to 'src')
-rw-r--r--src/main/java/com/google/devtools/build/lib/exec/TestStrategy.java12
-rwxr-xr-xsrc/test/shell/bazel/bazel_test_test.sh14
2 files changed, 14 insertions, 12 deletions
diff --git a/src/main/java/com/google/devtools/build/lib/exec/TestStrategy.java b/src/main/java/com/google/devtools/build/lib/exec/TestStrategy.java
index 96d8798c68..32ddf9da9b 100644
--- a/src/main/java/com/google/devtools/build/lib/exec/TestStrategy.java
+++ b/src/main/java/com/google/devtools/build/lib/exec/TestStrategy.java
@@ -75,9 +75,17 @@ public abstract class TestStrategy implements TestActionContext {
TestRunnerAction testAction, Path tmpDir, Path coverageDir, Path workingDirectory)
throws IOException {
if (isCoverageMode(testAction)) {
- recreateDirectory(coverageDir);
+ try {
+ recreateDirectory(coverageDir);
+ } catch (IOException e) {
+ throw new IOException("Failed to recreate coverage directory " + coverageDir, e);
+ }
+ }
+ try {
+ recreateDirectory(tmpDir);
+ } catch (IOException e) {
+ throw new IOException("Failed to recreate temporary directory " + tmpDir, e);
}
- recreateDirectory(tmpDir);
FileSystemUtils.createDirectoryAndParents(workingDirectory);
}
diff --git a/src/test/shell/bazel/bazel_test_test.sh b/src/test/shell/bazel/bazel_test_test.sh
index fbd9bc966a..ed76164f74 100755
--- a/src/test/shell/bazel/bazel_test_test.sh
+++ b/src/test/shell/bazel/bazel_test_test.sh
@@ -80,8 +80,7 @@ function test_3_local_jobs() {
--runs_per_test=10 //dir:test
}
-# TODO(#2228): Re-enable when the tmpdir creation is fixed.
-function DISABLED_test_tmpdir() {
+function test_tmpdir() {
mkdir -p foo
cat > foo/bar_test.sh <<'EOF'
#!/bin/bash
@@ -107,14 +106,9 @@ EOF
# succeed. If we run it on OS X (or in general without sandboxing enabled),
# it will fail to create /foo/bar, since obviously we don't have write
# permissions.
- if bazel test --nocache_test_results --test_output=all \
- --test_tmpdir=/foo/bar //foo:bar_test >& $TEST_log; then
- # We are in a sandbox.
- expect_log "TEST_TMPDIR=/foo/bar"
- else
- # We are not sandboxed.
- expect_log "Could not create TEST_TMPDIR"
- fi
+ bazel test --nocache_test_results --test_output=all --test_tmpdir=/foo/bar \
+ //foo:bar_test >& $TEST_log && fail "Writing to no permission path should fail"
+ expect_log "Failed to recreate temporary directory"
}
function test_env_vars() {