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
Comment | File | Size | Author |
---|---|---|---|
#2 | 2904566_2.patch | 5.7 KB | Mile23 |
Comments
Comment #2
Mile23Patch.
You can see it in action with a test run like this:
This will open the browser and show you a helpful error message for your failed test:
Remove
--fail-on-deprecated
and you'll see a notice in the test log, but not a fail.Comment #3
Mile23Comment #4
alexpottThis 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.
Comment #5
Wim LeersCan we move this forward? If not, what is it blocked on?
Comment #6
Mile23It would need to honor
--suppress-deprecations
instead of adding its own flag, and try to honorSYMFONY_DEPRECATIONS_HELPER
too.Comment #10
Mile23WTB does this correctly now after #2870194: Ensure that process-isolated tests can use Symfony's PHPunit bridge to catch usages of deprecated code and #2863055: Move TestDiscovery out of simpletest module, minimize dependencies.