Problem/Motivation
We execute run-test.sh during CI runs. After an upgrade to PHP 8.1 the test pipeline did not fail although no tests were executed and there was a fatal TypeError.
Steps to reproduce
1. Remove the "static" keyword from a Simpletest test case method getInfo()
2. Execute run-tests.sh to get an error like "TypeError: call_user_func(): Argument #1 ($callback) must be a valid callback, non-static method PrivatemsgEMailNotifyTestCase::getInfo() cannot be called statically in simpletest_test_get_all() (line 372 of /var/www/html/modules/simpletest/simpletest.module)." For example: ddev exec php ./scripts/run-tests.sh --verbose Jobiqo
3. notice that the exit code is 0 for success, which is bad because that indicates that there was no error.
Proposed resolution
Exit with status code 1 in _drupal_log_error() for CLI scripts.
Merge request link
Remaining tasks
Merge request review
User interface changes
API changes
Data model changes
Release notes snippet
Issue fork drupal-3420076
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
Comment #3
klausiMerge request created.
Comment #4
poker10 commentedThanks for reporting/working on this. The same change seems to be already in D10, see: #2927012: _drupal_log_error() returns a 0 exit code on errors, so I think this looks good.
Not sure if we can easily backport the test from D10, as we do not have
PhpProcess. Any thoughts? Did not have time to look at that more thoroughly yet.Comment #5
klausiHey nice find!
We could copy the code from Symfony Process for the test, but not sure if it is worth it to try to port that somehow?
I would say we can commit this without test, since it does not affect end users and is just for command line invocations.
Comment #6
tibezh commentedLooks good, I think we can merge this small change.
Comment #7
mcdruid commentedI don't think we need to jump through hoops to backport the test to D7.
However, per #2927012-33: _drupal_log_error() returns a 0 exit code on errors it deserves a Change Record as it may cause a change in the behaviour of tests.
Comment #8
poker10 commentedI have created a draft CR for D7: https://www.drupal.org/node/3438765 (it is mostly the copy from the D8 CR).
Comment #10
mcdruid commentedThanks everyone!