Fix IPv6-related network issues in some shell tests.
PiperOrigin-RevId: 638314617
Change-Id: Ia6a3f63f998e9cfd3512d2c6a17c622c2ac60846
diff --git a/src/test/shell/bazel/BUILD b/src/test/shell/bazel/BUILD
index 1ac9df8..79c355f 100644
--- a/src/test/shell/bazel/BUILD
+++ b/src/test/shell/bazel/BUILD
@@ -448,6 +448,7 @@
tags = [
"no-sandbox",
"no_windows",
+ "requires-network", # For Bzlmod
],
)
diff --git a/src/test/shell/bazel/bazel_test_test.sh b/src/test/shell/bazel/bazel_test_test.sh
index 9f9b2c0..02a5dcb 100755
--- a/src/test/shell/bazel/bazel_test_test.sh
+++ b/src/test/shell/bazel/bazel_test_test.sh
@@ -174,8 +174,16 @@
)
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"
@@ -187,7 +195,7 @@
# 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"
diff --git a/src/test/shell/integration/BUILD b/src/test/shell/integration/BUILD
index 2d0035a..8a49cf0 100644
--- a/src/test/shell/integration/BUILD
+++ b/src/test/shell/integration/BUILD
@@ -129,6 +129,9 @@
"@bazel_tools//tools/bash/runfiles",
],
shard_count = 8,
+ tags = [
+ "requires-network", # For Bzlmod
+ ],
)
sh_test(