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
ExtensionDiscovery::getProfileDirectories()
explicitly skips the simpletest parent installation profile processing in the installer, which seemingly defeats the entire purpose of that environment value:
// For SimpleTest to be able to test modules packaged together with a // distribution we need to include the profile of the parent site (in // which test runs are triggered). // @todo !drupal_installation_attempted() defeats the whole purpose? if (drupal_valid_test_ua() && !drupal_installation_attempted()) { $testing_profile = \Drupal::config('simpletest.settings')->get('parent_profile');
(Note the code comment.)
- This means that additional modules that may be provided by an installation profile are not actually discovered when Drupal is installed in a web test.
Comment | File | Size | Author |
---|---|---|---|
#32 | 2175391-31-test-only.patch | 1.28 KB | rpayanm |
#28 | 2175391-28.patch | 4.11 KB | rpayanm |
#25 | 2175391-25.patch | 4.13 KB | rpayanm |
#25 | 2175391-interdiff.txt | 1.1 KB | rpayanm |
#23 | 2175391-23.patch | 4.13 KB | rpayanm |
Comments
Comment #1
tstoecklerSo I looked and we have InstallationProfileModuleTestsTest which sort of tests this behavior. I'm not 100% sure, though. Can you elaborate why that test is not sufficient?
Comment #2
sunI wasn't aware that there is a InstallationProfileModuleTestsTest for this.
Need to study the situation some more.
Comment #3
sunHah. I actually authored that test myself ;)
This facility was originally introduced in #911354: Tests in profiles/[name]/modules cannot be run and cannot use a different profile for running tests
The original patch did not contain the additional
!drupal_installation_attempted()
condition.The important test is
OtherInstallationProfileModuleTestsTest
.However, studying those tests, I've the impression that the assertions are very poor/fragile and can easily result in false-positive test results.
Comment #4
sunFor starters.
Comment #6
sunI see. So it looks like that condition was added when
Config\InstallStorage
started to throw exceptions when trying to read config files that do not exist.As part of #2186491: [meta] D8 Extension System: Discovery/Listing/Info, I wanted to convert this into a setting either way, so let's simply do that here.
Comment #7
sunComment #8
BerdirNice, verified that this fixes the bug that #911354: Tests in profiles/[name]/modules cannot be run and cannot use a different profile for running tests was supposed to fix but got re-introduced. I can run tests of a module in a profiles/some_profile/modules folder with this patch and it does not work on HEAD.
Changes look fine, much cleaner than when using config, no need to document this, as it's just used internally.
Comment #9
alexpottWe need some tests here - also discovered #2217781: Can only run tests from the installed profile.
Comment #10
sun@alexpott: That is super-tricky...
In order to test this, we would need a second testing installation profile in core, which ships with a custom test module in its own ./modules subdirectory, and that module needs to ship with a test.
Only in that way, there can be a test class that is located in the module of testing2 profile, and which uses the testing profile for running tests, but still has access to the module code located in testing2 profile.
The already existing
OtherInstallationProfileModuleTestsTest
was supposed to cover this scenario, but given that we do not have a second testing profile in core, today I understand why that did not catch the problem (as outlined above).I'm not sure whether we really want to have a second testing2 profile in core...
Comment #11
Berdir6: drupal8.test-parent-profile.6.patch queued for re-testing.
Comment #13
BerdirRe-roll. Yeah, not sure how to do test this...
Comment #14
sun13: drupal8.ext-disco-parent-profile-2175391-4.patch queued for re-testing.
Comment #16
sunRe-rolled.
Also studied the situation regarding testability some more:
We would not only have to introduce a second testing profile, this new testing profile would additionally have to specify a (testing) module from a different profile as a dependency (so that the module is actually required in the installer).
I.e., in essence:
A second testing profile just for testing this would be pretty heavy, IMO...
Comment #17
sunActually, I figured out a way to unit test this.
Comment #19
tstoecklerNice job on the test! Can you upload a test-only patch to prove it works?
Comment #20
sunComment #21
jhedstromNeeds reroll, and the test-only patch shouldn't pass without the fix.
Comment #22
jhedstromComment #23
rpayanmComment #25
rpayanmtrying again!
Comment #26
rpayanmComment #27
jhedstromShould be a new line at the end.
Comment #28
rpayanmfixed :)
Comment #29
jhedstrom@rpayanm could you upload the test as a separate patch to illustrate the fix?
Comment #30
rpayanmTesting is not my forte :(
I said it "fixed" so you told me in #27.
Comment #31
jhedstrom@rpayanm you can generate a patch of just the test using:
This is just to insure that the added test addresses the issue at hand.
Comment #32
rpayanm@jhedstrom thank you, here it is :)
Comment #36
mgiffordPatch no longer applies.
Comment #37
mpotter CreditAttribution: mpotter at Phase2 commentedAnybody know why this issue got stalled? It looks like the patch was tested but then this wasn't ever marked RTBC so it got lost in the cracks? I could re-roll the patch if necessary, but wonder how this special case for simpletest should be potentially combined with a more general handling of additional profile directories proposed in #1356276: Allow profiles to define a base/parent profile
Comment #38
jhedstrom@mpotter I think it was stalled first when it needed re-rolling, but secondly, the 'test only' patch in #20 and #32 passed, indicating it isn't testing what we think it's testing (or if it is, the issue is somehow fixed).
Comment #52
quietone CreditAttribution: quietone at PreviousNext commentedI skimmed the comments and see that in #38 this has either been fixed or the test is not testing what it should be. That comment was 7 years ago. There has been no further discussion here which may suggest that this has, indeed, been fixed.
I did some research and found that the code changed in the patch (not the test) was removed from core in #3081501: Remove TestSetupTrait::$originalProfile and test infrastructure which uses it. As for the test, there is similar testing done in \Drupal\Tests\system\Kernel\Common\SystemListingTest::testFileScanIgnoreDirectory which seems to be showing the modules in install profiles are discovered. So, this does appear to be outdated.
I will check in #bugsmash. For now, setting to PMNMI.
Comment #54
quietone CreditAttribution: quietone at PreviousNext commentedThere has been no further discussion to suggest that this is still a problem. Therefor, closing as outdated based on #52.