mirror of
https://github.com/gbdev/rgbds.git
synced 2025-11-20 18:22:07 +00:00
Print summaries at the end of test.sh scripts
This commit is contained in:
@@ -10,6 +10,8 @@ gb="$(mktemp)"
|
|||||||
input="$(mktemp)"
|
input="$(mktemp)"
|
||||||
output="$(mktemp)"
|
output="$(mktemp)"
|
||||||
errput="$(mktemp)"
|
errput="$(mktemp)"
|
||||||
|
tests=0
|
||||||
|
failed=0
|
||||||
rc=0
|
rc=0
|
||||||
|
|
||||||
# Immediate expansion is the desired behavior.
|
# Immediate expansion is the desired behavior.
|
||||||
@@ -73,6 +75,7 @@ for i in *.asm; do
|
|||||||
RGBASMFLAGS="$(head -n 1 "$flags")" # Allow other lines to serve as comments
|
RGBASMFLAGS="$(head -n 1 "$flags")" # Allow other lines to serve as comments
|
||||||
fi
|
fi
|
||||||
for variant in '' '.pipe'; do
|
for variant in '' '.pipe'; do
|
||||||
|
(( tests++ ))
|
||||||
echo "${bold}${green}${i%.asm}${variant}...${rescolors}${resbold}"
|
echo "${bold}${green}${i%.asm}${variant}...${rescolors}${resbold}"
|
||||||
if [ -e "${i%.asm}.out" ]; then
|
if [ -e "${i%.asm}.out" ]; then
|
||||||
desired_outname=${i%.asm}.out
|
desired_outname=${i%.asm}.out
|
||||||
@@ -129,8 +132,17 @@ for i in *.asm; do
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
(( rc = rc || our_rc ))
|
(( rc = rc || our_rc ))
|
||||||
if [ $our_rc -ne 0 ]; then break; fi
|
if [[ $our_rc -ne 0 ]]; then
|
||||||
|
(( failed++ ))
|
||||||
|
break
|
||||||
|
fi
|
||||||
done
|
done
|
||||||
done
|
done
|
||||||
|
|
||||||
|
if [[ "$failed" -eq 0 ]]; then
|
||||||
|
echo "${bold}${green}All ${tests} tests passed!${rescolors}${resbold}"
|
||||||
|
else
|
||||||
|
echo "${bold}${red}${failed} of the tests failed!${rescolors}${resbold}"
|
||||||
|
fi
|
||||||
|
|
||||||
exit $rc
|
exit $rc
|
||||||
|
|||||||
@@ -4,6 +4,8 @@ export LC_ALL=C
|
|||||||
|
|
||||||
tmpdir="$(mktemp -d)"
|
tmpdir="$(mktemp -d)"
|
||||||
src="$PWD"
|
src="$PWD"
|
||||||
|
tests=0
|
||||||
|
failed=0
|
||||||
rc=0
|
rc=0
|
||||||
|
|
||||||
cp ../../{rgbfix,contrib/gbdiff.bash} "$tmpdir"
|
cp ../../{rgbfix,contrib/gbdiff.bash} "$tmpdir"
|
||||||
@@ -39,6 +41,7 @@ runTest () {
|
|||||||
flags="$(head -n 1 "$2/$1.flags")" # Allow other lines to serve as comments
|
flags="$(head -n 1 "$2/$1.flags")" # Allow other lines to serve as comments
|
||||||
|
|
||||||
for variant in '' ' piped'; do
|
for variant in '' ' piped'; do
|
||||||
|
(( tests++ ))
|
||||||
our_rc=0
|
our_rc=0
|
||||||
if [[ $progress -ne 0 ]]; then
|
if [[ $progress -ne 0 ]]; then
|
||||||
echo "${bold}${green}$1${variant}...${rescolors}${resbold}"
|
echo "${bold}${green}$1${variant}...${rescolors}${resbold}"
|
||||||
@@ -67,7 +70,10 @@ runTest () {
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
(( rc = rc || our_rc ))
|
(( rc = rc || our_rc ))
|
||||||
if [[ $our_rc -ne 0 ]]; then break; fi
|
if [[ $our_rc -ne 0 ]]; then
|
||||||
|
(( failed++ ))
|
||||||
|
break
|
||||||
|
fi
|
||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -102,4 +108,11 @@ rc=$((rc || $? != 1))
|
|||||||
tryDiff "$src/noexist.err" out.err noexist.err
|
tryDiff "$src/noexist.err" out.err noexist.err
|
||||||
rc=$((rc || $?))
|
rc=$((rc || $?))
|
||||||
|
|
||||||
|
|
||||||
|
if [[ "$failed" -eq 0 ]]; then
|
||||||
|
echo "${bold}${green}All ${tests} tests passed!${rescolors}${resbold}"
|
||||||
|
else
|
||||||
|
echo "${bold}${red}${failed} of the tests failed!${rescolors}${resbold}"
|
||||||
|
fi
|
||||||
|
|
||||||
exit $rc
|
exit $rc
|
||||||
|
|||||||
@@ -14,16 +14,21 @@ rescolors="$(tput op)"
|
|||||||
|
|
||||||
RGBGFX=../../rgbgfx
|
RGBGFX=../../rgbgfx
|
||||||
|
|
||||||
|
tests=0
|
||||||
|
failed=0
|
||||||
rc=0
|
rc=0
|
||||||
|
|
||||||
new_test() {
|
new_test() {
|
||||||
cmdline="$*"
|
cmdline="$*"
|
||||||
echo "${bold}${green}Testing: ${cmdline}${rescolors}${resbold}" >&2
|
echo "${bold}${green}Testing: ${cmdline}${rescolors}${resbold}" >&2
|
||||||
}
|
}
|
||||||
test() {
|
test() {
|
||||||
|
(( tests++ ))
|
||||||
eval "$cmdline"
|
eval "$cmdline"
|
||||||
}
|
}
|
||||||
fail() {
|
fail() {
|
||||||
rc=1
|
rc=1
|
||||||
|
(( failed++ ))
|
||||||
echo "${bold}${red}Test ${cmdline} failed!${1:+ (RC=$1)}${rescolors}${resbold}"
|
echo "${bold}${red}Test ${cmdline} failed!${1:+ (RC=$1)}${rescolors}${resbold}"
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -69,4 +74,10 @@ for f in *.png; do
|
|||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
|
||||||
|
if [[ "$failed" -eq 0 ]]; then
|
||||||
|
echo "${bold}${green}All ${tests} tests passed!${rescolors}${resbold}"
|
||||||
|
else
|
||||||
|
echo "${bold}${red}${failed} of the tests failed!${rescolors}${resbold}"
|
||||||
|
fi
|
||||||
|
|
||||||
exit $rc
|
exit $rc
|
||||||
|
|||||||
@@ -7,6 +7,8 @@ otemp="$(mktemp)"
|
|||||||
gbtemp="$(mktemp)"
|
gbtemp="$(mktemp)"
|
||||||
gbtemp2="$(mktemp)"
|
gbtemp2="$(mktemp)"
|
||||||
outtemp="$(mktemp)"
|
outtemp="$(mktemp)"
|
||||||
|
tests=0
|
||||||
|
failed=0
|
||||||
rc=0
|
rc=0
|
||||||
|
|
||||||
# Immediate expansion is the desired behavior.
|
# Immediate expansion is the desired behavior.
|
||||||
@@ -27,6 +29,8 @@ startTest () {
|
|||||||
}
|
}
|
||||||
|
|
||||||
continueTest () {
|
continueTest () {
|
||||||
|
(( tests++ ))
|
||||||
|
our_rc=0
|
||||||
echo "${bold}${green}${i%.asm}$1...${rescolors}${resbold}"
|
echo "${bold}${green}${i%.asm}$1...${rescolors}${resbold}"
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -35,6 +39,7 @@ tryDiff () {
|
|||||||
echo "${bold}${red}$1 mismatch!${rescolors}${resbold}"
|
echo "${bold}${red}$1 mismatch!${rescolors}${resbold}"
|
||||||
false
|
false
|
||||||
fi
|
fi
|
||||||
|
(( our_rc = our_rc || $? ))
|
||||||
}
|
}
|
||||||
|
|
||||||
tryCmp () {
|
tryCmp () {
|
||||||
@@ -43,6 +48,7 @@ tryCmp () {
|
|||||||
echo "${bold}${red}${i%.asm}.out.bin mismatch!${rescolors}${resbold}"
|
echo "${bold}${red}${i%.asm}.out.bin mismatch!${rescolors}${resbold}"
|
||||||
false
|
false
|
||||||
fi
|
fi
|
||||||
|
(( our_rc = our_rc || $? ))
|
||||||
}
|
}
|
||||||
tryCmpRom () {
|
tryCmpRom () {
|
||||||
# `printf` lets us keep only the first returned word from `wc`.
|
# `printf` lets us keep only the first returned word from `wc`.
|
||||||
@@ -57,6 +63,7 @@ tryCmpRomSize () {
|
|||||||
echo "$bold${red}${i%.asm} binary size mismatch! ${rescolors}${resbold}"
|
echo "$bold${red}${i%.asm} binary size mismatch! ${rescolors}${resbold}"
|
||||||
false
|
false
|
||||||
fi
|
fi
|
||||||
|
(( our_rc = our_rc || $? ))
|
||||||
}
|
}
|
||||||
|
|
||||||
rgblinkQuiet () {
|
rgblinkQuiet () {
|
||||||
@@ -65,6 +72,14 @@ rgblinkQuiet () {
|
|||||||
echo "$bold${red}Linking shouldn't produce anything on stdout!${rescolors}${resbold}"
|
echo "$bold${red}Linking shouldn't produce anything on stdout!${rescolors}${resbold}"
|
||||||
false
|
false
|
||||||
fi
|
fi
|
||||||
|
(( our_rc = our_rc || $? ))
|
||||||
|
}
|
||||||
|
|
||||||
|
evaluateTest () {
|
||||||
|
if [[ "$our_rc" -ne 0 ]]; then
|
||||||
|
(( failed++ ))
|
||||||
|
rc=1
|
||||||
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
for i in *.asm; do
|
for i in *.asm; do
|
||||||
@@ -78,14 +93,14 @@ for i in *.asm; do
|
|||||||
continueTest "-no${flag}"
|
continueTest "-no${flag}"
|
||||||
rgblinkQuiet -o "$gbtemp" "$otemp" 2>"$outtemp"
|
rgblinkQuiet -o "$gbtemp" "$otemp" 2>"$outtemp"
|
||||||
tryDiff "${i%.asm}-no${flag}.out" "$outtemp"
|
tryDiff "${i%.asm}-no${flag}.out" "$outtemp"
|
||||||
(( rc = rc || $? ))
|
evaluateTest
|
||||||
ran_flag=true
|
ran_flag=true
|
||||||
fi
|
fi
|
||||||
if [ -f "${i%.asm}${flag}.out" ]; then
|
if [ -f "${i%.asm}${flag}.out" ]; then
|
||||||
continueTest "$flag"
|
continueTest "$flag"
|
||||||
rgblinkQuiet ${flag} -o "$gbtemp" "$otemp" 2>"$outtemp"
|
rgblinkQuiet ${flag} -o "$gbtemp" "$otemp" 2>"$outtemp"
|
||||||
tryDiff "${i%.asm}${flag}.out" "$outtemp"
|
tryDiff "${i%.asm}${flag}.out" "$outtemp"
|
||||||
(( rc = rc || $? ))
|
evaluateTest
|
||||||
ran_flag=true
|
ran_flag=true
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
@@ -100,7 +115,7 @@ for i in *.asm; do
|
|||||||
continueTest "${script#${i%.asm}}"
|
continueTest "${script#${i%.asm}}"
|
||||||
rgblinkQuiet -l "$script" -o "$gbtemp" "$otemp" 2>"$outtemp"
|
rgblinkQuiet -l "$script" -o "$gbtemp" "$otemp" 2>"$outtemp"
|
||||||
tryDiff "${script%.link}.out" "$outtemp"
|
tryDiff "${script%.link}.out" "$outtemp"
|
||||||
(( rc = rc || $? ))
|
evaluateTest
|
||||||
ran_flag=true
|
ran_flag=true
|
||||||
done
|
done
|
||||||
if "$ran_flag"; then
|
if "$ran_flag"; then
|
||||||
@@ -111,13 +126,11 @@ for i in *.asm; do
|
|||||||
continueTest
|
continueTest
|
||||||
rgblinkQuiet -o "$gbtemp" "$otemp" 2>"$outtemp"
|
rgblinkQuiet -o "$gbtemp" "$otemp" 2>"$outtemp"
|
||||||
tryDiff "${i%.asm}.out" "$outtemp"
|
tryDiff "${i%.asm}.out" "$outtemp"
|
||||||
(( rc = rc || $? ))
|
|
||||||
|
|
||||||
bin=${i%.asm}.out.bin
|
bin=${i%.asm}.out.bin
|
||||||
if [ -f "$bin" ]; then
|
if [ -f "$bin" ]; then
|
||||||
tryCmpRom "$bin"
|
tryCmpRom "$bin"
|
||||||
(( rc = rc || $? ))
|
|
||||||
fi
|
fi
|
||||||
|
evaluateTest
|
||||||
done
|
done
|
||||||
|
|
||||||
# These tests do their own thing
|
# These tests do their own thing
|
||||||
@@ -129,7 +142,7 @@ startTest
|
|||||||
continueTest
|
continueTest
|
||||||
rgblinkQuiet -o "$gbtemp" "$gbtemp2" "$otemp" 2>"$outtemp"
|
rgblinkQuiet -o "$gbtemp" "$gbtemp2" "$otemp" 2>"$outtemp"
|
||||||
tryDiff bank-const/out.err "$outtemp"
|
tryDiff bank-const/out.err "$outtemp"
|
||||||
(( rc = rc || $? ))
|
evaluateTest
|
||||||
|
|
||||||
for i in fragment-align/*; do
|
for i in fragment-align/*; do
|
||||||
startTest
|
startTest
|
||||||
@@ -138,11 +151,10 @@ for i in fragment-align/*; do
|
|||||||
continueTest
|
continueTest
|
||||||
rgblinkQuiet -o "$gbtemp" "$otemp" "$gbtemp2" 2>"$outtemp"
|
rgblinkQuiet -o "$gbtemp" "$otemp" "$gbtemp2" 2>"$outtemp"
|
||||||
tryDiff "$i"/out.err "$outtemp"
|
tryDiff "$i"/out.err "$outtemp"
|
||||||
(( rc = rc || $? ))
|
|
||||||
if [[ -f "$i"/out.gb ]]; then
|
if [[ -f "$i"/out.gb ]]; then
|
||||||
tryCmpRom "$i"/out.gb
|
tryCmpRom "$i"/out.gb
|
||||||
(( rc = rc || $? ))
|
|
||||||
fi
|
fi
|
||||||
|
evaluateTest
|
||||||
done
|
done
|
||||||
|
|
||||||
i="high-low.asm"
|
i="high-low.asm"
|
||||||
@@ -153,7 +165,7 @@ continueTest
|
|||||||
rgblinkQuiet -o "$gbtemp" "$otemp"
|
rgblinkQuiet -o "$gbtemp" "$otemp"
|
||||||
rgblinkQuiet -o "$gbtemp2" "$outtemp"
|
rgblinkQuiet -o "$gbtemp2" "$outtemp"
|
||||||
tryCmp "$gbtemp" "$gbtemp2"
|
tryCmp "$gbtemp" "$gbtemp2"
|
||||||
(( rc = rc || $? ))
|
evaluateTest
|
||||||
|
|
||||||
i="overlay.asm"
|
i="overlay.asm"
|
||||||
startTest
|
startTest
|
||||||
@@ -161,10 +173,9 @@ startTest
|
|||||||
continueTest
|
continueTest
|
||||||
rgblinkQuiet -o "$gbtemp" -t -O overlay/overlay.gb "$otemp" 2>"$outtemp"
|
rgblinkQuiet -o "$gbtemp" -t -O overlay/overlay.gb "$otemp" 2>"$outtemp"
|
||||||
tryDiff overlay/out.err "$outtemp"
|
tryDiff overlay/out.err "$outtemp"
|
||||||
(( rc = rc || $? ))
|
|
||||||
# This test does not trim its output with 'dd' because it needs to verify the correct output size
|
# This test does not trim its output with 'dd' because it needs to verify the correct output size
|
||||||
tryCmp overlay/out.gb "$gbtemp"
|
tryCmp overlay/out.gb "$gbtemp"
|
||||||
(( rc = rc || $? ))
|
evaluateTest
|
||||||
|
|
||||||
i="scramble-romx.asm"
|
i="scramble-romx.asm"
|
||||||
startTest
|
startTest
|
||||||
@@ -172,10 +183,9 @@ startTest
|
|||||||
continueTest
|
continueTest
|
||||||
rgblinkQuiet -o "$gbtemp" -S romx=3 "$otemp" 2>"$outtemp"
|
rgblinkQuiet -o "$gbtemp" -S romx=3 "$otemp" 2>"$outtemp"
|
||||||
tryDiff scramble-romx/out.err "$outtemp"
|
tryDiff scramble-romx/out.err "$outtemp"
|
||||||
(( rc = rc || $? ))
|
|
||||||
# This test does not compare its exact output with 'tryCmpRom' because no scrambling order is guaranteed
|
# This test does not compare its exact output with 'tryCmpRom' because no scrambling order is guaranteed
|
||||||
tryCmpRomSize "$gbtemp" 65536
|
tryCmpRomSize "$gbtemp" 65536
|
||||||
(( rc = rc || $? ))
|
evaluateTest
|
||||||
|
|
||||||
i="section-fragment/jr-offset.asm"
|
i="section-fragment/jr-offset.asm"
|
||||||
startTest
|
startTest
|
||||||
@@ -184,7 +194,7 @@ startTest
|
|||||||
continueTest
|
continueTest
|
||||||
rgblinkQuiet -o "$gbtemp" "$otemp" "$gbtemp2"
|
rgblinkQuiet -o "$gbtemp" "$otemp" "$gbtemp2"
|
||||||
tryCmpRom section-fragment/jr-offset/ref.out.bin
|
tryCmpRom section-fragment/jr-offset/ref.out.bin
|
||||||
(( rc = rc || $? ))
|
evaluateTest
|
||||||
|
|
||||||
i="section-union/good.asm"
|
i="section-union/good.asm"
|
||||||
startTest
|
startTest
|
||||||
@@ -193,7 +203,7 @@ startTest
|
|||||||
continueTest
|
continueTest
|
||||||
rgblinkQuiet -o "$gbtemp" -l section-union/good/script.link "$otemp" "$gbtemp2"
|
rgblinkQuiet -o "$gbtemp" -l section-union/good/script.link "$otemp" "$gbtemp2"
|
||||||
tryCmpRom section-union/good/ref.out.bin
|
tryCmpRom section-union/good/ref.out.bin
|
||||||
(( rc = rc || $? ))
|
evaluateTest
|
||||||
|
|
||||||
i="section-union/fragments.asm"
|
i="section-union/fragments.asm"
|
||||||
startTest
|
startTest
|
||||||
@@ -202,7 +212,7 @@ startTest
|
|||||||
continueTest
|
continueTest
|
||||||
rgblinkQuiet -o "$gbtemp" "$otemp" "$gbtemp2"
|
rgblinkQuiet -o "$gbtemp" "$otemp" "$gbtemp2"
|
||||||
tryCmpRom section-union/fragments/ref.out.bin
|
tryCmpRom section-union/fragments/ref.out.bin
|
||||||
(( rc = rc || $? ))
|
evaluateTest
|
||||||
|
|
||||||
for i in section-union/*.asm; do
|
for i in section-union/*.asm; do
|
||||||
startTest
|
startTest
|
||||||
@@ -211,13 +221,19 @@ for i in section-union/*.asm; do
|
|||||||
continueTest
|
continueTest
|
||||||
if rgblinkQuiet "$otemp" "$gbtemp2" 2>"$outtemp"; then
|
if rgblinkQuiet "$otemp" "$gbtemp2" 2>"$outtemp"; then
|
||||||
echo -e "${bold}${red}$i didn't fail to link!${rescolors}${resbold}"
|
echo -e "${bold}${red}$i didn't fail to link!${rescolors}${resbold}"
|
||||||
rc=1
|
our_rc=1
|
||||||
fi
|
fi
|
||||||
echo --- >>"$outtemp"
|
echo --- >>"$outtemp"
|
||||||
# Ensure RGBASM also errors out
|
# Ensure RGBASM also errors out
|
||||||
cat "$i" - "$i" <<<'def SECOND equs "1"' | "$RGBASM" - 2>>"$outtemp"
|
cat "$i" - "$i" <<<'def SECOND equs "1"' | "$RGBASM" - 2>>"$outtemp"
|
||||||
tryDiff "${i%.asm}.out" "$outtemp"
|
tryDiff "${i%.asm}.out" "$outtemp"
|
||||||
(( rc = rc || $? ))
|
evaluateTest
|
||||||
done
|
done
|
||||||
|
|
||||||
|
if [[ "$failed" -eq 0 ]]; then
|
||||||
|
echo "${bold}${green}All ${tests} tests passed!${rescolors}${resbold}"
|
||||||
|
else
|
||||||
|
echo "${bold}${red}${failed} of the tests failed!${rescolors}${resbold}"
|
||||||
|
fi
|
||||||
|
|
||||||
exit $rc
|
exit $rc
|
||||||
|
|||||||
Reference in New Issue
Block a user