Files
rgbds/test/fetch-test-deps.sh
T
Rangi a829e6c067 Refactor the test harness for external repo tests (#1994)
- Use CTest labels to filter tests ("internal"/"external", "free"/"nonfree",
  and individual tool+project names) instead of defining `TESTS_RUN_NONFREE`
- Allow each external test to run independently in CTest
- Remove the unused no-op `fetch-test-deps.sh --only-internal` option
2026-06-30 16:19:41 +02:00

86 lines
2.0 KiB
Bash
Executable File

#!/usr/bin/env bash
set -euo pipefail
cd "$(dirname "$0")"
usage() {
cat <<"EOF"
Downloads source code of Game Boy project repos used as RGBDS test cases.
Options:
-h, --help show this help message
--only-free download only freely licensed codebases
--get-hash print repos' commit hashes instead of downloading them
--get-paths print repos' clone paths instead of downloading them
EOF
}
# Parse options in pure Bash because macOS `getopt` is stuck
# in what util-linux `getopt` calls `GETOPT_COMPATIBLE` mode
nonfree=true
actionname=
osname=
while [[ $# -gt 0 ]]; do
case "$1" in
-h|--help)
usage
exit 0
;;
--only-free)
nonfree=false
;;
--get-hash|--get-paths)
actionname="$1"
;;
--)
break
;;
*)
echo "$(basename "$0"): unknown option '$1'"
exit 1
;;
esac
shift
done
case "$actionname" in
--get-hash)
action() {
printf "%s@%s-" "$EXTERNAL_TEST_REPO" "$EXTERNAL_TEST_COMMIT"
}
;;
--get-paths)
action() {
printf "test/%s," "$EXTERNAL_TEST_REPO"
}
;;
*)
echo "Fetching test dependency repositories"
action() {
if [ ! -d "$EXTERNAL_TEST_REPO" ]; then
git clone "https://$EXTERNAL_TEST_DOMAIN/$EXTERNAL_TEST_OWNER/$EXTERNAL_TEST_REPO.git" \
--revision="$EXTERNAL_TEST_COMMIT" --depth=1 --recursive --shallow-submodules \
--config advice.detachedHead=false
fi
pushd "$EXTERNAL_TEST_REPO"
git checkout --force --detach "$EXTERNAL_TEST_COMMIT" --
if [ -f "../patches/$EXTERNAL_TEST_REPO.patch" ]; then
git apply --ignore-whitespace "../patches/$EXTERNAL_TEST_REPO.patch"
fi
popd
}
esac
# Sourcing each "external/*.cfg" file defines `EXTERNAL_TEST_*` values used by the `action` functions.
if "$nonfree"; then
. external/pokecrystal.cfg && action
. external/pokered.cfg && action
. external/ladx.cfg && action
fi
. external/ucity.cfg && action
. external/libbet.cfg && action
. external/sameboy.cfg && action
. external/gb-starter-kit.cfg && action