aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/test/shell
diff options
context:
space:
mode:
authorGravatar Damien Martin-Guillerez <dmarting@google.com>2015-07-21 13:23:25 +0000
committerGravatar Kristina Chodorow <kchodorow@google.com>2015-07-21 15:13:38 -0400
commit946a2fb382e1d7792915de25648b27485598fc12 (patch)
tree2194eefa2c5459d28238122fba4cbe73a3907818 /src/test/shell
parentc9bf5064c93d72037b931ada28f6bd0d0de80489 (diff)
Set PATH and TMPDIR in genrule / Skylark's action
PATH and TMPDIR were unset inside genrule / Skylark's action even if use_default_shell_env is set. -- MOS_MIGRATED_REVID=98729334
Diffstat (limited to 'src/test/shell')
-rwxr-xr-xsrc/test/shell/bazel/bazel_rules_test.sh24
1 files changed, 24 insertions, 0 deletions
diff --git a/src/test/shell/bazel/bazel_rules_test.sh b/src/test/shell/bazel/bazel_rules_test.sh
index 3e4af160d3..3135e9995f 100755
--- a/src/test/shell/bazel/bazel_rules_test.sh
+++ b/src/test/shell/bazel/bazel_rules_test.sh
@@ -212,4 +212,28 @@ EOF
expect_log "Hello, World!"
}
+
+function test_genrule_default_env() {
+ mkdir -p pkg
+ cat <<'EOF' >pkg/BUILD
+genrule(
+ name = "test",
+ outs = ["test.out"],
+ cmd = "(echo \"PATH=$$PATH\"; echo \"TMPDIR=$$TMPDIR\") > $@",
+)
+EOF
+ local old_path="$PATH"
+ local old_tmpdir="$TMPDIR"
+ export PATH=":/bin:/usr/bin:/random/path"
+ export TMPDIR="/some/path"
+ # batch mode to force reload of the environment
+ bazel --batch build //pkg:test || fail "Failed to build //pkg:test"
+ export PATH="$old_path"
+ export TMPDIR="$old_tmpdir"
+ assert_contains "PATH=:/bin:/usr/bin:/random/path" \
+ bazel-genfiles/pkg/test.out
+ assert_contains "TMPDIR=/some/path" \
+ bazel-genfiles/pkg/test.out
+}
+
run_suite "rules test"