Problem/Motivation

Here's a case where you discover test fails under PHPUnit that you do not see under run-tests.sh: #2905470: @deprecated Drupal\system\Tests\Update\UpdatePathTestBase breaks test runs

Why does this happen?

run-tests.sh runs all PHPUnit tests in a separate process. This is good for a number of reasons. However, because run-tests.sh has already discovered the tests, the phpunit child process doesn't need to. run-tests.sh just passes along the file path on the command line.

This is good because it's fast and good because there's no ambiguity.

But it's bad because our deprecation process includes putting @trigger_error() in non-executable portions of files. That is, when you put @trigger_error(E_USER_DEPRECATED) just after the namespace declaration, that error will only be triggered during discovery.

So we have a situation in #2905470: @deprecated Drupal\system\Tests\Update\UpdatePathTestBase breaks test runs where all PHPUnit-based functional tests (at least) should fail, by design, because of our deprecation process. But they do not fail, because PHPUnit never performs discovery.

This means run-tests.sh is giving us false passes for all PHPUnit functional tests.

Proposed resolution

Instead of launching each PHPUnit child process with a file path to the PHPUnit test class, we should force the child process to do discovery using --filter.

We can minimize the time this takes by calculating the test suite of the test class in question and then providing --testsuite on the command ilne as well.

Remaining tasks

User interface changes

API changes

Data model changes

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Mile23 created an issue. See original summary.

Mile23’s picture

Status: Active » Needs review
FileSize
1.77 KB

Here's a patch.

This test will fail, in a big way, which means it's working.

Mile23’s picture

Issue summary: View changes

Status: Needs review » Needs work

The last submitted patch, 2: 2906009_2.patch, failed testing. View results

Mile23’s picture

Status: Needs work » Needs review
FileSize
3.11 KB
dawehner’s picture

That is, when you put @trigger_error(E_USER_DEPRECATED) just after the namespace declaration, that error will only be triggered during discovery.

Can you explain why?

I am wondering whether there is a way to fix that. Running everything a different way than people might use it locally feels like a hacky fix.

Status: Needs review » Needs work

The last submitted patch, 5: 2906009_5_2905470_4_combined.patch, failed testing. View results

Mile23’s picture

feels like a hacky fix.

You're welcome.

Can you explain why?

Yes.

#2870194-31: Ensure that process-isolated tests can use Symfony's PHPunit bridge to catch usages of deprecated code
#2884530: Mark process-isolated test with @expectedDeprecation as risky
#2886547-22: Add trigger_error to deprecated TestBase base classes/traits that have none, reference CR

Those all explain that BrowserTestBase and other process-isolated tests will ignore @trigger_error() in all its forms. It's an upstream problem with symfony/phpunit-bridge, so if I solve it here, no one will a) understand it or b) want it, as evidenced by the above comment about hacky fixes.

This issue cuts some of the complexity off the problem for one case: @trigger_error() before executable code in a class file. We can at least catch those by forcing phpunit to do discovery instead of having all @trigger_error() being swallowed by a child process.

And the reason we want this is because run-tests.sh has false passes, when it should have failed at least two tests, and probably all functional tests, as seen in #2905470: @deprecated Drupal\system\Tests\Update\UpdatePathTestBase breaks test runs

If the policy here is that test should fail because they use deprecated base classes, then this is a no-brainer.

If that's not the policy then I am, truly, wasting my time on hacky fixes.

Mile23’s picture

Version: 8.4.x-dev » 8.5.x-dev

Drupal 8.4.4 was released on January 3, 2018 and is the final full bugfix release for the Drupal 8.4.x series. Drupal 8.4.x will not receive any further development aside from critical and security fixes. Sites should prepare to update to 8.5.0 on March 7, 2018. (Drupal 8.5.0-alpha1 is available for testing.)

Bug reports should be targeted against the 8.5.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.6.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.5.x-dev » 8.6.x-dev

Drupal 8.5.6 was released on August 1, 2018 and is the final bugfix release for the Drupal 8.5.x series. Drupal 8.5.x will not receive any further development aside from security fixes. Sites should prepare to update to 8.6.0 on September 5, 2018. (Drupal 8.6.0-rc1 is available for testing.)

Bug reports should be targeted against the 8.6.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.7.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.6.x-dev » 8.8.x-dev

Drupal 8.6.x will not receive any further development aside from security fixes. Bug reports should be targeted against the 8.8.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.9.x-dev branch. For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

Version: 8.8.x-dev » 8.9.x-dev

Drupal 8.8.7 was released on June 3, 2020 and is the final full bugfix release for the Drupal 8.8.x series. Drupal 8.8.x will not receive any further development aside from security fixes. Sites should prepare to update to Drupal 8.9.0 or Drupal 9.0.0 for ongoing support.

Bug reports should be targeted against the 8.9.x-dev branch from now on, and new development or disruptive changes should be targeted against the 9.1.x-dev branch. For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

quietone’s picture

Component: simpletest.module » phpunit

Triaging issues in simpletest.module as part of the Bug Smash Initiative to determine if they should be in the Simpletest Project or core.

run-tests is still in core so moving to the Phpunit component, the only testing related component.

Version: 8.9.x-dev » 9.2.x-dev

Drupal 8 is end-of-life as of November 17, 2021. There will not be further changes made to Drupal 8. Bugfixes are now made to the 9.3.x and higher branches only. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.2.x-dev » 9.3.x-dev

Version: 9.3.x-dev » 9.4.x-dev

Drupal 9.3.15 was released on June 1st, 2022 and is the final full bugfix release for the Drupal 9.3.x series. Drupal 9.3.x will not receive any further development aside from security fixes. Drupal 9 bug reports should be targeted for the 9.4.x-dev branch from now on, and new development or disruptive changes should be targeted for the 9.5.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.4.x-dev » 9.5.x-dev

Drupal 9.4.9 was released on December 7, 2022 and is the final full bugfix release for the Drupal 9.4.x series. Drupal 9.4.x will not receive any further development aside from security fixes. Drupal 9 bug reports should be targeted for the 9.5.x-dev branch from now on, and new development or disruptive changes should be targeted for the 10.1.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.5.x-dev » 11.x-dev

Drupal core is moving towards using a “main” branch. As an interim step, a new 11.x branch has been opened, as Drupal.org infrastructure cannot currently fully support a branch named main. New developments and disruptive changes should now be targeted for the 11.x branch. For more information, see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.