Problem/Motivation
When setting up testing on a Drupal installation it's pretty easy to accicentally enter an invalid value in phpunit.xml. One fault i've seen happen quite a few times is entering the database uri that is support to go in SIMPLETEST_DB
into the wrong variable SIMPLETEST_BASE_URL
.
The problem is this results in a segmentation fault while running tests, which really is not helpfull. Unless you have seen this before resolving this is quite a timesink. I'm not sure if this only happened with apache-php, but it might.
Output you see:
PHPUnit 9.5.4 by Sebastian Bergmann and contributors.
Warning: Your XML configuration validates against a deprecated schema.
Suggestion: Migrate your XML configuration using "--migrate-configuration"!
Testing Drupal\Tests\wordproof\Kernel\TimestampRepositoryTest
ERESegmentation fault
Steps to reproduce
Enter the datbase dsn (mysql://username:password/...) into the SIMPLETEST_BASE_URL
env variable or phpunit.xml. This will result in a segementation fault.
Proposed resolution
Add a validation of the scheme of the base url. We parse the url anyways, so there is little overhead to check for http(s).
Issue fork drupal-3217374
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 #2
bbralaComment #3
bbralaSomething interesting about this is that the
run-tests.sh
actually does add either http or https. Perhaps the only place it needs fixing is the FunctionalTestSetupTrait.php.Comment #5
daffie CreditAttribution: daffie commented@bbrala: Thank you for the bug report and the MR. To get committed the change in the MR also needs an automated test. I think that the test can best be added to the test class Drupal\FunctionalTests\BrowserTestBaseTest. Set the variable with the command
putenv("SIMPLETEST_BASE_URL=somewrongurl");
and then set the expected exception with$this->expectDeprecation()
and as last call the method$this->setupBaseUrl()
.Comment #6
bbralaAh, i was wondering how i would test this, i'll have a look, thanks for the suggestion.
Comment #7
daffie CreditAttribution: daffie commentedThe testbot is not happy with the extra empty line.
Comment #8
bbralaEverything should be resolved now :)
Comment #9
bbralaComment #10
daffie CreditAttribution: daffie commentedAll code changes look good to me.
The bugfix has testing.
For me it is RTBC.
Comment #13
catchCommitted/pushed to 9.3.x and cherry-picked to 9.2.x, thanks!