aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/test/shell/bazel/bazel_test_test.sh
diff options
context:
space:
mode:
authorGravatar Kristina Chodorow <kchodorow@google.com>2016-08-18 14:24:58 +0000
committerGravatar Philipp Wollermann <philwo@google.com>2016-08-18 17:25:32 +0000
commit88de40ee8bf2248fbf2264a7725170e0a83ee84c (patch)
treef0fd54f81ef0efb454d76feca2c7b7c4bc56dfbd /src/test/shell/bazel/bazel_test_test.sh
parent837dbc1739258d72a5e7c4adb37ffe6aff847672 (diff)
Fix tmpdir with standalone test strategy
If the tmpdir wasn't below the execroot, Bazel would crash and print a stack trace. Also, the test was incorrect because the EOF wasn't quoted, so it was actually just executing "echo TEST_TMPDIR=/path/to/tmpdir" which (surprise surprise) matched TEST_TMPDIR=/path/to/tmpdir. Finally, the test was _also_ incorrect because it was using the cached test result for the second case, since changing the tmpdir doesn't invalidate the test result. So it not only was comparing a constant string to a constant string, but it wasn't even re-evaluating the constant string. -- MOS_MIGRATED_REVID=130637221
Diffstat (limited to 'src/test/shell/bazel/bazel_test_test.sh')
-rwxr-xr-xsrc/test/shell/bazel/bazel_test_test.sh18
1 files changed, 16 insertions, 2 deletions
diff --git a/src/test/shell/bazel/bazel_test_test.sh b/src/test/shell/bazel/bazel_test_test.sh
index 98a80cbbdc..1c98a6991d 100755
--- a/src/test/shell/bazel/bazel_test_test.sh
+++ b/src/test/shell/bazel/bazel_test_test.sh
@@ -91,7 +91,7 @@ function test_unlimited_local_jobs() {
function test_tmpdir() {
mkdir -p foo
- cat > foo/bar_test.sh <<EOF
+ cat > foo/bar_test.sh <<'EOF'
#!/bin/bash
echo TEST_TMPDIR=$TEST_TMPDIR
EOF
@@ -106,9 +106,23 @@ EOF
fail "Running sh_test failed"
expect_log "TEST_TMPDIR=/.*"
- bazel test --test_output=all --test_tmpdir=$TEST_TMPDIR //foo:bar_test \
+ bazel test --nocache_test_results --test_output=all --test_tmpdir=$TEST_TMPDIR //foo:bar_test \
>& $TEST_log || fail "Running sh_test failed"
expect_log "TEST_TMPDIR=$TEST_TMPDIR"
+
+ # If we run `bazel test //src/test/shell/bazel:bazel_test_test` on Linux, it
+ # will be sandboxed and this "inner test" creating /foo/bar will actually
+ # 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
}
function test_env_vars() {