mirror of
https://github.com/gbdev/rgbds.git
synced 2026-08-30 18:45:17 +00:00
Use Bash arrays instead of POSIX splitting when possible
This commit is contained in:
@@ -28,12 +28,12 @@ while [[ $# -gt 0 ]]; do
|
|||||||
;;
|
;;
|
||||||
--jobs)
|
--jobs)
|
||||||
shift
|
shift
|
||||||
make_args+=("-j" "$1")
|
make_args+=(-j "$1")
|
||||||
runtests_args+=("--jobs" "$1")
|
runtests_args+=(--jobs "$1")
|
||||||
;;
|
;;
|
||||||
--os)
|
--os)
|
||||||
shift
|
shift
|
||||||
runtests_args+=("--os" "$1")
|
runtests_args+=(--os "$1")
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
echo "$(basename "$0"): unknown option '$1'"
|
echo "$(basename "$0"): unknown option '$1'"
|
||||||
|
|||||||
+12
-12
@@ -61,9 +61,9 @@ else
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
for i in *.asm notexist.asm; do
|
for i in *.asm notexist.asm; do
|
||||||
RGBASMFLAGS="-Weverything -Bcollapse"
|
RGBASMFLAGS=(-Weverything -Bcollapse)
|
||||||
if [ -f "${i%.asm}.flags" ]; then
|
if [ -f "${i%.asm}.flags" ]; then
|
||||||
RGBASMFLAGS="$RGBASMFLAGS @${i%.asm}.flags"
|
RGBASMFLAGS+=("@${i%.asm}.flags")
|
||||||
fi
|
fi
|
||||||
for variant in '' ' piped'; do
|
for variant in '' ' piped'; do
|
||||||
(( tests++ ))
|
(( tests++ ))
|
||||||
@@ -79,7 +79,7 @@ for i in *.asm notexist.asm; do
|
|||||||
desired_errname=/dev/null
|
desired_errname=/dev/null
|
||||||
fi
|
fi
|
||||||
if [ -z "$variant" ]; then
|
if [ -z "$variant" ]; then
|
||||||
"$RGBASM" $RGBASMFLAGS -o "$o" "$i" >"$output" 2>"$errput"
|
"$RGBASM" "${RGBASMFLAGS[@]}" -o "$o" "$i" >"$output" 2>"$errput"
|
||||||
desired_output=$desired_outname
|
desired_output=$desired_outname
|
||||||
desired_errput=$desired_errname
|
desired_errput=$desired_errname
|
||||||
else
|
else
|
||||||
@@ -96,7 +96,7 @@ for i in *.asm notexist.asm; do
|
|||||||
# that's harder to deal with and was broken when the feature was
|
# that's harder to deal with and was broken when the feature was
|
||||||
# first implemented.
|
# first implemented.
|
||||||
# shellcheck disable=SC2002
|
# shellcheck disable=SC2002
|
||||||
cat "$i" | "$RGBASM" $RGBASMFLAGS -o "$o" - >"$output" 2>"$errput"
|
cat "$i" | "$RGBASM" "${RGBASMFLAGS[@]}" -o "$o" - >"$output" 2>"$errput"
|
||||||
|
|
||||||
# Use two otherwise unused files for temp storage
|
# Use two otherwise unused files for temp storage
|
||||||
desired_output="$input"
|
desired_output="$input"
|
||||||
@@ -162,10 +162,10 @@ done
|
|||||||
# These tests do their own thing
|
# These tests do their own thing
|
||||||
|
|
||||||
i="invalid-source-date-epoch"
|
i="invalid-source-date-epoch"
|
||||||
RGBASMFLAGS="-Weverything -Bcollapse"
|
RGBASMFLAGS=(-Weverything -Bcollapse)
|
||||||
(( tests++ ))
|
(( tests++ ))
|
||||||
echo "${bold}${green}${i}...${rescolors}${resbold}"
|
echo "${bold}${green}${i}...${rescolors}${resbold}"
|
||||||
SOURCE_DATE_EPOCH=0x1234 "$RGBASM" $RGBASMFLAGS /dev/null >"$output" 2>"$errput"
|
SOURCE_DATE_EPOCH=0x1234 "$RGBASM" "${RGBASMFLAGS[@]}" /dev/null >"$output" 2>"$errput"
|
||||||
tryDiff /dev/null "$output" out
|
tryDiff /dev/null "$output" out
|
||||||
our_rc=$?
|
our_rc=$?
|
||||||
tryDiff invalid-source-date-epoch.err "$errput" err
|
tryDiff invalid-source-date-epoch.err "$errput" err
|
||||||
@@ -177,15 +177,15 @@ fi
|
|||||||
|
|
||||||
evaluateDepTest () {
|
evaluateDepTest () {
|
||||||
i="$1"
|
i="$1"
|
||||||
RGBASMFLAGS="-Weverything -Bcollapse -M -"
|
RGBASMFLAGS=(-Weverything -Bcollapse -M -)
|
||||||
if [ -f "$i/a.flags" ]; then
|
if [ -f "$i/a.flags" ]; then
|
||||||
RGBASMFLAGS="$RGBASMFLAGS @$i/a.flags"
|
RGBASMFLAGS+=("@$i/a.flags")
|
||||||
fi
|
fi
|
||||||
# Piping the .asm file to rgbasm would not make sense for dependency generation,
|
# Piping the .asm file to rgbasm would not make sense for dependency generation,
|
||||||
# so just test the normal variant
|
# so just test the normal variant
|
||||||
(( tests++ ))
|
(( tests++ ))
|
||||||
echo "${bold}${green}${i}...${rescolors}${resbold}"
|
echo "${bold}${green}${i}...${rescolors}${resbold}"
|
||||||
"$RGBASM" $RGBASMFLAGS -o "$o" "$i"/a.asm >"$output" 2>"$errput"
|
"$RGBASM" "${RGBASMFLAGS[@]}" -o "$o" "$i"/a.asm >"$output" 2>"$errput"
|
||||||
|
|
||||||
fixed_output="$input"
|
fixed_output="$input"
|
||||||
if type -t cygpath >/dev/null; then
|
if type -t cygpath >/dev/null; then
|
||||||
@@ -223,15 +223,15 @@ else
|
|||||||
state_outname="$o"
|
state_outname="$o"
|
||||||
fi
|
fi
|
||||||
state_features=" all " # Test trimming whitespace
|
state_features=" all " # Test trimming whitespace
|
||||||
RGBASMFLAGS="-Weverything -Bcollapse"
|
RGBASMFLAGS=(-Weverything -Bcollapse)
|
||||||
for variant in '' '.pipe'; do
|
for variant in '' '.pipe'; do
|
||||||
(( tests++ ))
|
(( tests++ ))
|
||||||
echo "${bold}${green}${i%.asm}${variant}...${rescolors}${resbold}"
|
echo "${bold}${green}${i%.asm}${variant}...${rescolors}${resbold}"
|
||||||
if [ -z "$variant" ]; then
|
if [ -z "$variant" ]; then
|
||||||
"$RGBASM" $RGBASMFLAGS -s "$state_features:$state_outname" "$i"/a.asm >"$output" 2>"$errput"
|
"$RGBASM" "${RGBASMFLAGS[@]}" -s "$state_features:$state_outname" "$i"/a.asm >"$output" 2>"$errput"
|
||||||
else
|
else
|
||||||
# shellcheck disable=SC2002
|
# shellcheck disable=SC2002
|
||||||
cat "$i"/a.asm | "$RGBASM" $RGBASMFLAGS -s "$state_features:$state_outname" - >"$output" 2>"$errput"
|
cat "$i"/a.asm | "$RGBASM" "${RGBASMFLAGS[@]}" -s "$state_features:$state_outname" - >"$output" 2>"$errput"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
tryDiff /dev/null "$output" out
|
tryDiff /dev/null "$output" out
|
||||||
|
|||||||
+6
-6
@@ -93,9 +93,9 @@ for i in *.asm; do
|
|||||||
startTest
|
startTest
|
||||||
"$RGBASM" -o "$otemp" "${test}.asm"
|
"$RGBASM" -o "$otemp" "${test}.asm"
|
||||||
|
|
||||||
RGBLINKFLAGS=""
|
RGBLINKFLAGS=()
|
||||||
if [ -f "${test}.flags" ]; then
|
if [ -f "${test}.flags" ]; then
|
||||||
RGBLINKFLAGS="$RGBLINKFLAGS @${test}.flags"
|
RGBLINKFLAGS+=("@${test}.flags")
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Some tests have variants depending on flags
|
# Some tests have variants depending on flags
|
||||||
@@ -103,14 +103,14 @@ for i in *.asm; do
|
|||||||
for flag in '-d' '-t' '-w'; do
|
for flag in '-d' '-t' '-w'; do
|
||||||
if [ -f "${test}-no${flag}.out" ]; then
|
if [ -f "${test}-no${flag}.out" ]; then
|
||||||
continueTest "-no${flag}"
|
continueTest "-no${flag}"
|
||||||
rgblinkQuiet $RGBLINKFLAGS -o "$gbtemp" "$otemp" 2>"$outtemp"
|
rgblinkQuiet "${RGBLINKFLAGS[@]}" -o "$gbtemp" "$otemp" 2>"$outtemp"
|
||||||
tryDiff "${test}-no${flag}.out" "$outtemp"
|
tryDiff "${test}-no${flag}.out" "$outtemp"
|
||||||
evaluateTest
|
evaluateTest
|
||||||
ran_flag=true
|
ran_flag=true
|
||||||
fi
|
fi
|
||||||
if [ -f "${test}${flag}.out" ]; then
|
if [ -f "${test}${flag}.out" ]; then
|
||||||
continueTest "$flag"
|
continueTest "$flag"
|
||||||
rgblinkQuiet $RGBLINKFLAGS ${flag} -o "$gbtemp" "$otemp" 2>"$outtemp"
|
rgblinkQuiet "${RGBLINKFLAGS[@]}" ${flag} -o "$gbtemp" "$otemp" 2>"$outtemp"
|
||||||
tryDiff "${test}${flag}.out" "$outtemp"
|
tryDiff "${test}${flag}.out" "$outtemp"
|
||||||
evaluateTest
|
evaluateTest
|
||||||
ran_flag=true
|
ran_flag=true
|
||||||
@@ -125,7 +125,7 @@ for i in *.asm; do
|
|||||||
[[ -e "$script" ]] || break # If the glob doesn't match, it just... doesn't expand!
|
[[ -e "$script" ]] || break # If the glob doesn't match, it just... doesn't expand!
|
||||||
|
|
||||||
continueTest "${script#${test}}"
|
continueTest "${script#${test}}"
|
||||||
rgblinkQuiet $RGBLINKFLAGS -l "$script" -o "$gbtemp" "$otemp" 2>"$outtemp"
|
rgblinkQuiet "${RGBLINKFLAGS[@]}" -l "$script" -o "$gbtemp" "$otemp" 2>"$outtemp"
|
||||||
tryDiff "${script%.link}.out" "$outtemp"
|
tryDiff "${script%.link}.out" "$outtemp"
|
||||||
evaluateTest
|
evaluateTest
|
||||||
ran_flag=true
|
ran_flag=true
|
||||||
@@ -136,7 +136,7 @@ for i in *.asm; do
|
|||||||
|
|
||||||
# The rest of the tests just links a file, and maybe checks the binary
|
# The rest of the tests just links a file, and maybe checks the binary
|
||||||
continueTest
|
continueTest
|
||||||
rgblinkQuiet $RGBLINKFLAGS -o "$gbtemp" "$otemp" 2>"$outtemp"
|
rgblinkQuiet "${RGBLINKFLAGS[@]}" -o "$gbtemp" "$otemp" 2>"$outtemp"
|
||||||
tryDiff "${test}.out" "$outtemp"
|
tryDiff "${test}.out" "$outtemp"
|
||||||
bin=${test}.out.bin
|
bin=${test}.out.bin
|
||||||
if [ -f "$bin" ]; then
|
if [ -f "$bin" ]; then
|
||||||
|
|||||||
Reference in New Issue
Block a user