diff options
author | Kristina Chodorow <kchodorow@google.com> | 2016-04-25 15:14:55 +0000 |
---|---|---|
committer | Yun Peng <pcloudy@google.com> | 2016-04-25 17:48:34 +0000 |
commit | 06fb7ef98fedf9e814380e75f323a4f9669a1f93 (patch) | |
tree | 3474d81b455f169cd3d71491c1cb5c3e8da8628f | |
parent | 6ba22c0b3bf323db9235a2bb2a5c333d2518b148 (diff) |
Fix docs on test environment and add a test
Fixes #1126.
--
MOS_MIGRATED_REVID=120707955
-rw-r--r-- | site/docs/test-encyclopedia.html | 7 | ||||
-rwxr-xr-x | src/test/shell/bazel/bazel_test_test.sh | 25 |
2 files changed, 30 insertions, 2 deletions
diff --git a/site/docs/test-encyclopedia.html b/site/docs/test-encyclopedia.html index 7429066079..f534cc633b 100644 --- a/site/docs/test-encyclopedia.html +++ b/site/docs/test-encyclopedia.html @@ -203,7 +203,7 @@ test unless the user explicitly requests it.</p> <tr><td><code>LOGNAME</code></td><td>value of <code>$USER</code></td><td>required</td></tr> <tr><td><code>PATH</code></td><td><code>/usr/local/bin:/usr/local/sbin:/usr/bin:/usr/sbin:/bin:/sbin:.</code></td><td>recommended</td></tr> - <tr><td><code>PWD</code></td><td><code>$TEST_SRCDIR</code></td><td>recommended</td></tr> + <tr><td><code>PWD</code></td><td><code>$TEST_SRCDIR/<i>workspace-name</i></code></td><td>recommended</td></tr> <tr><td><code>SHLVL</code></td><td><code>2</code></td><td>recommended</td></tr> <tr><td><code>TEST_PREMATURE_EXIT_FILE</code></td><td>absolute path to a private file in a writable directory (used for catching calls to exit())</td><td>optional</td></tr> <tr><td><code>TEST_RANDOM_SEED</code></td><td>See <a href="bazel-user-manual.html#other_options_for_blaze_test">this table</a>.</td><td>optional</td></tr> @@ -222,13 +222,16 @@ test unless the user explicitly requests it.</p> <tr><td><code>USER</code></td><td>value of <code>getpwuid(getuid())->pw_name</code></td><td>required</td></tr> + <tr><td><code>XML_OUTPUT_FILE</code></td><td>Location of the <code>ANT</code>-like XML output file</td><td>optional</td></tr> + <tr><td><code>TEST_WORKSPACE</code></td><td>the local repository's workspace name</td><td>optional</td></tr> + </tbody> </table> <br> <p>The environment may contain additional entries. Tests should not depend on the presence, absence, or value of any environment variable not listed above.</p> -<p>The initial working directory shall be <code>$TEST_SRCDIR</code>.</p> +<p>The initial working directory shall be <code>$TEST_SRCDIR/$TEST_WORKSPACE</code>.</p> <p> The current process id, process group id, session id, and parent process id are unspecified. The process may or may not be a process group leader or a session leader. The process may or may not have a controlling terminal. The diff --git a/src/test/shell/bazel/bazel_test_test.sh b/src/test/shell/bazel/bazel_test_test.sh index 60ca47351c..4997143298 100755 --- a/src/test/shell/bazel/bazel_test_test.sh +++ b/src/test/shell/bazel/bazel_test_test.sh @@ -115,6 +115,31 @@ EOF expect_log "TEST_TMPDIR=$TEST_TMPDIR" } +function test_env_vars() { + cat > WORKSPACE <<EOF +workspace(name = "bar") +EOF + mkdir -p foo + cat > foo/testenv.sh <<'EOF' +#!/bin/bash +echo "pwd: $PWD" +echo "src: $TEST_SRCDIR" +echo "ws: $TEST_WORKSPACE" +EOF + chmod +x foo/testenv.sh + cat > foo/BUILD <<EOF +sh_test( + name = "foo", + srcs = ["testenv.sh"], +) +EOF + + bazel test --test_output=all //foo &> $TEST_log || fail "Test failed" + expect_log "pwd: .*/foo.runfiles/bar$" + expect_log "src: .*/foo.runfiles$" + expect_log "ws: bar$" +} + function test_run_under_label_with_options() { mkdir -p testing run || fail "mkdir testing run failed" cat <<EOF > run/BUILD |