Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Problem/Motivation
The hold_test module creates files in
\Drupal::root() . '/sites/default/files/simpletest/'
so they are not test environment specific which means that two tests using this module can have random fails when run together.
For example: \Drupal\Tests\quickedit\FunctionalJavascript\QuickEditIntegrationTest and \Drupal\FunctionalJavascriptTests\Ajax\ThrobberTest
Proposed resolution
Use the test sites public files directory.
Remaining tasks
User interface changes
API changes
Data model changes
Release notes snippet
Comment | File | Size | Author |
---|---|---|---|
#12 | 3175112-12.patch | 1.46 KB | andypost |
#3 | 3175112-3.patch | 2.78 KB | alexpott |
Comments
Comment #2
longwaveOh, nice find. MultipleFileUploadTest seems similarly affected, but maybe not a problem here:
Comment #3
alexpottRE #2 I think we should tackle that in a follow-up. I think we need to deprecate this directory. It's created in \Drupal\Core\Test\TestRunnerKernel::boot() - I think we need to ensure it is empty and issue a deprecation if not and then we can remove it.
Here's a patch to fix the potential random fail. It places the file in the site directory and not the files directory as this is writable under testing and keeps these files out of harms way. Plus they'll now be tidied up after the tests.
Comment #4
alexpottI created the follow-up for the more general issue - see #3175141: Deprecate sites/default/files/simpletest
Comment #5
longwaveChanges here look great, also +1 to removing the possibility of a race condition here entirely in the followup.
Comment #9
catchGood chance this fixes #3037436: [random test failure] Make QuickEditIntegrationTest more robust and fail proof, which would be amazing, possibly the most long-running random test failure.
Committed 5e27a9f and pushed to 9.1.x. Backported to 9.0.x and 8.9.x too.
Comment #10
TR CreditAttribution: TR commentedThis commit causes core 8.9.x tests to fail (https://www.drupal.org/node/3060/qa) because site.path hasn't been backported to D8 yet. See #3074585: [Symfony 5] Replace app.root and site.path string services with container parameters
Re-opening and moving to critical, as core tests are failing because of this.
Comment #11
andypostComment #12
andypostIt makes pass following tests locally
-
core/tests/Drupal/FunctionalJavascriptTests/Ajax/ThrobberTest.php
-
core/modules/quickedit/tests/src/FunctionalJavascript/QuickEditIntegrationTest.php
Comment #13
alexpottThis fix looks great.
Comment #14
alexpottCommitted bd65826 and pushed to 8.9.x. Thanks!
Comment #16
alexpott