If you run core's tests on main with code coverage turned on, 48 test classes trigger a PHPUnit warning and the run fails.

phpunit.xml.dist has a <source> section that tells PHPUnit which files to measure for code coverage.

The 48 tests that fail name code outside <source>. At a minumum, I think we should add .module and .inc files, and ../composer, to <source>.

Issue fork drupal-3630852

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

dries created an issue. See original summary.

dries’s picture

I did some digging and opened an MR for this.

PHPUnit's <directory> element only picks up .php files, unless you give it a suffix. Core's <source> doesn't set one anywhere.

That has been the case since at least Drupal 8.0. What changed is that PHPUnit 12.0 started checking coverage targets against <source>.

The MR adds the suffixes and composer/:

     <include>
-      <directory>./includes</directory>
+      <directory suffix=".inc">./includes</directory>
       <directory>./lib</directory>
       <directory>./modules</directory>
+      <directory suffix=".module">./modules</directory>
+      <directory suffix=".inc">./modules</directory>
       <directory>../modules</directory>
+      <directory>../composer</directory>
     </include>
     <exclude>
       <directory>./lib/Drupal/Component</directory>
       <directory>./modules/*/src/Tests</directory>
       <directory>./modules/*/tests</directory>
+      <directory suffix=".module">./modules/*/tests</directory>
+      <directory suffix=".inc">./modules/*/tests</directory>

PHPUnit takes one suffix per line, so each file type gets its own line. The two exclude lines are there for the same reason: the existing ./modules/*/tests exclude only removes .php files, and the test directories also have .module and .inc files.

This is what each line does:

Directory Suffix Files
./includes .inc adds 12
./modules .module adds 35
./modules .inc adds 15
../composer .php (the default) adds 48
./modules/*/tests .module removes 12
./modules/*/tests .inc removes 6
dries’s picture

Status: Active » Needs review
mondrake’s picture