diff --git a/phpbb-test-board/README.md b/phpbb-test-board/README.md index ec1de5f..5fd92f9 100644 --- a/phpbb-test-board/README.md +++ b/phpbb-test-board/README.md @@ -54,6 +54,7 @@ phpbb-test-board/run-unit-tests.sh path/to/extension [-b 3.3.x|master] [-f PATTE Runs the extension's `phpunit.xml.dist` the way [phpbb-extensions/test-framework](https://github.com/phpbb-extensions/test-framework) does in CI: inside a phpBB checkout, with phpBB's own PHPUnit and `tests/bootstrap.php`. It needs no board. - **The checkout** is set up on first use in `~/.cache/phpbb-release-tools/phpbb-BRANCH` (or `--env DIR`, or `PHPBB_UNIT_ENV`): a shallow clone of phpBB, its Composer dependencies, and on PHP 8 with phpBB 3.3.x the switch to PHPUnit 9 that phpBB's own CI makes, since 3.3.x ships PHPUnit 7.5. `--update` pulls it and reinstalls. - **The extension** is copied in afresh on every run (`rsync --delete`, without `.git`), into `phpBB/ext/` under its `composer.json` name, so a test never runs against an old copy. +- **A `tests/functional` folder** must exist, even an empty one (`tests/functional/.gitkeep`). The test framework runs with phpBB's own configuration, which lists it, and its PostgreSQL, MySQL, MSSQL and Windows jobs stop without it; the script refuses to run without it so that shows up before CI. - `-f PATTERN` runs only the matching tests; anything after `--` goes to PHPUnit, for example `-- --testdox` or, on `master`, `-- --display-skipped`. Exit status: PHPUnit's, 1 for a setup failure, 2 for bad arguments. Needs `git`, `php`, `composer`, `rsync` and `jq`. diff --git a/phpbb-test-board/run-unit-tests.sh b/phpbb-test-board/run-unit-tests.sh index 694a79f..0b14780 100755 --- a/phpbb-test-board/run-unit-tests.sh +++ b/phpbb-test-board/run-unit-tests.sh @@ -30,8 +30,9 @@ phpbb-extensions test framework does in CI. The checkout is set up on first use; the extension is copied in afresh on every run. Arguments: - EXT_DIR the extension's checkout (with composer.json and - phpunit.xml.dist) + EXT_DIR the extension's checkout (with composer.json, + phpunit.xml.dist and a tests/functional folder, + which may be empty) PHPUNIT_ARGS anything after -- is passed to PHPUnit Options: @@ -128,6 +129,11 @@ esac ext_dir="$(cd -- "$ext_dir" && pwd)" [ -f "$ext_dir/composer.json" ] || usage_error "$ext_dir has no composer.json" [ -f "$ext_dir/phpunit.xml.dist" ] || usage_error "$ext_dir has no phpunit.xml.dist" +# The test framework's CI runs with phpBB's own configuration, which lists the +# extension's tests/functional folder; its PostgreSQL, MySQL, MSSQL and Windows +# jobs stop when the folder is missing, even with functional tests turned off +[ -d "$ext_dir/tests/functional" ] || + usage_error "$ext_dir has no tests/functional folder, which the test framework's CI jobs need even when empty: mkdir -p tests/functional && touch tests/functional/.gitkeep" for tool in git php composer rsync jq; do need "$tool" diff --git a/tests/test-phpbb-test-board.sh b/tests/test-phpbb-test-board.sh index f077707..0a9a510 100755 --- a/tests/test-phpbb-test-board.sh +++ b/tests/test-phpbb-test-board.sh @@ -128,6 +128,9 @@ mkdir -p "$tmp/ext-no-phpunit" "$tmp/ext-bad-name" echo '{"name": "vendor/ext"}' >"$tmp/ext-no-phpunit/composer.json" echo '{"name": "Not A Name"}' >"$tmp/ext-bad-name/composer.json" touch "$tmp/ext-bad-name/phpunit.xml.dist" +mkdir -p "$tmp/ext-bad-name/tests/functional" "$tmp/ext-no-functional" +echo '{"name": "vendor/ext"}' >"$tmp/ext-no-functional/composer.json" +touch "$tmp/ext-no-functional/phpunit.xml.dist" check "run-unit-tests.sh without arguments shows help and exits 0" \ exits_with 0 "$tools/run-unit-tests.sh" check "run-unit-tests.sh --help shows usage" output_has "Usage: run-unit-tests.sh" "$tools/run-unit-tests.sh" --help @@ -137,6 +140,10 @@ check "run-unit-tests.sh with an unknown branch exits 2" \ check "run-unit-tests.sh with a missing directory exits 2" exits_with 2 "$tools/run-unit-tests.sh" "$tmp/no-such-dir" check "run-unit-tests.sh without phpunit.xml.dist exits 2" \ exits_with 2 "$tools/run-unit-tests.sh" "$tmp/ext-no-phpunit" +check "run-unit-tests.sh without tests/functional exits 2" \ + exits_with 2 "$tools/run-unit-tests.sh" "$tmp/ext-no-functional" +check "run-unit-tests.sh says how to add tests/functional" \ + output_has "mkdir -p tests/functional" "$tools/run-unit-tests.sh" "$tmp/ext-no-functional" check "run-unit-tests.sh with two directories exits 2" \ exits_with 2 "$tools/run-unit-tests.sh" "$tmp/ext-no-phpunit" "$tmp/ext-bad-name" check "run-unit-tests.sh rejects a composer name that is not vendor/name" \