Skip to content

Commit f5cb4a9

Browse files
committed
Modify TMPDIR to avoid port colissions
1 parent de66ce0 commit f5cb4a9

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

java/gazelle/testdata/gazelle_build_mode.bzl

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,13 +27,21 @@ def _gazelle_embedded_javaparser_impl(ctx):
2727
# Therefore, we have to look in the runfiles dir for the real gazelle binary.
2828
mkdir $RUNFILES_DIR/hack_for_runtime_path
2929
export GAZELLE_JAVA_JAVAHOME="$RUNFILES_DIR/hack_for_runtime_path/{java_home}"
30+
31+
# If both the embedded and non-embedded version of a test are running at the same time, they will collide trying to create the port file and crash.
32+
export TMPDIR="$TMPDIR_embedded"
33+
3034
exec $RUNFILES_DIR/_main/{gazelle_bin} "$@"
3135
"""
3236

3337
gazelle_runner_script_windows = """@echo off
3438
REM Because java_home points to ../<java_repository> but we pass the JDK runfiles in DefaultInfo,
3539
REM we insert a non-existent directory to cancel out the `..`.
3640
set "GAZELLE_JAVA_JAVAHOME=%RUNFILES_DIR%\\hack_for_runtime_path\\{java_home}"
41+
42+
REM If both the embedded and non-embedded version of a test are running at the same time, they will collide trying to create the port file and crash.
43+
set "TMPDIR=%TMPDIR%_embedded"
44+
3745
call %RUNFILES_DIR%\\_main\\{gazelle_bin} %*
3846
"""
3947

0 commit comments

Comments
 (0)