From cb354f7de0338ff6034f616020d4edaf3dc77247 Mon Sep 17 00:00:00 2001 From: Robbi Blechdose Date: Tue, 21 Jan 2025 15:47:44 +0100 Subject: [PATCH 1/3] Added option to only run external tests, added option to use system-installed binaries --- man/gbz80.7 | 9 +++++++-- test/run-tests.sh | 46 ++++++++++++++++++++++++++++++++++------------ 2 files changed, 41 insertions(+), 14 deletions(-) diff --git a/man/gbz80.7 b/man/gbz80.7 index 17b332832..af70edb51 100644 --- a/man/gbz80.7 +++ b/man/gbz80.7 @@ -615,6 +615,9 @@ to the adjustment. .It Subtract the adjustment from .Sy A . +.It +Set the carry flag if borrow (i.e. if adjustment > +.Sy A ) . .El .It If the subtract flag Sy N No is not set: .Bl -enum -compact @@ -636,13 +639,15 @@ to the adjustment. If the carry flag is set or .Sy A > -.Ad $99 , +.Ad $9F , then add .Ad $60 -to the adjustment and set the carry flag. +to the adjustment. .It Add the adjustment to .Sy A . +.It +Set the carry flag if overflow from bit 7. .El .El .Pp diff --git a/test/run-tests.sh b/test/run-tests.sh index e29d3a601..b8eeacc69 100755 --- a/test/run-tests.sh +++ b/test/run-tests.sh @@ -13,7 +13,9 @@ usage() { # Parse options in pure Bash because macOS `getopt` is stuck # in what util-linux `getopt` calls `GETOPT_COMPATIBLE` mode +installedrgbds=false nonfree=true +internal=true external=true FETCH_TEST_DEPS="fetch-test-deps.sh" while [[ $# -gt 0 ]]; do @@ -29,6 +31,12 @@ while [[ $# -gt 0 ]]; do --only-internal) external=false ;; + --only-external) + internal=false + ;; + --installed-rgbds) + installedrgbds=true + ;; --) break ;; @@ -40,19 +48,28 @@ while [[ $# -gt 0 ]]; do shift done -# 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 +if "$installedrgbds"; then + # Refuse to run if RGBDS isn't installed + 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 + echo "Please install RGBDS before running the tests" + 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 - -for dir in asm link fix gfx; do - pushd $dir - ./test.sh - popd -done +if "$internal"; then + for dir in asm link fix gfx; do + pushd $dir + ./test.sh + popd + done +fi if ! "$external"; then exit @@ -68,8 +85,13 @@ test_downstream() { # owner repo make-target build-file build-hash echo >&2 'Please run `'"$FETCH_TEST_DEPS"'` before running the test suite' return 1 fi - make clean RGBDS=../../ - make -j4 "$3" RGBDS=../../ + if "$installedrgbds"; then + make clean + make -j4 "$3" + else + make clean RGBDS=../../ + make -j4 "$3" RGBDS=../../ + fi hash="$(sha1sum -b "$4" | head -c 40)" if [ "$hash" != "$5" ]; then echo >&2 'SHA-1 hash of '"$4"' did not match: '"$hash" From d9f60e605274b6051659d2a329684144a76ecaac Mon Sep 17 00:00:00 2001 From: Robbi Blechdose Date: Tue, 21 Jan 2025 15:53:10 +0100 Subject: [PATCH 2/3] Reverted changes to man file --- man/gbz80.7 | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/man/gbz80.7 b/man/gbz80.7 index af70edb51..17b332832 100644 --- a/man/gbz80.7 +++ b/man/gbz80.7 @@ -615,9 +615,6 @@ to the adjustment. .It Subtract the adjustment from .Sy A . -.It -Set the carry flag if borrow (i.e. if adjustment > -.Sy A ) . .El .It If the subtract flag Sy N No is not set: .Bl -enum -compact @@ -639,15 +636,13 @@ to the adjustment. If the carry flag is set or .Sy A > -.Ad $9F , +.Ad $99 , then add .Ad $60 -to the adjustment. +to the adjustment and set the carry flag. .It Add the adjustment to .Sy A . -.It -Set the carry flag if overflow from bit 7. .El .El .Pp From fb04e77aa3dd4c39f3d8388c9bfeb63fa265d799 Mon Sep 17 00:00:00 2001 From: Robbi Blechdose Date: Tue, 21 Jan 2025 16:30:11 +0100 Subject: [PATCH 3/3] Added safeguards --- test/run-tests.sh | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/test/run-tests.sh b/test/run-tests.sh index b8eeacc69..a5b4d9410 100755 --- a/test/run-tests.sh +++ b/test/run-tests.sh @@ -48,6 +48,16 @@ while [[ $# -gt 0 ]]; do shift done +if ! ("$external" || "$internal"); then + echo "No tests to run." + false +fi + +if "$internal" && "$installedrgbds"; then + echo "Internal tests don't support running with the system-installed rgbds." + false +fi + if "$installedrgbds"; then # Refuse to run if RGBDS isn't installed 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