Allow running external tests against installed rgbds (#1621)

This commit is contained in:
robbi-blechdose
2025-01-21 19:43:31 +01:00
committed by GitHub
parent 056190413e
commit 82f7bdb480

View File

@@ -13,7 +13,9 @@ usage() {
# Parse options in pure Bash because macOS `getopt` is stuck # Parse options in pure Bash because macOS `getopt` is stuck
# in what util-linux `getopt` calls `GETOPT_COMPATIBLE` mode # in what util-linux `getopt` calls `GETOPT_COMPATIBLE` mode
installedrgbds=false
nonfree=true nonfree=true
internal=true
external=true external=true
FETCH_TEST_DEPS="fetch-test-deps.sh" FETCH_TEST_DEPS="fetch-test-deps.sh"
while [[ $# -gt 0 ]]; do while [[ $# -gt 0 ]]; do
@@ -30,6 +32,12 @@ while [[ $# -gt 0 ]]; do
external=false external=false
FETCH_TEST_DEPS="$FETCH_TEST_DEPS --only-internal" FETCH_TEST_DEPS="$FETCH_TEST_DEPS --only-internal"
;; ;;
--only-external)
internal=false
;;
--installed-rgbds)
installedrgbds=true
;;
--) --)
break break
;; ;;
@@ -41,19 +49,38 @@ while [[ $# -gt 0 ]]; do
shift shift
done done
# Refuse to run if RGBDS isn't present if ! ("$external" || "$internal"); then
if [[ ! ( -x ../rgbasm && -x ../rgblink && -x ../rgbfix && -x ../rgbgfx ) ]]; then echo "No tests to run."
echo "Please build RGBDS before running the tests"
false false
fi fi
# Tests included with the repository if "$internal" && "$installedrgbds"; then
echo "Internal tests don't support running with the system-installed rgbds."
false
fi
for dir in asm link fix gfx; do if "$installedrgbds"; then
pushd $dir # Refuse to run if RGBDS isn't installed
./test.sh if ! (command -v rgbasm 2>&1 >/dev/null && command -v rgblink 2>&1 >/dev/null && command -v rgbfix 2>&1 >/dev/null && command -v rgbgfx 2>&1 >/dev/null); then
popd echo "Please install RGBDS before running the tests"
done false
fi
else
# Refuse to run if RGBDS isn't present
if [[ ! ( -x ../rgbasm && -x ../rgblink && -x ../rgbfix && -x ../rgbgfx ) ]]; then
echo "Please build RGBDS before running the tests"
false
fi
fi
# Tests included with the repository
if "$internal"; then
for dir in asm link fix gfx; do
pushd $dir
./test.sh
popd
done
fi
if ! "$external"; then if ! "$external"; then
exit exit
@@ -69,8 +96,13 @@ test_downstream() { # owner repo make-target build-file build-hash
echo >&2 'Please run `'"$FETCH_TEST_DEPS"'` before running the test suite' echo >&2 'Please run `'"$FETCH_TEST_DEPS"'` before running the test suite'
return 1 return 1
fi fi
make clean RGBDS=../../ if "$installedrgbds"; then
make -j4 "$3" RGBDS=../../ make clean
make -j4 "$3"
else
make clean RGBDS=../../
make -j4 "$3" RGBDS=../../
fi
hash="$(sha1sum -b "$4" | head -c 40)" hash="$(sha1sum -b "$4" | head -c 40)"
if [ "$hash" != "$5" ]; then if [ "$hash" != "$5" ]; then
echo >&2 'SHA-1 hash of '"$4"' did not match: '"$hash" echo >&2 'SHA-1 hash of '"$4"' did not match: '"$hash"