Repository navigation
Add WPT_PHPUNIT_ARGS to pass extra arguments to PHPUnit - #358
Merged
Merged
Conversation
Hosts can now leave out a test that fails for a known reason without replacing the whole PHPUnit command through WPT_PHPUNIT_CMD. The value is added to the end of the default command, after the multisite and extra-group flags. It is ignored, with a log message, when WPT_PHPUNIT_CMD is set. Document the variable and how to skip one test with --filter or a group with --exclude-group, including that --exclude-group replaces the <exclude> list in the PHPUnit configuration. Fixes WordPress#48.
|
The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message. To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. Props Bot commandsYou can trigger Props Bot actions by commenting on this PR:
|
Resolve the conflict in test.php with WordPress#361: keep its --verbose and its comment on the default PHPUnit command, and add WPT_PHPUNIT_ARGS after the flags as before.
compose.yaml lists the variables it passes to the runner, and the README says only those reach it. Add WPT_PHPUNIT_ARGS next to WPT_PHPUNIT_CMD so it also works when the runner is started with Docker Compose.
✅ Container Tests: successResults for a36fbf1 from workflow run #19. Logs, PHPUnit Test Runner: ✅ passed
Test results
PHPUnit Test Runner: ✅ passed
Test results
|
chrisdavidmiles
approved these changes
Oct 28, 2026
jazzsequence
approved these changes
Nov 4, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #48.
Problem
When a test fails on a host for a reason the host already knows about, there is no simple way to leave it out. The only option is
WPT_PHPUNIT_CMD, which replaces the whole PHPUnit command, so the host has to rebuildcd <test dir> && php ./vendor/phpunit/phpunit/phpunit --dont-report-useless-tests --verboseand theWPT_FLAVOR/WPT_EXTRATESTSflags by hand. None of this is documented.Fix
WPT_PHPUNIT_ARGS.test.phpadds it to the end of the default PHPUnit command, after the multisite and extra-group flags. It is empty by default, so the command does not change for existing setups.WPT_PHPUNIT_CMDis set,WPT_PHPUNIT_ARGSis ignored andtest.phplogs that, becauseWPT_PHPUNIT_CMDreplaces the whole command.compose.yamlpassesWPT_PHPUNIT_ARGSto the runner container, next toWPT_PHPUNIT_CMD, because only the variables listed there reach it..env.defaultand the README document it. The new README section "Skipping tests that fail for a known reason" covers:--filterwith a negative lookahead pattern. It also leaves out every data set of that test and keeps tests whose names only start the same way.--exclude-group. PHPUnit then ignores the<exclude>list inphpunit.xml.dist(ortests/phpunit/multisite.xml), so groups such asajaxandexternal-httpwould run unless that list is added too. The README gives the single site and multisite lists separately, since they differ. WithWPT_EXTRATESTSset, only the failing group should be listed.Verification
test.phpend to end, re-run after mergingmaster(#361), with a stubvendor/phpunit/phpunit/phpunitthat prints the arguments it receives and the.envsourced as the README describes:WPT_PHPUNIT_ARGS: the same command asmaster.--filterexample: arrives as one argument with the pattern intact.WPT_FLAVOR=1,WPT_EXTRATESTS=1and--exclude-group: the arguments come after-c tests/phpunit/multisite.xml --group ajax.WPT_PHPUNIT_CMDset: the arguments are ignored and the message is logged.WPT_SSH_CONNECTset, with a stand-insshthat runs the remote command in a shell: the pattern arrives intact.Docker Compose: with the README
--filterexample set on the host,docker compose runon the runner image built from this branch receivedWPT_PHPUNIT_ARGSunchanged (checked withprintenv; the test suite was not run in the container).Verified with PHPUnit 9.6.38 on a small suite whose config excludes
ajax:--filterpattern leaves out exactly the named test and all of its data sets, and keeps a test whose name only starts the same way and a method with the same name in another class.--exclude-groupwith only the failing group makes theajaxtest run. Adding the config's list keeps it out.--group ajaxwith an exclude list that containsajaxruns no tests.php -land PHPCS with the repository ruleset are clean ontest.php.Notes
test.php, and Add multi-PHP, environment labels, and commit tracking. #333 and Add GitHub action for easy remote test execution via GitHub Actions #245 already conflict withmaster. This branch merges cleanly with the other open PRs that touch the same files (Reduce the need for npm by installing built files from the WordPress mirror #246, Add host-tools/testrunner.sh to run the full test cycle in one step #346, Add host-tools/setup.sh to create .env with prompts #348, Document the host tools #349).Use of AI
AI assistance: Yes
Tool(s): Claude Code and Codex
Used for: Investigation, implementation, verification harness, and PR wording. I reviewed the reasoning and test results, and I take responsibility for the contribution.