mirror of
https://github.com/gbdev/rgbds.git
synced 2025-11-20 10:12:06 +00:00
Fix shellcheck warnings in the test scripts
Making them more robust to changes. We ought to automate this some day. My version of ShellCheck (v0.9.0) errors on test/gfx/test.sh, though...
This commit is contained in:
@@ -7,8 +7,10 @@ src="$PWD"
|
||||
rc=0
|
||||
|
||||
cp ../../{rgbfix,contrib/gbdiff.bash} "$tmpdir"
|
||||
cd "$tmpdir"
|
||||
trap "cd; rm -rf '$tmpdir'" EXIT
|
||||
cd "$tmpdir" || exit
|
||||
# Immediate expansion is the desired behaviour.
|
||||
# shellcheck disable=SC2064
|
||||
trap "cd; rm -rf ${tmpdir@Q}" EXIT
|
||||
|
||||
bold="$(tput bold)"
|
||||
resbold="$(tput sgr0)"
|
||||
@@ -43,7 +45,7 @@ runTest () {
|
||||
fi
|
||||
if [[ -z "$variant" ]]; then
|
||||
cp "$2/$1.bin" out.gb
|
||||
if [[ -n "$(eval $RGBFIX $flags out.gb '2>out.err')" ]]; then
|
||||
if [[ -n "$(eval "$RGBFIX" $flags out.gb '2>out.err')" ]]; then
|
||||
echo "${bold}${red}Fixing $1 in-place shouldn't output anything on stdout!${rescolors}${resbold}"
|
||||
our_rc=1
|
||||
fi
|
||||
@@ -52,18 +54,19 @@ runTest () {
|
||||
# Stop! This is not a Useless Use Of Cat. Using cat instead of
|
||||
# stdin redirection makes the input an unseekable pipe - a scenario
|
||||
# that's harder to deal with.
|
||||
# shellcheck disable=SC2002
|
||||
cat "$2/$1.bin" | eval $RGBFIX "$flags" - '>out.gb' '2>out.err'
|
||||
subst='<stdin>'
|
||||
fi
|
||||
|
||||
sed "s/$subst/<filename>/g" "out.err" | tryDiff "$2/$1.err" - "$1.err${variant}"
|
||||
our_rc=$(($? || $our_rc))
|
||||
(( our_rc = our_rc || $? ))
|
||||
if [[ -r "$2/$1.gb" ]]; then
|
||||
tryCmp "$2/$1.gb" "out.gb" "$1.gb${variant}"
|
||||
our_rc=$(($? || $our_rc))
|
||||
(( our_rc = our_rc || $? ))
|
||||
fi
|
||||
|
||||
rc=$(($rc || $our_rc))
|
||||
(( rc = rc || our_rc ))
|
||||
if [[ $our_rc -ne 0 ]]; then break; fi
|
||||
done
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user