From afca9d58f871cc6b609062c60e3652246c65c272 Mon Sep 17 00:00:00 2001 From: speak-agent <248744407+speak-agent@users.noreply.github.com> Date: Mon, 10 Aug 2026 10:12:05 +0800 Subject: [PATCH] test(e2e): stop the wine teardown from failing a passing test MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit `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. --- tests/e2e/102_mingw_cross_wine.sh | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/tests/e2e/102_mingw_cross_wine.sh b/tests/e2e/102_mingw_cross_wine.sh index 2993fc06..590ac7ca 100644 --- a/tests/e2e/102_mingw_cross_wine.sh +++ b/tests/e2e/102_mingw_cross_wine.sh @@ -9,7 +9,28 @@ set -e TMP=$(mktemp -d) -trap "rm -rf $TMP" EXIT + +# `wine` leaves a wineserver running after the process it launched exits, and +# that server keeps writing into $WINEPREFIX. A plain `rm -rf` in the EXIT trap +# therefore races it and can fail with "Directory not empty" — AFTER the test +# has already printed OK. Under `set -e` that failing trap becomes the script's +# exit status, so a passing test reports as a red job (observed on main at +# 0006ce6, run 31336526583: the log ends `OK` then `rm: cannot remove +# '…/wineprefix': Directory not empty`). +# +# So: shut the server down first and wait for it, and never let cleanup decide +# the verdict. By the time this runs the verdict is already printed; a failure +# to delete a temp directory is not a statement about mcpp. +cleanup() { + local status=$? + if [[ -n "${WINEPREFIX:-}" ]] && command -v wineserver >/dev/null 2>&1; then + wineserver -k >/dev/null 2>&1 || true + wineserver -w >/dev/null 2>&1 || true + fi + rm -rf "$TMP" 2>/dev/null || true + return $status +} +trap cleanup EXIT cd "$TMP" "$MCPP" new crosswin