Skip to content

Commit

Permalink
feat: set $HOME to $TEST_TMPDIR in test targets (#141)
Browse files Browse the repository at this point in the history
  • Loading branch information
sushain97 authored Jul 17, 2024
1 parent dd99181 commit 8b542cd
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
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

0 comments on commit 8b542cd

Please sign in to comment.