mirror of
https://github.com/gbdev/rgbds.git
synced 2026-09-22 13:47:05 +00:00
Some shell script style improvements (#2087)
* Escape special characters in filenames when comparing gfx .err output * Use `if` instead of `&&` * Use `case` instead of `if` disjunction --------- Co-authored-by: Eldred Habert <[email protected]>
This commit is contained in:
+3
-3
@@ -90,9 +90,9 @@ for i in *.asm notexist.asm; do
|
||||
# "make-deps.asm" refers to its output filename in its desired output.
|
||||
# "notexist.asm" doesn't exist, so there's no point in trying to `cat` it.
|
||||
# Skip testing with stdin input for those files.
|
||||
if [[ "$i" = include-recursion.asm || "$i" = make-deps.asm || "$i" = notexist.asm ]]; then
|
||||
continue
|
||||
fi
|
||||
case "$i" in
|
||||
include-recursion.asm | make-deps.asm | notexist.asm) continue;;
|
||||
esac
|
||||
|
||||
# shellcheck disable=SC2002 # (This use of `cat` intentionally makes the input an unseekable pipe.)
|
||||
cat "$i" | "$RGBASM" "${RGBASMFLAGS[@]}" -o "$o" - >"$output" 2>"$errput"
|
||||
|
||||
+20
-11
@@ -74,14 +74,17 @@ done
|
||||
|
||||
for f in *.png; do
|
||||
# Do not process outputs or palette inputs of other tests as test inputs themselves
|
||||
if [[ "$f" = result.png ]] || [[ "$f" = *.pal.png ]]; then
|
||||
continue
|
||||
fi
|
||||
case "$f" in
|
||||
result.png | *.pal.png) continue;;
|
||||
esac
|
||||
|
||||
flags="$([[ -e "${f%.png}.flags" ]] && echo "@${f%.png}.flags")"
|
||||
flags=
|
||||
if [[ -e "${f%.png}.flags" ]]; then
|
||||
flags="@${f%.png}.flags"
|
||||
fi
|
||||
for f_ext in o_1bpp o_2bpp p_pal t_tilemap a_attrmap q_palmap; do
|
||||
if [[ -e "${f%.png}.out.${f_ext#*_}" ]]; then
|
||||
flags="$flags -${f_ext%_*} result.${f_ext#*_}"
|
||||
flags+=" -${f_ext%_*} result.${f_ext#*_}"
|
||||
fi
|
||||
done
|
||||
|
||||
@@ -96,7 +99,7 @@ for f in *.png; do
|
||||
newTest "$RGBGFX" $flags - "<$f"
|
||||
if [[ -e "${f%.png}.err" ]]; then
|
||||
runTest 2>"$errtmp"
|
||||
diff -au --strip-trailing-cr <(sed "s/$f/<stdin>/g" "${f%.png}.err") "$errtmp" || failTest
|
||||
diff -au --strip-trailing-cr "${f%.png}.err" <(sed "s#<stdin>#${f//#/\\#}#g" "$errtmp") || failTest
|
||||
else
|
||||
runTest && checkOutput "${f%.png}" || failTest $?
|
||||
fi
|
||||
@@ -104,16 +107,22 @@ done
|
||||
|
||||
for f in *.[12]bpp; do
|
||||
# Do not process outputs or sample outputs of other tests as test inputs themselves
|
||||
if [[ "$f" = result.[12]bpp ]] || [[ "$f" = *.in.[12]bpp ]] || [[ "$f" = *.out.[12]bpp ]]; then
|
||||
continue
|
||||
fi
|
||||
case "$f" in
|
||||
result.[12]bpp | *.in.[12]bpp | *.out.[12]bpp) continue;;
|
||||
esac
|
||||
|
||||
flags="$([[ -e "${f%.[12]bpp}.flags" ]] && echo "@${f%.[12]bpp}.flags") $([[ -e "${f%.1bpp}.flags" ]] && echo "-d 1")"
|
||||
flags=
|
||||
if [[ -e "${f%.[12]bpp}.flags" ]]; then
|
||||
flags="@${f%.[12]bpp}.flags"
|
||||
if [[ -e "${f%.1bpp}.flags" ]]; then
|
||||
flags="$flags -d 1"
|
||||
fi
|
||||
fi
|
||||
|
||||
if [[ -e "${f%.[12]bpp}.err" ]]; then
|
||||
newTest "$RGBGFX $flags -o $f -r 1 result.png"
|
||||
runTest 2>"$errtmp"
|
||||
diff -au --strip-trailing-cr <(sed "s/$f/<stdin>/g" "${f%.[12]bpp}.err") "$errtmp" || failTest
|
||||
diff -au --strip-trailing-cr "${f%.[12]bpp}.err" <(sed "s#<stdin>#${f//#/\\#}#g" "$errtmp") || failTest
|
||||
else
|
||||
newTest "$RGBGFX $flags -o $f -r 1 result.png && $RGBGFX $flags -o result.2bpp result.png"
|
||||
runTest && tryCmp "$f" result.2bpp || failTest $?
|
||||
|
||||
Reference in New Issue
Block a user