Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Set $HOME to $TEST_TMPDIR in test targets #141

Merged
merged 1 commit into from
Jul 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions ruby/private/binary/binary.cmd.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,17 @@ if "{java_bin}" neq "" (
for %%a in ("!java_bin!\..\..") do set JAVA_HOME=%%~fa
)

:: Bundler expects the %HOME% directory to be writable and produces misleading
:: warnings if it isn't. This isn't the case in every situation (e.g. remote
:: execution) and Bazel recommends using %TEST_TMPDIR% when it's available:
:: https://bazel.build/reference/test-encyclopedia#initial-conditions
::
:: We set %HOME% prior to setting environment variables from the target itself
:: so that users can override this behavior if they desire.
if defined TEST_TMPDIR (
set "HOME=%TEST_TMPDIR%"
)

:: Set environment variables.
{env}

Expand Down
11 changes: 11 additions & 0 deletions ruby/private/binary/binary.sh.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,17 @@ if [ -n "{java_bin}" ]; then
export JAVA_HOME=$(dirname $(dirname $(rlocation "{java_bin}")))
fi

# Bundler expects the $HOME directory to be writable and produces misleading
# warnings if it isn't. This isn't the case in every situation (e.g. remote
# execution) and Bazel recommends using $TEST_TMPDIR when it's available:
# https://bazel.build/reference/test-encyclopedia#initial-conditions
#
# We set $HOME prior to setting environment variables from the target itself so
# that users can override this behavior if they desire.
if [ -n "${TEST_TMPDIR:-}" ]; then
export HOME=$TEST_TMPDIR
fi

# Set environment variables.
{env}

Expand Down