Skip to content

Commit

Permalink
Patch test projects so they build without deprecated features
Browse files Browse the repository at this point in the history
Also ensure the test scripts pass shellcheck
  • Loading branch information
Rangi42 committed Mar 28, 2024
1 parent ccfd3b6 commit 9dac583
Show file tree
Hide file tree
Showing 6 changed files with 89 additions and 32 deletions.
4 changes: 2 additions & 2 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -145,12 +145,12 @@ If one *does* exist, RGBGFX's return status is ignored, but its output **must**
2. Add the project to `test/fetch-test-deps.sh`: add a new `action` line at the bottom, following the existing pattern:

```sh
action <owner>/<repo> <date of last commit> <hash of last commit>
action <owner> <repo> <date of last commit> <hash of last commit>
```

(The date is used to avoid fetching too much history when cloning the repositories.)
3. Add the project to `test/run-tests.sh`: add a new `test_downstream` line at the bottom, following the existing pattern:

```sh
test_downstream <repo> <makefile target>
test_downstream <owner> <repo> <makefile target>
```
40 changes: 20 additions & 20 deletions test/fetch-test-deps.sh
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ while [[ $# -gt 0 ]]; do
break
;;
*)
echo "$(basename $0): unknown option "$1""
echo "$(basename "$0"): unknown option '$1'"
exit 1
;;
esac
Expand All @@ -48,9 +48,9 @@ done

case "$actionname" in
--get-deps)
action() { # # owner/repo
action() { # _ repo _ _
# libbet depends on PIL to build
if [ "$1" = "pinobatch/libbet" ]; then
if [ "$2" = "libbet" ]; then
case "${osname%-*}" in
ubuntu|macos)
python3 -m pip install pillow
Expand All @@ -67,38 +67,38 @@ case "$actionname" in
;;

--get-hash)
action() { # owner/repo shallow-since commit
printf "%s@%s-" "${1##*/}" "$3"
action() { # _ repo _ commit
printf "%s@%s-" "$2" "$4"
}
;;

--get-paths)
action() { # owner/repo shallow-since commit
printf "test/%s," "${1##*/}"
action() { # _ repo
printf "test/%s," "$2"
}
;;

*)
echo "Fetching test dependency repositories"

action() { # owner/repo shallow-since commit
if [ ! -d ${1##*/} ]; then
git clone https://github.com/$1.git --shallow-since=$2 --single-branch
action() { # owner repo shallow-since commit
if [ ! -d "$2" ]; then
git clone "https://github.com/$1/$2.git" --shallow-since="$3" --single-branch
fi
pushd ${1##*/}
git checkout -f $3
if [ -f ../patches/${1##*/}.patch ]; then
git apply --ignore-whitespace ../patches/${1##*/}.patch
pushd "$2"
git checkout -f "$4"
if [ -f "../patches/$2.patch" ]; then
git apply --ignore-whitespace "../patches/$2.patch"
fi
popd
}
esac

if "$nonfree"; then
action pret/pokecrystal 2024-03-03 c1da20e2f12f95c935500151d15f455e7e7eb213
action pret/pokered 2024-01-02 fabe2b3fb3fb5a849c5220298acabbdc9ad30f3b
action zladx/LADX-Disassembly 2024-02-25 583c78d2f2a5258b87bf133f75b7129228255650
action pret pokecrystal 2024-03-03 c1da20e2f12f95c935500151d15f455e7e7eb213
action pret pokered 2024-01-02 fabe2b3fb3fb5a849c5220298acabbdc9ad30f3b
action zladx LADX-Disassembly 2024-02-25 583c78d2f2a5258b87bf133f75b7129228255650
fi
action AntonioND/ucity 2023-11-02 c781ae20c0b319262b19b51e5067a2c93cf3b362
action pinobatch/libbet 2024-03-09 c98c7574d94f3e1a977bd7e98899f30a1ecbbb17
action LIJI32/SameBoy 2024-03-08 e7792c16b24c08f55a370973f0beaecb7bd0ab92
action AntonioND ucity 2023-11-02 c781ae20c0b319262b19b51e5067a2c93cf3b362
action pinobatch libbet 2024-03-09 c98c7574d94f3e1a977bd7e98899f30a1ecbbb17
action LIJI32 SameBoy 2024-03-08 e7792c16b24c08f55a370973f0beaecb7bd0ab92
15 changes: 15 additions & 0 deletions test/patches/LADX-Disassembly.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
diff --git a/Makefile b/Makefile
index d05ccba..1011447 100644
--- a/Makefile
+++ b/Makefile
@@ -13,9 +13,7 @@ RGBDS :=

ASM := $(RGBDS)rgbasm
ASFLAGS := \
- --export-all\
- --halt-without-nop\
- --preserve-ld
+ --export-all

LD := $(RGBDS)rgblink
LDFLAGS :=
17 changes: 17 additions & 0 deletions test/patches/libbet.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
diff --git a/makefile b/makefile
index 6513518..35826eb 100644
--- a/makefile
+++ b/makefile
@@ -85,10 +85,10 @@ $(title).gb: $(objlisto)
$(RGBFIX) -jvsc -k "OK" -l 0x33 -m ROM -p 0xFF -t "LIBBET" -v $@

obj/gb/%.o: src/%.z80 src/hardware.inc src/global.inc
- ${RGBASM} -h -o $@ $<
+ ${RGBASM} -o $@ $<

obj/gb/%.o: obj/gb/%.z80
- ${RGBASM} -h -o $@ $<
+ ${RGBASM} -o $@ $<

# Files that will be included with incbin

25 changes: 25 additions & 0 deletions test/patches/ucity.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
diff --git a/Makefile b/Makefile
index 22c65e9..e7c888d 100644
--- a/Makefile
+++ b/Makefile
@@ -51,7 +51,7 @@ ASMFILES := $(foreach dir,$(SOURCE_ALL_DIRS),$(wildcard $(dir)/*.asm))

# List of include directories: All source and data folders.
# A '/' is appended to the path.
-INCLUDES := $(foreach dir,$(SOURCE_ALL_DIRS),-i$(dir)/)
+INCLUDES := $(foreach dir,$(SOURCE_ALL_DIRS),-I$(dir)/)

# Prepare object paths from source files.
OBJ := $(ASMFILES:.asm=.obj)
@@ -72,10 +72,9 @@ clean:
@echo rm $(OBJ) $(BIN) $(COMPAT_BIN) $(NAME).sym $(NAME).map
@rm -f $(OBJ) $(BIN) $(COMPAT_BIN) $(NAME).sym $(NAME).map

-# TODO: Remove the -h when RGBASM is updated to remove it
%.obj : %.asm
@echo rgbasm $<
- @$(RGBASM) $(INCLUDES) -h -E -o$@ $<
+ @$(RGBASM) $(INCLUDES) -E -o$@ $<

$(BIN): $(OBJ)
@echo rgblink $(BIN)
20 changes: 10 additions & 10 deletions test/run-tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ while [[ $# -gt 0 ]]; do
break
;;
*)
echo "$(basename $0): internal error"
echo "$(basename "$0"): internal error"
exit 1
;;
esac
Expand All @@ -54,21 +54,21 @@ done
# When updating subprojects, change the commit being checked out, and set the `shallow-since`
# to the day before, to reduce the amount of refs being transferred and thus speed up CI.

test_downstream() { # owner/repo make-target
if ! pushd ${1##*/}; then
test_downstream() { # owner repo make-target
if ! pushd "$2"; then
echo >&2 'Please run `'"$FETCH_TEST_DEPS"'` before running the test suite'
return 1
fi
make clean
make -j4 $2 RGBDS=../../
make -j4 "$3" RGBDS=../../
popd
}

if "$nonfree"; then
test_downstream pret/pokecrystal compare
test_downstream pret/pokered compare
test_downstream zladx/LADX-Disassembly ''
test_downstream pret pokecrystal compare
test_downstream pret pokered compare
test_downstream zladx LADX-Disassembly default
fi
test_downstream AntonioND/ucity ''
test_downstream pinobatch/libbet all
test_downstream LIJI32/SameBoy bootroms
test_downstream AntonioND ucity all
test_downstream pinobatch libbet all
test_downstream LIJI32 SameBoy bootroms

0 comments on commit 9dac583

Please sign in to comment.