From 6cc4dd26add5bc1e7a849d207751c5b7d9d209b1 Mon Sep 17 00:00:00 2001 From: Simon Howard Date: Mon, 11 Nov 2019 19:40:20 -0500 Subject: [PATCH] Better cleanup; exit with error when appropriate. --- testrunner | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/testrunner b/testrunner index 20c6f9e..4cf0c2f 100755 --- a/testrunner +++ b/testrunner @@ -2,10 +2,14 @@ set -eu -tmp=$(mktemp -d) ORIGDIR=$PWD -cd "$tmp" +tmp=$(mktemp -d) +cleanup() { + rm -rf "$tmp" +} +trap cleanup EXIT +cd "$tmp" unzip -oq "$ORIGDIR/miniwad.zip" while [ $# -gt 1 ] && [ "$1" != "--" ]; do @@ -14,7 +18,7 @@ while [ $# -gt 1 ] && [ "$1" != "--" ]; do done if [ "$1" != "--" ]; then echo "ZIP list not terminated with --." >>/dev/stderr - rm -rf "$tmp" + exit 1 fi shift @@ -22,16 +26,15 @@ SDL_VIDEODRIVER=dummy export SDL_VIDEODRIVER $SOURCE_PORT -iwad miniwad.wad \ - -mb 32 \ + -mb 24 \ -nodraw -noblit -nosound -noautoload -nogui -nograbmouse \ -statdump statdump.txt \ - "$@" >log.txt 2>errs.txt || true + "$@" >log.txt 2>&1 || true if [ ! -e statdump.txt ]; then - (echo "No statdump output produced."; - cat log.txt; cat errs.txt) >/dev/stderr + (echo "No statdump output produced."; cat log.txt) >/dev/stderr + exit 1 else cat statdump.txt fi -rm -rf "$tmp"