Repository navigation
programs.sh: BSD date and stat on macOS - #278
Merged
Merged
Conversation
… bash 3.2)
macOS ships /bin/bash 3.2, where "${arr[@]}" of an empty array is an
'unbound variable' error under set -u. TARGET_FLAGS, test_env, pin and
RUN_PREFIX are empty for a native run, so every sample failed there.
${arr[@]+"${arr[@]}"} expands to nothing for an empty array on every
bash version and keeps the quoting otherwise.
Fixes jonathanperis#198.
CSHARPC_JOBS=N reaped jobs with wait -n, which bash 3.2 doesn't have: it failed at once, so the running count dropped without a job ending and every sample ran at the same time. Bash before 4.3 now polls the jobs' pids instead.
…d stat)
The same empty-array expansion as tests/run.sh broke tests/size.sh
(TARGET_FLAGS) and would break the other suites with optional arrays:
size, programs, projects, debuginfo, check-oracle and slicer now expand
${arr[@]+"${arr[@]}"}. tests/programs.sh also timed builds with
date +%s%N and sized them with stat -c %s, both GNU-only: macOS's date
prints a literal N and its stat has no -c. It now uses wc -c, and perl's
Time::HiRes where date has no %N.
main now re-runs every set -u test script under bash 4.4+ (jonathanperis#498, which closed jonathanperis#198), so the empty-array expansions and the wait -n fallback are no longer needed. programs.sh still called GNU-only date +%s%N and stat -c, which the re-run does not change on a Mac without coreutils.
jonathanperis
marked this pull request as ready for review
November 27, 2026 13:44
Owner
|
Thanks, @filipnavara. #198 was fixed on One part still applies after the re-run: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #198.
macOS ships
/bin/bash3.2 and BSD userland, which break the test scripts in three ways:set -u."${arr[@]}"of an empty array is an "unbound variable" error. A native run leavesTARGET_FLAGS,test_env,pinandRUN_PREFIXempty, so every sample failed on a stock Mac, andtests/size.shstopped at once.${arr[@]+"${arr[@]}"}expands to nothing for an empty array on every bash version and keeps per-element quoting otherwise. Every array expansion now uses it inrun.sh,size.sh,programs.sh,projects.sh,debuginfo.sh,check-oracle.shandslicer.sh.il-main-check.shneeds bash 4's associative arrays and runs on Linux, so it is untouched.CSHARPC_JOBS=Nrelied onwait -n(bash 4.3+). On 3.2 it fails at once, so the running count dropped without any job ending and every sample ran at the same time. Bash before 4.3 now polls the jobs' pids (kill -0, 50 ms); 4.3+ keepswait -n.date +%s%Nandstat -c %sinprograms.sh. macOS'sdateprints a literalN(a shell arithmetic error) and itsstathas no-c. The size now comes fromwc -c, and timing falls back to perl'sTime::HiReswheredatehas no%N.Checked on macOS 27 arm64 with
/bin/bash3.2.57:tests/run.sh --all-opts '1055_marshal|993_reflection': 4 passed;CSHARPC_JOBS=6 tests/run.sh --all-opts 'marshal': 22 passed, at most 6 at a time;--regen(recording the samples of Marshal.SizeOf/OffsetOf of structs with fixed-size buffers #279, Array.IndexOf(Array, object) when the element type is only known at run time #281, A Type local that is exactly typeof(T) stands for T in per-type lowerings #283, [DynamicallyAccessedMembers] on properties and fields keeps the members of typeof values assigned to them #284, Uri: relative references and implicit file paths with spaces #291, Read-write memory-mapped files and UnmanagedMemoryAccessor #293)tests/size.sh: 7 budgets checked on macos-arm64tests/programs.sh interp: 2 passedtests/projects.sh: 29 passeddebuginfo.sh,check-oracle.shandslicer.shonly got the mechanical array change; not run here.