Skip to content

Commit afca9d5

Browse files
committed
test(e2e): stop the wine teardown from failing a passing test
`cross-build-test` went red on main at 0006ce6 (run 31336526583) with a log that ends: OK rm: cannot remove '/tmp/tmp.XgyezkVtrY/wineprefix': Directory not empty The test passed. `wine` leaves a wineserver running after the process it launched exits, and that server keeps writing into $WINEPREFIX, so the EXIT trap's `rm -rf` races it. Under `set -e` the failing trap becomes the script's exit status, so a green test reports as a red job — and the verdict it reports is about a temp directory, not about mcpp. Shut the server down and wait for it before deleting, and let cleanup keep the status the test already earned. Cleanup runs after the verdict is printed; it has no business changing it.
1 parent 0006ce6 commit afca9d5

1 file changed

Lines changed: 22 additions & 1 deletion

File tree

tests/e2e/102_mingw_cross_wine.sh

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,28 @@
99
set -e
1010

1111
TMP=$(mktemp -d)
12-
trap "rm -rf $TMP" EXIT
12+
13+
# `wine` leaves a wineserver running after the process it launched exits, and
14+
# that server keeps writing into $WINEPREFIX. A plain `rm -rf` in the EXIT trap
15+
# therefore races it and can fail with "Directory not empty" — AFTER the test
16+
# has already printed OK. Under `set -e` that failing trap becomes the script's
17+
# exit status, so a passing test reports as a red job (observed on main at
18+
# 0006ce6, run 31336526583: the log ends `OK` then `rm: cannot remove
19+
# '…/wineprefix': Directory not empty`).
20+
#
21+
# So: shut the server down first and wait for it, and never let cleanup decide
22+
# the verdict. By the time this runs the verdict is already printed; a failure
23+
# to delete a temp directory is not a statement about mcpp.
24+
cleanup() {
25+
local status=$?
26+
if [[ -n "${WINEPREFIX:-}" ]] && command -v wineserver >/dev/null 2>&1; then
27+
wineserver -k >/dev/null 2>&1 || true
28+
wineserver -w >/dev/null 2>&1 || true
29+
fi
30+
rm -rf "$TMP" 2>/dev/null || true
31+
return $status
32+
}
33+
trap cleanup EXIT
1334
cd "$TMP"
1435

1536
"$MCPP" new crosswin

0 commit comments

Comments
 (0)