Skip to content

Commit

Permalink
rules_r: fix exporting status vars as env vars in r_binary
Browse files Browse the repository at this point in the history
This was broken by 8a4ab37 in which we
stopped exporting stable status var by default.
  • Loading branch information
Siddhartha Bagaria committed Mar 6, 2020
1 parent ec66be6 commit 7a0dc43
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 2 deletions.
12 changes: 10 additions & 2 deletions R/scripts/binary.sh.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,17 @@ fatal() {
}

# Make bazel status variables available as environment variables, if available.
if [[ -e ./stable-status.txt ]]; then
e="$(cat ./{stable,volatile}-status.txt | sed -e 's/\([^[:space:]]*\) \(.*\)/export \1=\"\2\"/')"
status_to_env() {
local status_file="$1"
e="$(cat "${status_file}" | sed -e 's/\([^[:space:]]*\) \(.*\)/export \1=\"\2\"/')"
eval "${e}"
}

if [[ -e "./volatile-status.txt" ]]; then
status_to_env "./volatile-status.txt"
fi
if [[ -e "./stable-status.txt" ]]; then
status_to_env "./stable-status.txt"
fi

# Export environment variables, if any.
Expand Down
6 changes: 6 additions & 0 deletions tests/stamping/nostamp_test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,13 @@ fail() {
if ! grep "^VAR" "volatile-status.txt"; then
fail "volatile status file expected"
fi
if ! [[ "${VAR:-}" ]]; then
fail "volatile status var expected as env var"
fi

if [[ -e stable-info.txt ]]; then
fail "stable status file not expected"
fi
if [[ "${STABLE_VAR:-}" ]]; then
fail "stable status var not expected as env var"
fi
6 changes: 6 additions & 0 deletions tests/stamping/stamp_test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,13 @@ fail() {
if ! grep "^VAR" "volatile-status.txt"; then
fail "volatile status file expected"
fi
if ! [[ "${VAR:-}" ]]; then
fail "volatile status var expected as env var"
fi

if ! grep "^STABLE_VAR" "stable-status.txt"; then
fail "stable status file expected and not empty"
fi
if ! [[ "${STABLE_VAR:-}" ]]; then
fail "stable status var expected as env var"
fi

0 comments on commit 7a0dc43

Please sign in to comment.