Free fork of NotProton: Windows Steam games in Mac Steam, on CodeWeavers' Wine and Apple's Game Porting Toolkit
Swift apple-silicond3dmetaldxmtdxvkgame-porting-toolkitgptkmac-gamingmacosmetalfxrosetta-2steamsteam-playwinewinecx
Merge pull request #774 from Ni-zav/fix/np-batch-failure-status-s20261024T1040Z-niz
A Hazy Reign Is Fluide544a35fe64e
diff --git a/Makefile b/Makefileindex 599311f..b993520 100644--- a/Makefile+++ b/Makefile@@ -117,6 +117,11 @@ cicheck:@if [ ! -f scripts/tests/cicheck.sh ]; then $(call SKIP,cicheck,scripts/tests/cicheck.sh); exit 0; fi; \sh scripts/tests/cicheck.sh+# Validate batch exit statuses without starting games.+.PHONY: np-test-batch-check+np-test-batch-check:+ @sh scripts/tests/np-test-batch.sh+.PHONY: seedcheckseedcheck:@if [ ! -f dylib/tests/seedcheck.sh ]; then $(call SKIP,seedcheck,dylib/tests/seedcheck.sh); exit 0; fi; \@@ -874,7 +879,7 @@ native-shim-tests:# and CI gate on one list. Each check runs even when an earlier one failed.# overlay-shim-tests is left out: it needs a Metal GPU and real frame timing.CI_CHECKS := mincheck l10ncheck \- sigcheck callscheck webpatch-fixtures peicon-fixtures panel-behavior spawn-env \+ sigcheck callscheck np-test-batch-check webpatch-fixtures peicon-fixtures panel-behavior spawn-env \activatecheck compatcheck compatsvc-check prefixstate-check shortcutcheck launch-shell envcheck \buildcheck settingscheck routecheck bridgecheck envpasscheck prefixnotecheck powernotecheck exitcheck gamedrivecheck launchercheck \seedcheck gamefixescheck versioncheck cicheck padcheck compat-reported-check np-native-tests native-shim-tests \diff --git a/scripts/np-test-batch.sh b/scripts/np-test-batch.shindex 1b2d212..21f59f3 100755--- a/scripts/np-test-batch.sh+++ b/scripts/np-test-batch.sh@@ -1,13 +1,33 @@#!/usr/bin/env bash# np-test-batch.sh <appid...> - run np-test-game.sh sequentially with --stop; prints a summary.# Extra args via NP_TEST_ARGS, e.g. NP_TEST_ARGS="--seconds 60 --backend dxvk".+# Exit status: 64 = no app IDs; 1 = any game failed or output was invalid;+# 0 = every game exited successfully and returned valid JSON.set -u[ $# -gt 0 ] || { echo "usage: $0 <appid...>" >&2; exit 64; }DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"# shellcheck disable=SC2206EXTRA=(${NP_TEST_ARGS:-})+failed=0for id in "$@"; doout="$("$DIR/np-test-game.sh" "$id" ${EXTRA[@]+"${EXTRA[@]}"} --stop)"- printf '%s\n' "$out" | jq -r '"\(.appid)\t\(.name)\t\(.backend)\t\(.verdict)\t\(.seconds_alive)s"'+ rc=$?+ if [ "$rc" -ne 0 ]; then+ echo "np-test-batch: game $id exited with status $rc" >&2+ failed=1+ fi+ if ! printf '%s\n' "$out" | jq -er '+ select(type == "object" and+ (.appid | type == "number") and+ (.name | type == "string") and+ (.backend | type == "string") and+ (.verdict | type == "string") and+ (.seconds_alive | type == "number"))+ | "\(.appid)\t\(.name)\t\(.backend)\t\(.verdict)\t\(.seconds_alive)s"+ '; then+ echo "np-test-batch: no valid result for game $id" >&2+ failed=1+ fisleep 5done+exit "$failed"diff --git a/scripts/tests/np-test-batch.sh b/scripts/tests/np-test-batch.shnew file mode 100644index 0000000..6fb8297--- /dev/null+++ b/scripts/tests/np-test-batch.sh@@ -0,0 +1,35 @@+#!/bin/sh+# Batch reports each game's verdict, but fails overall if a run or its JSON fails.+set -eu+root=$(cd "$(dirname "$0")/../.." && pwd)+work=$(mktemp -d) || exit 1+trap 'rm -rf "$work"' EXIT+cp "$root/scripts/np-test-batch.sh" "$work/np-test-batch.sh"+mkdir "$work/bin"+cat > "$work/np-test-game.sh" <<'SCRIPT'+#!/bin/sh+case " $* " in *" --stop "*) ;; *) exit 65 ;; esac+case "$1" in+ 1) printf '%s\n' '{"appid":1,"name":"One","backend":"dxmt","verdict":"running","seconds_alive":3}'; exit 0 ;;+ 2) printf '%s\n' '{"appid":2,"name":"Two","backend":"dxmt","verdict":"crashed","seconds_alive":2}'; exit 1 ;;+ 3) echo invalid-json; exit 2 ;;+ 4) printf '%s\n' '{"appid":4}'; exit 0 ;;+ *) exit 64 ;;+esac+SCRIPT+printf '#!/bin/sh\nexit 0\n' > "$work/bin/sleep"+chmod +x "$work/bin/sleep" "$work/np-test-game.sh"+export PATH="$work/bin:$PATH"+if ! bash "$work/np-test-batch.sh" 1 > "$work/out" 2> "$work/err"; then+ echo 'successful game should pass the batch' >&2; exit 1+fi+grep -qx "$(printf '1\tOne\tdxmt\trunning\t3s')" "$work/out"+if bash "$work/np-test-batch.sh" 1 2 3 4 > "$work/out" 2> "$work/err"; then+ echo 'failed game must fail the batch' >&2; exit 1+fi+grep -qx "$(printf '2\tTwo\tdxmt\tcrashed\t2s')" "$work/out"+grep -q 'game 2 exited with status 1' "$work/err"+grep -q 'game 3 exited with status 2' "$work/err"+grep -q 'no valid result for game 3' "$work/err"+grep -q 'no valid result for game 4' "$work/err"+echo 'np-test-batch: success, failure and invalid results checked'