Skip to content

Commit 91262df

Browse files
committed
ci: improve macOS cmd test workaround - try CGO_ENABLED=0 and 1 explicitly
The LC_UUID abort on Go 1.22 + macos-latest runners is extremely persistent and not fixed by simple retry + codesign. New approach for the cmd package on Darwin: - Loop over CGO_ENABLED=0 and CGO_ENABLED=1 - Build with `go test -c` - codesign the resulting binary - Run it directly This gives the toolchain two different ways to produce the test binary, increasing the chance that at least one produces a runnable binary on flaky GitHub macOS images. Go 1.23 macOS jobs have been passing; this targets the Go 1.22 matrix entries.
1 parent 37c3c9f commit 91262df

1 file changed

Lines changed: 30 additions & 14 deletions

File tree

test/go-unit-tests.sh

Lines changed: 30 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -72,23 +72,39 @@ do
7272
sleep 2
7373
fi
7474

75-
# On macOS + Go 1.22 the cmd package test binary is sometimes produced
76-
# without LC_UUID and the dynamic linker aborts with "missing LC_UUID".
77-
# Standard `go test` fails. Build explicitly and force-codesign the binary.
75+
# On macOS the cmd package test binary produced by Go 1.22 (and sometimes
76+
# other versions) on GitHub runners lacks LC_UUID, causing:
77+
# dyld: missing LC_UUID load command
78+
# signal: abort trap
79+
# We build explicitly, try both CGO_ENABLED values, codesign, and run.
80+
# Never skip the package on macOS.
7881
if [ "$(uname -s)" = "Darwin" ] && [ "$dir" = "cmd" ]; then
79-
echo "# macOS special handling for cmd package (build + codesign)"
80-
TESTBIN=$(mktemp -t dbdeployer_cmd_test.XXXXXX)
81-
if CGO_ENABLED=1 go test -c -o "$TESTBIN" -count=1 . 2>&1; then
82-
codesign --force --deep --sign - "$TESTBIN" 2>/dev/null || true
83-
if "$TESTBIN" -test.v -test.timeout=30m; then
84-
rm -f "$TESTBIN"
85-
test_rc=0
82+
echo "# macOS special handling for cmd package (build + codesign + CGO variants)"
83+
test_rc=1
84+
for cgo in 0 1; do
85+
echo "# trying CGO_ENABLED=$cgo for cmd test binary"
86+
TESTBIN=$(mktemp -t dbdeployer_cmd_test.XXXXXX 2>/dev/null || mktemp)
87+
rm -f "$TESTBIN" 2>/dev/null || true
88+
if CGO_ENABLED=$cgo go test -c -o "$TESTBIN" -count=1 . 2>&1; then
89+
codesign --force --deep --sign - "$TESTBIN" 2>/dev/null || true
90+
if "$TESTBIN" -test.v -test.timeout=30m 2>&1; then
91+
echo "# cmd tests passed with CGO_ENABLED=$cgo"
92+
rm -f "$TESTBIN" 2>/dev/null || true
93+
test_rc=0
94+
break
95+
else
96+
rc=$?
97+
echo "# run of cmd test binary (CGO=$cgo) exited $rc"
98+
rm -f "$TESTBIN" 2>/dev/null || true
99+
test_rc=$rc
100+
fi
86101
else
87-
test_rc=$?
88-
rm -f "$TESTBIN"
102+
echo "# build of cmd test binary with CGO_ENABLED=$cgo failed"
103+
test_rc=1
89104
fi
90-
else
91-
test_rc=1
105+
done
106+
if [ $test_rc -ne 0 ]; then
107+
echo "# WARNING: cmd package tests failed on macOS after all workarounds (known toolchain LC_UUID issue on some Go 1.22 images)"
92108
fi
93109
else
94110
go test -v -timeout 30m -count=1

0 commit comments

Comments
 (0)