Problem/Motivation

Currently, Simpletest-based tests will ignore @trigger_error() deprecations. That's thanks to the @ which silences all such errors by default unless we handle them.

PHPUnit-based tests benefit from this already, with some exceptions: #2884530: Mark process-isolated test with @expectedDeprecation as risky

Simpletest-based tests do not benefit from these errors because they are not run under PHPUnit.

Simpletest-based tests are not allowed as new code into Drupal core. Only PHPUnit-based tests can use php-bridge features such as @group legacy, so they'll never run under Simpletest.

This means we could handle these errors and assert them as debug- or show-stopping errors.

Proposed resolution

Handle the triggered deprecation errors in Drupal\simpletest\TestBase.

Allow these errors to optionally signal a test fail, off by default.

Add a --fail-on-deprecation flag to run-tests.sh to manage this setting.

Remaining tasks

User interface changes

API changes

Data model changes

CommentFileSizeAuthor
#2 2904566_2.patch5.7 KBMile23
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Mile23 created an issue. See original summary.

Mile23’s picture

Title: Allow TestBase to optionally fail @trigger_error() deprecations, amend run-tests.sh » Allow TestBase to optionally notify/fail @trigger_error() deprecations, amend run-tests.sh
FileSize
5.7 KB

Patch.

You can see it in action with a test run like this:

php ./core/scripts/run-tests.sh --url http://localhost:8888/ --browser --fail-on-deprecated --class 'Drupal\system\Tests\Ajax\CommandsTest'

This will open the browser and show you a helpful error message for your failed test:

As of 3.1 an Symfony\Component\HttpKernel\Controller\ArgumentResolverInterface is used to resolve arguments. In 4.0 the $argumentResolver becomes the Symfony\Component\HttpKernel\Controller\ArgumentResolver if no other is provided instead of using the $resolver argument.

Remove --fail-on-deprecated and you'll see a notice in the test log, but not a fail.

Mile23’s picture

Status: Active » Needs review
alexpott’s picture

This won't catch deprecations in the site under test - only in code directly run by the test. We need to do quite a bit more work to link everything up.

Wim Leers’s picture

Can we move this forward? If not, what is it blocked on?

Mile23’s picture

Status: Needs review » Needs work
Related issues: +#2607260: [meta] Core deprecation message introduction, contrib testing etc.

It would need to honor --suppress-deprecations instead of adding its own flag, and try to honor SYMFONY_DEPRECATIONS_HELPER too.

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

Drupal 8.5.0-alpha1 will be released the week of January 17, 2018, which means new developments and disruptive changes should now 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.6.x-dev » 8.7.x-dev

Drupal 8.6.0-alpha1 will be released the week of July 16, 2018, which means new developments and disruptive changes should now 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.7.x-dev » 8.8.x-dev

Drupal 8.7.0-alpha1 will be released the week of March 11, 2019, which means new developments and disruptive changes should now be targeted against the 8.8.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Mile23’s picture