Skip to content

Commit

Permalink
Fix IPv6-related network issues in some shell tests.
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 638314617
Change-Id: Ia6a3f63f998e9cfd3512d2c6a17c622c2ac60846
  • Loading branch information
fweikert authored and copybara-github committed May 29, 2024
1 parent 29e9a9d commit b48a319
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 2 deletions.
1 change: 1 addition & 0 deletions src/test/shell/bazel/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -448,6 +448,7 @@ sh_test(
tags = [
"no-sandbox",
"no_windows",
"requires-network", # For Bzlmod
],
)

Expand Down
12 changes: 10 additions & 2 deletions src/test/shell/bazel/bazel_test_test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -174,8 +174,16 @@ sh_test(
)
EOF

# The next line ensures that the test passes in IPv6-only networks on macOS.
if is_darwin; then
export JAVA_TOOL_OPTIONS="-Djava.net.preferIPv6Addresses=true"
export STARTUP_OPTS="--host_jvm_args=-Djava.net.preferIPv6Addresses=true"
else
export STARTUP_OPTS=""
fi

# Test BAR is set from --action_env
BAZ=fromaction bazel --ignore_all_rc_files test --test_output=all \
BAZ=fromaction bazel --ignore_all_rc_files $STARTUP_OPTS test --test_output=all \
--action_env=BAR=fromcli --action_env=BAZ \
//foo &> $TEST_log || fail "Test failed"
expect_log "foo: frombuild"
Expand All @@ -187,7 +195,7 @@ EOF
# Test FOO from the BUILD file wins
# Test BAR is set from --test_env
# Test BAZ is set from --test_env
BAZ=fromtest bazel --ignore_all_rc_files test --test_output=all \
BAZ=fromtest bazel --ignore_all_rc_files $STARTUP_OPTS test --test_output=all \
--action_env=FOO=fromcli --test_env=FOO=fromcli --test_env=BAR=fromcli \
--test_env=BAZ //foo &> $TEST_log || fail "Test failed"
expect_log "foo: frombuild"
Expand Down
3 changes: 3 additions & 0 deletions src/test/shell/integration/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,9 @@ sh_test(
"@bazel_tools//tools/bash/runfiles",
],
shard_count = 8,
tags = [
"requires-network", # For Bzlmod
],
)

sh_test(
Expand Down

0 comments on commit b48a319

Please sign in to comment.