- Merge request !13363#3549601 Allow --directory and @group to work together in run-tests.sh → (Open) created by jonathan1055
When using core/scripts/run-tests.sh
with a final argument to run just a subset of tests for a specific @group
the test discovery process can fail with errors such as "class not found" or "declaration ... must be compatible with ..." in unrelated 3rd-party modules. The tests in these modules are never intended to be run, so the errors are not actually relevent. However the job is halted, thus preventing the tests in the actual project from being run.
The error does not happen for Drupal Core 10 and 11.0 and 11.1, which use PHPUnit 10. The problem starts with core version 11.2 which has PHPUnit 11 and where run-tests.sh has been modified to use the new test discovery API.
The problem does not happen if the --directory
parameter is specified, as this limits the test discovery to just the module being tested, or a folder within it, so the 3rd-party modules file are never examined. But the problem then is that this overrides the @group argument and all tests are run. The --directory
and @group
filtering can be made to work together and not be mutually exclusive, such that --directory
will limit the test discovery then @group filtering will be used to run the subset of tests.
Gitlab Templates can be modified to add the --directory
parameter when required, and this will greatly help all contrib modules who are testing with a subset of tests.
A secondary benefit of this is that it is much much faster locally to scan only the module you are testing, not the entire set of source test files for every module in your site.
Here is an example in the webform modules where an error in the feeds module prevents the tests from running.
https://git.drupalcode.org/issue/webform-3547627/-/jobs/6632522#L389
Here is an example in Gitlab Templates development, when an error in the sam module is preventing testing a recipe, which uses a core recipe, which loads the sam module
https://git.drupalcode.org/project/gitlab_templates_downstream/-/jobs/67...
Add $args['module']
and $args['directory']
when calling findAllClassFiles()
then filter later for test groups if required.
Active
11.0 🔥
phpunit
Not all content is available!
It's likely this issue predates Contrib.social: some issue and comment data are missing.