Problem/Motivation
The TestRunnerKernel hardwires the module list to system and simpletest. Good luck implementing a hook in these circumstances.
We also want to deprecate the dependency between the testing system and the simpletest module: #2863044: [plan] Remove simpletest dependencies from PHPUnit-based tests
TestDiscovery has a dependency on the module handler only so that it can fire this hook. When this dependency is deprecated (in this issue) we can then work on #2863055: Move TestDiscovery out of simpletest module, minimize dependencies
Proposed resolution
Deprecate the hook for removal before Drupal 9. drivers get a chance in #2459745: Allow the database driver to skip test classes modules don't.
Remaining tasks
Remove invocations of this hook in Drupal 9.
User interface changes
None.
API changes
Deprecate hook_simpletest_alter().
| Comment | File | Size | Author |
|---|---|---|---|
| #49 | 2460521_49.patch | 4.13 KB | mile23 |
| #46 | interdiff.txt | 1.88 KB | mile23 |
| #46 | 2460521_46.patch | 4.14 KB | mile23 |
| #43 | interdiff.txt | 584 bytes | mile23 |
| #43 | 2460521_43.patch | 4.06 KB | mile23 |
Comments
Comment #1
dawehnerWell, you could really ask yourself wether the hook is the way to do it, given that it requires a proper parent site.
Given that the settings override in settings.testing.php seems great for me.
Note: Also #2304461: KernelTestBaseTNG™ and #2232861: Create BrowserTestBase for web-testing on top of Mink might make this harder than currently.
Comment #2
chx commentedHere's one possible patch.
Comment #3
larowlanThis sentence doesn't make sense
Thought some more about the intent here - could we have a new annotation on test classes @unsupportedDrivers - which took an array of driver names, defaulting to none?
Then we could tag tests that weren't supported by a given driver.
Comment #4
chx commentedYes, I missed the verb, would
work?
Regarding the annotation: that won't work -- you do not know the drivers ahead of the time. Like, the Oracle driver didn't even start a D8 version yet. And that's just the DB drivers -- efq_views might want to override what mongodb doesn't support for example. It needs to be a hook or similar.
Also, this solution allows for adding modules to the TestRunnerKernel which currently requires very ... ahem ... interesting code which I would rather not ship.
Comment #5
chx commentedAlso, the driver issues is at #2459745: Allow the database driver to skip test classes and I feel it's a different issue to this.
Comment #6
chx commentedI've completely rewritten the doxygen.
Comment #7
chx commentedMore cowbell! (Actually, comments in TestRunnerKernel)
Comment #8
dawehnerAs written in IRC it would be great to explain WHY those module data has to be provided ... this hook is executed outside of an installed drupal site, so you don't have the modules with the alter hook available in the first place.
Comment #9
chx commentedAnother attempt.
Comment #10
dawehnerThank you!
Comment #11
alexpottAt the very least we're missing a pointer to this in hook_simpletest_alter.
But for me this approach doesn't feel right. i think we should not use alters for this at all. There should be only one way to achieve this and using hooks means that it'll work when you have a full drupal test runner but then you'll have to know to add this extra stuff to settings.php.
Comment #12
chx commented> At the very least we're missing a pointer to this in hook_simpletest_alter.
I do not quite understand. A pointer to what? All the new documentation is on hook_simpletest_alter.
And I am glad to accept better alternatives. List of callbacks in settings.php perhaps?
Comment #13
chx commentedComment #14
moshe weitzman commentedIMO it is valid for a hosting platform to ship with a module that skips certain tests. Similarly, a custom web site might skip Drupal core or contrib tests that it does not care about. Ideally we could specify individual classes to skip because skipping a whole module is reckless overkill Anyway, I just want to articulate use cases beyond DB drivers.
Comment #15
mgiffordRe-uploading patch for the bots.
Comment #19
dawehnerI think we should let this later hook just die away. In phpunit you can ignore certain tests using https://stackoverflow.com/questions/22645986/phpunit-testsuite-exclude
so if you want to run the entire core test suite you could ignore the tests by writing your own
phpunit.xmlfile.Comment #20
mile23Comment #21
mile23Changing to 8.4.x because it's disruptive.
Comment #23
mile23Testbot burp.
Comment #25
mile23Lets postpone on #2866779: Add a way to trigger_error() for deprecated hooks like #2234479: Deprecate hook_test_* hooks in simpletest
Comment #26
mile23And, just like #2234479: Deprecate hook_test_* hooks in simpletest we can unpostpone because #2866779: Add a way to trigger_error() for deprecated hooks is now postponed because core doesn't actually deal with the
trigger_error()yet.Added @todo for #2866779: Add a way to trigger_error() for deprecated hooks
Comment #27
dawehnerGetting at least this information about is a good step.
Comment #28
alexpottHook deprecation hasn't really been tackled in the deprecation policy but I think we should try and think about how it should be done. I think we need a followup to discuss this. Also there is no change record yet.
Comment #29
mile23Here's a plan for it: #2870058: [policy, no patch] Document how to deprecate hooks
Comment #30
mile23Postponed on #2866779: Add a way to trigger_error() for deprecated hooks
Comment #31
mile23Comment #33
mile23#2866779: Add a way to trigger_error() for deprecated hooks is in, so we're unpostponed here.
Comment #35
mile23Added change record.
I'm not sure what the follow-up was supposed to be.
Here's a patch against 8.6.x.
Comment #36
mile23Comment #37
mile23This isn't true. There are two reasons
run-tests.shneeds simpletest module enabled: 1)TestDiscoverydepends onModuleHandlerso it can fire this hook and, 2) Functions insimpletest.module. The hook is not fired from the PHPUnit tool so I got that right.I was thinking of #2234479: Deprecate hook_test_* hooks in simpletest when I wrote that.
Comment #38
dawehner@Mile23 Do you understand why this fails?
Comment #39
mile23It has a ton of these: "Drupal\Core\Database\DatabaseNotFoundException: SQLSTATE[HY000] [1049] Unknown database 'jenkins_drupal_patches_46060'"
That has always looked like a testbot failure to me.
Re-running.
Comment #40
mile23It turns out it was a testbot failure.
Fixed the docblock and added a test.
Comment #41
mile23Updated IS.
Comment #42
dawehner@Mile23
Do you mind linking to the change record inside the code?
Comment #43
mile23Ah, good catch.
Comment #44
dawehnerThank you @Mile23!
Comment #45
alexpottThe deprecation message should contain a link to the change record. Since this allows us to keep the change record up-to-date with any additional info discovered after committing this.
Comment #46
mile23Updated per #45
Comment #47
dawehnerThank you!
Comment #49
mile23Re-rolled after the reversion of #2893117: Improve HTML caching of Simpletest UI test form
Comment #50
mile23Comment #51
borisson_Still applies, was already RTBC in #47.
Comment #52
alexpottCommitted d208812 and pushed to 8.6.x. Thanks!
In reference to #14 - one thing that I think we should try to state somewhere is that core's tests are for core. The idea of a site running them to see if it works is not a good one. There are tests that are designed to be extended like
\Drupal\KernelTests\Core\Cache\GenericCacheBackendUnitTestBasebut you don't need an alter hook for that.