-
Notifications
You must be signed in to change notification settings - Fork 4.1k
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
Improve sh_test execution compatibility on MacOS #22228
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The changes to this file were not necessary but are also not harmful, so I've left them in the patchset.
@mark-thm I can't see how these changes would make any difference, did making these changes actually fix the failures? I have the same setup (MacOS Sonoma 14.4.1, GNU bash, version 3.2.57(1)-release) and the tests seem to be working fine. By any chance, are you perhaps running into something similar to #21391 (comment)? |
Unfortunately, no, that doesn't seem related. Here's with $ bazel test --announce_rc --noincompatible_check_sharding_support --test_filter=test_download_and_extract src/test/shell/bazel:bazel_workspaces_test
INFO: Options provided by the client:
Inherited 'common' options: --isatty=1 --terminal_columns=142
INFO: Reading rc options for 'test' from /Users/melliot/code/bazel/.bazelrc:
Inherited 'common' options: --enable_platform_specific_config --check_direct_dependencies=error --experimental_downloader_config=bazel_downloader.cfg --incompatible_disallow_empty_glob
INFO: Reading rc options for 'test' from /Users/melliot/code/bazel/.bazelrc:
Inherited 'build' options: --java_runtime_version=21 --java_language_version=21 --tool_java_language_version=21 --tool_java_runtime_version=21
INFO: Found applicable config definition build:macos in file /Users/melliot/code/bazel/.bazelrc: --macos_minimum_os=10.11 --cxxopt=-std=c++17 --host_cxxopt=-std=c++17
FAIL: //src/test/shell/bazel:bazel_workspaces_test (shard 3 of 3) (see /private/var/tmp/_bazel_melliot/bca87da07f637628ae875fb2424867d8/execroot/_main/bazel-out/darwin_arm64-fastbuild/testlogs/src/test/shell/bazel/bazel_workspaces_test/shard_3_of_3/test.log)
FAIL: //src/test/shell/bazel:bazel_workspaces_test (shard 2 of 3) (see /private/var/tmp/_bazel_melliot/bca87da07f637628ae875fb2424867d8/execroot/_main/bazel-out/darwin_arm64-fastbuild/testlogs/src/test/shell/bazel/bazel_workspaces_test/shard_2_of_3/test.log)
FAIL: //src/test/shell/bazel:bazel_workspaces_test (shard 1 of 3) (see /private/var/tmp/_bazel_melliot/bca87da07f637628ae875fb2424867d8/execroot/_main/bazel-out/darwin_arm64-fastbuild/testlogs/src/test/shell/bazel/bazel_workspaces_test/shard_1_of_3/test.log)
FAILED: //src/test/shell/bazel:bazel_workspaces_test (Summary)
/private/var/tmp/_bazel_melliot/bca87da07f637628ae875fb2424867d8/execroot/_main/bazel-out/darwin_arm64-fastbuild/testlogs/src/test/shell/bazel/bazel_workspaces_test/shard_3_of_3/test.log
/private/var/tmp/_bazel_melliot/bca87da07f637628ae875fb2424867d8/execroot/_main/bazel-out/darwin_arm64-fastbuild/testlogs/src/test/shell/bazel/bazel_workspaces_test/shard_2_of_3/test.log
/private/var/tmp/_bazel_melliot/bca87da07f637628ae875fb2424867d8/execroot/_main/bazel-out/darwin_arm64-fastbuild/testlogs/src/test/shell/bazel/bazel_workspaces_test/shard_1_of_3/test.log
INFO: Found 1 test target...
Target //src/test/shell/bazel:bazel_workspaces_test up-to-date:
bazel-bin/src/test/shell/bazel/bazel_workspaces_test
INFO: Elapsed time: 1.615s, Critical Path: 1.31s
INFO: 4 processes: 6 darwin-sandbox.
INFO: Build completed, 1 test FAILED, 4 total actions
//src/test/shell/bazel:bazel_workspaces_test FAILED in 3 out of 3 in 1.2s
Stats over 3 runs: max = 1.2s, min = 1.2s, avg = 1.2s, dev = 0.0s
/private/var/tmp/_bazel_melliot/bca87da07f637628ae875fb2424867d8/execroot/_main/bazel-out/darwin_arm64-fastbuild/testlogs/src/test/shell/bazel/bazel_workspaces_test/shard_3_of_3/test.log
/private/var/tmp/_bazel_melliot/bca87da07f637628ae875fb2424867d8/execroot/_main/bazel-out/darwin_arm64-fastbuild/testlogs/src/test/shell/bazel/bazel_workspaces_test/shard_2_of_3/test.log
/private/var/tmp/_bazel_melliot/bca87da07f637628ae875fb2424867d8/execroot/_main/bazel-out/darwin_arm64-fastbuild/testlogs/src/test/shell/bazel/bazel_workspaces_test/shard_1_of_3/test.log I run zsh as my shell, and for good measure tried launching the build from bash, but the results are the same. Here's test.log from shard_1_of_3, they're all fundamentally the same, though:
|
Adding some debugging: diff --git a/src/test/shell/testenv.sh.tmpl b/src/test/shell/testenv.sh.tmpl
index 5d0fb91170..00dd6924f9 100755
--- a/src/test/shell/testenv.sh.tmpl
+++ b/src/test/shell/testenv.sh.tmpl
@@ -260,7 +260,12 @@ function setup_localjdk_javabase() {
if [[ $PLATFORM =~ msys ]]; then
jdk_dir="$(cygpath -m $(cd $(rlocation local_jdk/bin/java.exe)/../..; pwd))"
else
- jdk_dir="$(dirname "$(dirname "$(rlocation local_jdk/bin/java)")")"
+ # jdk_dir="$(dirname "$(dirname "$(rlocation local_jdk/bin/java)")")"
+ echo "rlocation=$(rlocation local_jdk/bin/java)"
+ echo "dirname+rlocation=$(dirname $(rlocation local_jdk/bin/java))"
+ echo "dirname+rlocation quoted=$(dirname "$(rlocation local_jdk/bin/java)")"
+ jdk_dir="$(dirname $(dirname $(rlocation local_jdk/bin/java)))"
+ echo "jdk_dir=$jdk_dir"
fi
bazel_javabase="${jdk_dir}"
} Results in the following output from the still failing tests:
|
So ultimately this comes down to But as to why this change helps the situation, here's some additional debug: bash-3.2$ dirname ""
.
bash-3.2$ echo $?
0
bash-3.2$ dirname $(echo "")
usage: dirname string [...]
bash-3.2$ echo $?
1
bash-3.2$ dirname "$(echo "")"
.
bash-3.2$ echo $?
0 My default local JDK is: $ java -version
openjdk version "22.0.1" 2024-04-16
OpenJDK Runtime Environment Zulu22.30+13-CA (build 22.0.1+8)
OpenJDK 64-Bit Server VM Zulu22.30+13-CA (build 22.0.1+8, mixed mode, sharing) If I set my JDK to 21, the tests pass. It'd probably be less cryptic to test the output of |
While working on #22213 I ran into errors running any
sh_test
, all invocations terminated without running any of the tests, and ended with these two lines:I'm working on an arm-based Mac with MacOS Sonoma 14.4.1 and with bash reporting a version of GNU bash, version 3.2.57(1)-release.
This PR adds quotes to
dirname
arguments to resolve thesh_test
execution failures.