From 04b9c7fa3d101c9125dae713f769e9ade0200bd8 Mon Sep 17 00:00:00 2001 From: ISSOtm Date: Wed, 1 Jul 2026 02:09:34 +0200 Subject: [PATCH] Move external tests files to `tests/external/` --- .github/workflows/testing.yml | 24 +++++++++---------- contrib/checkdiff.bash | 2 +- contrib/coverage.bash | 2 +- docs/ARCHITECTURE.md | 13 +++++++--- docs/CONTRIBUTING.md | 2 +- docs/RELEASE.md | 2 +- test/.gitignore | 7 ------ test/CMakeLists.txt | 8 +++---- test/external/.gitignore | 2 ++ .../fetch-repos.sh} | 9 ++++--- test/external/test.sh | 11 +++++---- 11 files changed, 42 insertions(+), 40 deletions(-) delete mode 100644 test/.gitignore create mode 100644 test/external/.gitignore rename test/{fetch-test-deps.sh => external/fetch-repos.sh} (85%) diff --git a/.github/workflows/testing.yml b/.github/workflows/testing.yml index f24a9b59..7f3e47e9 100644 --- a/.github/workflows/testing.yml +++ b/.github/workflows/testing.yml @@ -93,8 +93,8 @@ jobs: - name: Compute test dependency cache params id: test-deps-cache-params run: | - paths=$(test/fetch-test-deps.sh --get-paths) - hash=$(test/fetch-test-deps.sh --get-hash) + paths=$(test/external/fetch-repos.sh --get-paths) + hash=$(test/external/fetch-repos.sh --get-hash) tee -a <<<"paths=\"${paths//,/\\n}\"" $GITHUB_OUTPUT tee -a <<<"hash=${hash%-}" $GITHUB_OUTPUT - name: Check test dependency repositories cache @@ -107,7 +107,7 @@ jobs: if: steps.test-deps-cache.outputs.cache-hit != 'true' continue-on-error: true run: | - test/fetch-test-deps.sh + test/external/fetch-repos.sh - name: Run tests using our script if: matrix.buildsys == 'make' run: | @@ -155,8 +155,8 @@ jobs: - name: Compute test dependency cache params id: test-deps-cache-params run: | - paths=$(test/fetch-test-deps.sh --get-paths) - hash=$(test/fetch-test-deps.sh --get-hash) + paths=$(test/external/fetch-repos.sh --get-paths) + hash=$(test/external/fetch-repos.sh --get-hash) tee -a <<<"paths=\"${paths//,/\\n}\"" $GITHUB_OUTPUT tee -a <<<"hash=${hash%-}" $GITHUB_OUTPUT - name: Check test dependency repositories cache @@ -169,7 +169,7 @@ jobs: if: steps.test-deps-cache.outputs.cache-hit != 'true' continue-on-error: true run: | - test/fetch-test-deps.sh + test/external/fetch-repos.sh - name: Run tests run: | ctest --test-dir build --schedule-random @@ -218,8 +218,8 @@ jobs: - name: Compute test dependency cache params id: test-deps-cache-params run: | - paths=$(test/fetch-test-deps.sh --get-paths) - hash=$(test/fetch-test-deps.sh --get-hash) + paths=$(test/external/fetch-repos.sh --get-paths) + hash=$(test/external/fetch-repos.sh --get-hash) tee -a <<<"paths=\"${paths//,/\\n}\"" $GITHUB_OUTPUT tee -a <<<"hash=${hash%-}" $GITHUB_OUTPUT - name: Check test dependency repositories cache @@ -232,7 +232,7 @@ jobs: if: steps.test-deps-cache.outputs.cache-hit != 'true' continue-on-error: true run: | - test/fetch-test-deps.sh + test/external/fetch-repos.sh - name: Run tests using CTest run: | ctest --test-dir build --schedule-random @@ -311,8 +311,8 @@ jobs: - name: Compute test dependency cache params id: test-deps-cache-params run: | - paths=$(test/fetch-test-deps.sh --get-paths) - hash=$(test/fetch-test-deps.sh --get-hash) + paths=$(test/external/fetch-repos.sh --get-paths) + hash=$(test/external/fetch-repos.sh --get-hash) tee -a <<<"paths=\"${paths//,/\\n}\"" $GITHUB_OUTPUT tee -a <<<"hash=${hash%-}" $GITHUB_OUTPUT - name: Check test dependency repositories cache @@ -325,7 +325,7 @@ jobs: if: steps.test-deps-cache.outputs.cache-hit != 'true' continue-on-error: true run: | - test/fetch-test-deps.sh + test/external/fetch-repos.sh - name: Run tests run: | test/run-tests.sh --os ${{ matrix.os }} diff --git a/contrib/checkdiff.bash b/contrib/checkdiff.bash index be412a22..3dc06e89 100755 --- a/contrib/checkdiff.bash +++ b/contrib/checkdiff.bash @@ -79,7 +79,7 @@ dependency src/gfx/main.cpp contrib/zsh_compl/_rgbgfx \ dependency src/gfx/main.cpp contrib/bash_compl/_rgbgfx.bash \ "Did the rgbgfx CLI change?" -dependency test/fetch-test-deps.sh docs/CONTRIBUTING.md \ +dependency test/external/fetch-repos.sh docs/CONTRIBUTING.md \ "Did the test protocol change?" dependency test/run-tests.sh docs/CONTRIBUTING.md \ "Did the test protocol change?" diff --git a/contrib/coverage.bash b/contrib/coverage.bash index 46fd1adf..6b0f7777 100755 --- a/contrib/coverage.bash +++ b/contrib/coverage.bash @@ -6,7 +6,7 @@ make coverage -j # Run the tests pushd test -./fetch-test-deps.sh +external/fetch-repos.sh if [[ $# -eq 0 ]]; then ./run-tests.sh else diff --git a/docs/ARCHITECTURE.md b/docs/ARCHITECTURE.md index 55d59839..e8c75d26 100644 --- a/docs/ARCHITECTURE.md +++ b/docs/ARCHITECTURE.md @@ -56,8 +56,10 @@ rgbds/ │ ├── bison.sh │ └── ... ├── test/ -│ ├── fetch-test-deps.sh │ ├── run-tests.sh +│ ├── external/ +│ │ ├── fetch-repos.sh +│ │ └── ... │ └── ... ├── .clang-format ├── .clang-tidy @@ -110,10 +112,15 @@ rgbds/ Script used to run the Bison parser generator with the latest flags that the user's version supports. - **`test/`:** Testing framework used to verify that changes to the code don't break or modify the behavior of RGBDS. - * **`fetch-test-deps.sh`:** - Script used to fetch dependencies for building external repositories. `fetch-test-deps.sh --help` describes its options. + The `test.sh` scripts inside each of the subdirectories are the individual test drivers. * **`run-tests.sh`:** Script used to run tests, including internal test cases and external repositories. `run-tests.sh --help` describes its options. + * **`external/`:** + Directory for third-party repos making use of RGBDS, which get cloned here and built during testing. + - **`fetch-repos.sh`:** + Script used to clone the external repositories. `fetch-repos.sh --help` describes its options. + - **`*.cfg`:** + Each `.cfg` file defines the parameters to clone, build, and verify an external repository. - **`.clang-format`:** Code style for automated C++ formatting with [`clang-format`](https://clang.llvm.org/docs/ClangFormat.html) (for which we define the shortcut `make format`). - **`.clang-tidy`:** diff --git a/docs/CONTRIBUTING.md b/docs/CONTRIBUTING.md index f312f186..70e5739c 100644 --- a/docs/CONTRIBUTING.md +++ b/docs/CONTRIBUTING.md @@ -69,7 +69,7 @@ years). If you are adding new files, you need to use the You can also use `cmake --preset develop` if you prefer. 5. Test your changes by running `./run-tests.sh` in the `test` directory. `./run-tests.sh --help` will print its available options. (You must run - `./fetch-test-deps.sh` first; if you forget to, the test suite will fail and + `external/fetch-repos.sh` first; if you forget to, the test suite will fail and remind you mid-way.) You can also use `ctest --test-dir build` if you prefer. diff --git a/docs/RELEASE.md b/docs/RELEASE.md index cb121f7b..63daf41f 100644 --- a/docs/RELEASE.md +++ b/docs/RELEASE.md @@ -10,7 +10,7 @@ GitHub. `PACKAGE_VERSION_MINOR`, `PACKAGE_VERSION_PATCH`, and `PACKAGE_VERSION_RC`. **Only** define `PACKAGE_VERSION_RC` if you are publishing a release candidate! - [Dockerfile](Dockerfile): update `ARG version`. - - [test/fetch-test-deps.sh](test/fetch-test-deps.sh): update test dependency commits + - [test/external/*.cfg](test/external): update test dependency commits (preferably, use the latest available). - [man/\*](man/): update dates and authors. diff --git a/test/.gitignore b/test/.gitignore deleted file mode 100644 index 2bd54f06..00000000 --- a/test/.gitignore +++ /dev/null @@ -1,7 +0,0 @@ -/gb-starter-kit/ -/LADX-Disassembly/ -/libbet/ -/pokecrystal/ -/pokered/ -/SameBoy/ -/ucity/ diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 8f9faddb..4faa8665 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -28,15 +28,15 @@ endforeach() set_tests_properties(rgbgfx PROPERTIES REQUIRED_FILES "$;$;$") add_test(NAME fetch-test-deps - COMMAND bash -- fetch-test-deps.sh --only-free + COMMAND bash -- external/fetch-repos.sh --only-free WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}") set_tests_properties(fetch-test-deps PROPERTIES FIXTURES_SETUP "free-repos" LABELS "external") add_test(NAME fetch-nonfree-deps - COMMAND bash -- fetch-test-deps.sh + COMMAND bash -- external/fetch-repos.sh WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}") -set_tests_properties(fetch-nonfree-deps PROPERTIES FIXTURES_SETUP "external-repos" - FIXTURES_REQUIRED "free-repos" +set_tests_properties(fetch-nonfree-deps PROPERTIES FIXTURES_SETUP "external-repos" # *All* external repos. + FIXTURES_REQUIRED "free-repos" # Sequence after the other to avoid concurrent access. LABELS "external;nonfree") file(GLOB ext_projects "external/*.cfg") # This will not be re-computed if a new project is added! You must manually reconfigure. diff --git a/test/external/.gitignore b/test/external/.gitignore new file mode 100644 index 00000000..6d083e6f --- /dev/null +++ b/test/external/.gitignore @@ -0,0 +1,2 @@ +# All of the cloned external repos. +/*/ diff --git a/test/fetch-test-deps.sh b/test/external/fetch-repos.sh similarity index 85% rename from test/fetch-test-deps.sh rename to test/external/fetch-repos.sh index 54acaad4..e0800ca8 100755 --- a/test/fetch-test-deps.sh +++ b/test/external/fetch-repos.sh @@ -50,7 +50,7 @@ case "$actionname" in --get-paths) action() { - printf "test/%s," "$EXT_TEST_REPO" + printf "test/external/%s," "$EXT_TEST_REPO" } ;; @@ -72,10 +72,9 @@ case "$actionname" in } esac -# Since each iteration sources variables into the shell itself, -# we do that in a subshell so that they don't "leak" out. -for cfg in external/*.cfg; do ( - # The sourced file defines `EXT_TEST_*` variables that get used by `action`. +# Each iteration is isolated in a (subshell) so the sourced cfg variables don't "leak" out. +for cfg in *.cfg; do ( + # Sourcing "$cfg" defines `EXT_TEST_*` variables that get used by `action`. . "$cfg" # Only run a nonfree action if nonfree tests are opted into. if ! $EXT_TEST_IS_NONFREE || $nonfree; then diff --git a/test/external/test.sh b/test/external/test.sh index 80f03a5e..8ee76901 100755 --- a/test/external/test.sh +++ b/test/external/test.sh @@ -6,24 +6,25 @@ export LC_ALL=C # Game Boy release date, 1989-04-21T12:34:56Z (for reproducible test results) export SOURCE_DATE_EPOCH=609165296 -cd "$(dirname "$0")/.." +cd "$(dirname "$0")" -RGBDS_PATH="RGBDS=../../" - -if [ ! -f "external/$1.cfg" ]; then +if [ ! -f "$1.cfg" ]; then echo >&2 'External test file '"$1"'.cfg does not exist' exit 1 fi # Sourcing "$1.cfg" defines `EXT_TEST_*` variables used below. -. "external/$1.cfg" +. "$1.cfg" if ! cd "$EXT_TEST_REPO"; then echo >&2 'Please fetch test deps before running any external test' exit 1 fi + +RGBDS_PATH="RGBDS=../../../" make clean $RGBDS_PATH make -j4 "$EXT_TEST_TARGET" $RGBDS_PATH + hash="$(sha1sum -b "$EXT_TEST_FILE" | head -c 40)" if [ "$hash" != "$EXT_TEST_HASH" ]; then cat >&2 <