Problem/Motivation

This issue supports #2807237: PHPUnit initiative

It's a child of #2863044: [plan] Remove simpletest dependencies from PHPUnit-based tests

We have a long-standing issue about removing the caching of results in TestDiscovery: #1667822: Remove caching of test classes in TestDiscovery

We also have a need to remove TestDiscovery from the simpletest module context. Currently it's a service defined by simpletest module, but is only used as a service by simpletest module's test list form, which we want to phase out. It's used as a class by behaviors we want to keep, such as TestSuiteBase and run-tests.sh.

TestDiscovery also declares a dependency on ModuleHandlerInterface which is used to support hook_simpletest_alter(). chx wants to remove that hook, do YOU? #2460521: Deprecate hook_simpletest_alter()

Proposed resolution

Turn TestDiscovery into a lean, mean, test discovering machine, with few external dependencies.

Keep a deprecated semi-stub Drupal\simpletest\TestDiscovery class which subclasses the new one. This allows BC for code which passes the dependencies. This simpletest subclass is also responsible for invoking simpletest module's hooks and performs caching for consistent behavior.

Have the new class not cache results beyond static, because developers are adding and moving tests all the time, and will need to invalidate the cache every time they do. The cache system is also a dependency which TestDiscovery currently manages as a special case, so this amounts to removing that special case. Work underway here: #1667822: Remove caching of test classes in TestDiscovery

Move TestDiscovery outside of the simpletest module context, so it's not dependent on the module. Also move MissingGroupException which it depends on. Move them to core/tests.

Remaining tasks

User interface changes

API changes

Data model changes

CommentFileSizeAuthor
#79 interdiff.txt2.17 KBMile23
#79 2863055_79.patch79.89 KBMile23
#77 interdiff.txt21.34 KBMile23
#77 2863055_77.patch77.96 KBMile23
#75 interdiff-2863055-72-75.txt470 bytesmartin107
#75 2863055-75.patch61.17 KBmartin107
#72 2863055-72.patch61.18 KBmartin107
#68 2863055-68.patch61.14 KBLendude
#68 interdiff-2863055-66-68.txt477 bytesLendude
#66 2863055-66.patch61.16 KBLendude
#66 interdiff-2863055-65-66.txt420 bytesLendude
#65 interdiff.txt54.12 KBMile23
#65 2863055_65.patch61.19 KBMile23
#64 interdiff.txt1.86 KBMile23
#64 2863055_64.patch115.31 KBMile23
#63 interdiff.txt1.01 KBMile23
#63 2863055_63.patch42.75 KBMile23
#62 interdiff.txt43.17 KBMile23
#62 2863055_62.patch42.95 KBMile23
#56 2863055_56.patch44.09 KBMile23
#53 interdiff.txt2.75 KBMile23
#53 2863055_53.patch44.09 KBMile23
#51 interdiff.txt7.15 KBMile23
#51 2863055_51.patch44.4 KBMile23
#47 2863055_47.patch42.42 KBMile23
#43 interdiff.txt11.19 KBMile23
#43 2863055_43.patch29.08 KBMile23
#41 interdiff.txt237 bytesMile23
#41 2863055_41.patch41.79 KBMile23
#39 2863055_39.patch42.02 KBMile23
#24 interdiff.txt1.93 KBMile23
#24 2863055_24.patch29.96 KBMile23
#21 interdiff.txt3.13 KBMile23
#21 2863055_21.patch30.43 KBMile23
#12 2863055_12.patch29.44 KBMile23
#10 interdiff.txt954 bytesMile23
#10 2863055_10.patch29.63 KBMile23
#8 interdiff.txt5.79 KBMile23
#8 2863055_8.patch28.98 KBMile23
#6 interdiff_2_5.txt1.04 KBMile23
#5 2863055_5.patch25.6 KBMile23
#2 2863055_2.patch25.55 KBMile23
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Mile23 created an issue. See original summary.

Mile23’s picture

Issue summary: View changes
Status: Active » Needs review
FileSize
25.55 KB

This patch makes a stub TestDiscovery in simpletest which still does caching and calling hooks. The core TestDiscovery only finds tests.

It also fixes TestInfoParsingTest, which erroneously has a test method on a stub class instead of the test class.

This fails locally for a few tests, mostly because of race conditions having to do with timing out building the UI test list. That is: The main consumer of the TestDiscovery cached results is tests of the form that shows the tests.

Let's see how the testbot fares.

Mile23’s picture

Issue summary: View changes
klausi’s picture

Status: Needs review » Needs work
  1. +++ b/core/modules/simpletest/src/TestDiscovery.php
    @@ -74,416 +46,38 @@ class TestDiscovery {
    +  protected function alterHook(&$test_list) {
    +    // Allow modules extending core tests to disable originals.
    +    $this->moduleHandler->alter('simpletest', $list);
       }
    

    Shouldn't you pass $test_list to the module handler, not $list?

  2. +++ b/core/modules/simpletest/tests/src/Unit/TestInfoParsingTest.php
    @@ -410,6 +393,26 @@ public function providerTestGetPhpunitTestSuite() {
       }
    +  ¶
    +}
    

    trailing white space

Out of curiosity I checked for a test runtime regressions with an example:
../vendor/bin/phpunit --filter AccessManagerTest
That finishes in roughly 7 seconds before and after the patch, so I see no performance problem with this patch.

Keeping hook_simpletest_alter() in the simpletest specific TestDiscovery makes sense to me. I don't understand why we want to keep the cache in the Simpletest version and not just remove it completely. Because the Simpletest UI interacts with it and would be slow?

Mile23’s picture

Status: Needs work » Needs review
FileSize
25.6 KB

Keeping hook_simpletest_alter() in the simpletest specific TestDiscovery makes sense to me.

There's a little bit of problem with that, though, because the problem from #2460521: Deprecate hook_simpletest_alter() is that the hook isn't running from CLI (apparently). Part of the reason we'd be doing this refactor is so the CLI can avoid a dependency on ModuleHandler.

But we still need a way to satisfy the hook_simpletest_alter() use case, even if it's running from the CLI or other low-dependency environment. At some point, all the core simpletest will be converted, and database tests could say @requires postgre or whatever, but that still leaves contrib.

I don't understand why we want to keep the cache in the Simpletest version and not just remove it completely. Because the Simpletest UI interacts with it and would be slow?

1) For the purposes of this issue, we still want the same behavior, just refactored. We can make decisions about the cache in #1667822: Remove caching of test classes in TestDiscovery

2) I initially left it out, but tests were failing locally. It was all the usual suspects, such as SimpleTestBrowserTest. These tests run testception within the UI, and were timing out. Adding the cache back helped them pass, because the margin was large enough that it mattered.

This patch fixes concerns from #4.

Mile23’s picture

FileSize
1.04 KB

Forgot interdiff.

dawehner’s picture

Just some super quick comment.

  1. +++ b/core/lib/Drupal/Core/Test/TestDiscovery.php
    index 85a0696ca1..f90c74c75e 100644
    --- a/core/modules/simpletest/src/Exception/MissingGroupException.php
    
    --- a/core/modules/simpletest/src/Exception/MissingGroupException.php
    +++ b/core/modules/simpletest/src/Exception/MissingGroupException.php
    
    +++ b/core/modules/simpletest/src/Exception/MissingGroupException.php
    +++ b/core/modules/simpletest/src/Exception/MissingGroupException.php
    @@ -2,8 +2,10 @@
    
    @@ -2,8 +2,10 @@
     
     namespace Drupal\simpletest\Exception;
     
    +use Drupal\Core\Test\Exception\MissingGroupException as CoreMissingGroupException;
    +
     /**
      * Exception thrown when a simpletest class is missing an @group annotation.
      */
    -class MissingGroupException extends \LogicException {
    +class MissingGroupException extends CoreMissingGroupException {
     }
    

    Should we deprecate this exception?

  2. +++ b/core/modules/simpletest/src/TestDiscovery.php
    @@ -2,27 +2,20 @@
    + *
    + * This class provides backwards compatibility for code which uses the legacy
    + * \Drupal\simpletest\TestDiscovery.
    + *
    + * @deprecated in Drupal 8.4.x, will be removed before Drupal 9.0.0. Use
    + *   Drupal\Core\Test\TestDiscovery instead.
      */
    ...
    +class TestDiscovery extends CoreTestDiscovery {
    

    When we deprecate something we should call out to trigger_error() now, see https://www.drupal.org/core/deprecation

Mile23’s picture

Added trigger_error(), including an incomplete test to check whether the deprecation worked. See #2488860: Bring phpunit bridge into drupal and use it for unit tests and simpletest to handle Deprecation

Moved and renamed some tests because we're testing the class, not one method.

Status: Needs review » Needs work

The last submitted patch, 8: 2863055_8.patch, failed testing.

Mile23’s picture

Status: Needs work » Needs review
FileSize
29.63 KB
954 bytes

I guess I *didn't* try and run that test locally. Thought I did.

Mile23’s picture

Mile23’s picture

Needed reroll.

dawehner’s picture

I really like how this patch allows us to move towards a more simple testing system, even on the longrun I hope we get rid of some of those aspects.
To be honest I'm wondering whether we can really get rid of caching ...

Mile23’s picture

Thanks.

There's no use case where we need to discover tests more than once per request, other than when we test the UI form to make sure the form can discover tests and display them. And of course there's a use case where we *shouldn't* cache the list, because then the UI keeps the old discovered data even if the tests have changed.

Since it takes a really long time to generate the form *after* the files are discovered, it's possible to time out, depending on how fast your computer is. I did some timing research in #1667822-17: Remove caching of test classes in TestDiscovery

For now, we can leave it for consistency and make a determination in that other issue.

dawehner’s picture

There's no use case where we need to discover tests more than once per request, other than when we test the UI form to make sure the form can discover tests and display them. And of course there's a use case where we *shouldn't* cache the list, because then the UI keeps the old discovered data even if the tests have changed.

This is a good point!

Mile23’s picture

Issue summary: View changes
alexpott’s picture

+++ b/core/modules/simpletest/simpletest.services.yml
@@ -1,4 +1,6 @@
   test_discovery:
+    # @todo Change this service so that it uses \Drupal\Core\Test\TestDiscovery
+    # in https://www.drupal.org/node/1667822
     class: Drupal\simpletest\TestDiscovery
     arguments: ['@app.root', '@class_loader', '@module_handler', '@?cache.discovery']

Why wouldn't we swap to using the non-deprecated code here?

Mile23’s picture

@alexpott #17... Only simpletest module uses that service, and only uses it to build the testing UI form. See #14... We need the caching for the UI form at present, because otherwise tests of the UI form time out due to repeated renders.

We can remove usages of the deprecated Drupal\simpletest\TestDiscovery in a follow-up, which is normal deprecation anyway. Probably here: #1667822: Remove caching of test classes in TestDiscovery

Mile23’s picture

Patch still applies. Re-running test.

Status: Needs review » Needs work

The last submitted patch, 12: 2863055_12.patch, failed testing.

Mile23’s picture

Status: Needs work » Needs review
FileSize
30.43 KB
3.13 KB

Fixing the failing test from #12 reveals a couple of interesting problems:

One is that it looks like kernel tests are swallowing the E_USER_DEPRECATION messages in some way, such that the thrown error remains but the message does not. I'm not sure where the problem might be for this.

Another is that DrupalStandardsListener calls class_exists() for @coversDefaultClass. This causes the deprecated class file to be loaded outside the context of a test, and @trigger_error() gets called. The phpunit-bridge error handler is still around, so we get a deprecation error.

The hacky-seeming solution is to add @group legacy to the listener method.

Note that the test probably still won't pass. It just *should* pass. :-)

Status: Needs review » Needs work

The last submitted patch, 21: 2863055_21.patch, failed testing.

Mile23’s picture

Added an issue about deprecations and DrupalStandardsListener: #2878248: DrupalStandardsListener improper handling of @trigger_error() deprecation

Mile23’s picture

Status: Needs work » Needs review
FileSize
29.96 KB
1.93 KB

Re-rolled after #2878248: DrupalStandardsListener improper handling of @trigger_error() deprecation, moved the failing test to be a unit test.

Mile23’s picture

Patch still applies, re-running test.

Mile23’s picture

Version: 8.4.x-dev » 8.5.x-dev

Drupal 8.4.0-alpha1 will be released the week of July 31, 2017, which means new developments and disruptive changes should now be targeted against the 8.5.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Mile23’s picture

Issue tags: +Needs reroll
jofitz’s picture

Status: Needs review » Needs work
Ivan Berezhnov’s picture

Issue tags: +CSKyiv18

Version: 8.5.x-dev » 8.6.x-dev

Drupal 8.5.0-alpha1 will be released the week of January 17, 2018, which means new developments and disruptive changes should now be targeted against the 8.6.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

mohit1604’s picture

Assigned: Unassigned » mohit1604
mohit1604’s picture

Assigned: mohit1604 » Unassigned

Applying patch #24 for version 8.4.x shows following error :

error: patch failed: core/modules/simpletest/src/TestDiscovery.php:309
error: core/modules/simpletest/src/TestDiscovery.php: patch does not apply
error: patch failed: core/modules/simpletest/src/TestDiscovery.php:74
error: core/modules/simpletest/src/TestDiscovery.php: patch does not apply
error: core/modules/simpletest/tests/src/Unit/TestDiscoveryTest.php: already exists in working directory
error: core/modules/simpletest/tests/src/Unit/TestInfoParsingTest.php: No such file or directory
error: patch failed: core/tests/TestSuites/TestSuiteBase.php:1
error: core/tests/TestSuites/TestSuiteBase.php: patch does not apply

martin107’s picture

@Mohit Malik, this issue has a tag "Needs reroll" which is a signal that the patch no longer applies.

Happily there are people in the community who act on this signal

Mile23’s picture

Status: Needs work » Postponed

This will need rerolls for #2893117: Improve HTML caching of Simpletest UI test form and/or #1667822: Remove caching of test classes in TestDiscovery

Those will decide what to do with TestDiscovery's use of cache services.

I'm calling this one postponed on those, because we might not need to make a second TestDiscovery service class just for simpletest module.

Mile23’s picture

#2893117: Improve HTML caching of Simpletest UI test form is in, and it removes the persistent caching from TestDiscovery.

This leaves us with one service dependency in TestDiscovery: ModuleHandler. We only use ModuleHandler to fire hook_simpletest_alter(), which is basically unused at this point and will likely be deprecated in #2460521: Deprecate hook_simpletest_alter()

Let's stay postponed here until #2460521: Deprecate hook_simpletest_alter() is implemented.

Mile23’s picture

Mile23’s picture

Mile23’s picture

Status: Postponed » Needs review
FileSize
42.02 KB

#2893117: Improve HTML caching of Simpletest UI test form is back in.

Reroll plus very minor changes.

Status: Needs review » Needs work

The last submitted patch, 39: 2863055_39.patch, failed testing. View results

Mile23’s picture

Status: Needs work » Needs review
Issue tags: -Needs reroll
FileSize
41.79 KB
237 bytes

Let's try that without a .DS_Store file.

Status: Needs review » Needs work

The last submitted patch, 41: 2863055_41.patch, failed testing. View results
- codesniffer_fixes.patch Interdiff of automated coding standards fixes only.

Mile23’s picture

Status: Needs work » Needs review
Issue tags: +Needs followup
FileSize
29.08 KB
11.19 KB

Added CR.

Adding @trigger_error() to Drupal\simpletest\TestDiscovery fails all tests which a) enable Simpletest module and b) use services, which is most functional tests. So I took it back out. We'll need a follow-up against D9 to add that (if at all).

Mile23’s picture

Patch still applies. Re-running tests.

Version: 8.6.x-dev » 8.7.x-dev

Drupal 8.6.0-alpha1 will be released the week of July 16, 2018, which means new developments and disruptive changes should now be targeted against the 8.7.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.7.x-dev » 8.8.x-dev

Drupal 8.7.0-alpha1 will be released the week of March 11, 2019, which means new developments and disruptive changes should now be targeted against the 8.8.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Mile23’s picture

Re-roll, setting to 8.7.x because this is a testing improvement.

andypost’s picture

  1. +++ b/core/lib/Drupal/Core/Test/TestDiscovery.php
    @@ -0,0 +1,487 @@
    +    $listing->setProfileDirectories([]);
    +    $extensions = $listing->scan('module', TRUE);
    +    $extensions += $listing->scan('profile', TRUE);
    +    $extensions += $listing->scan('theme', TRUE);
    

    makes sense to add theme engines, is there ability to configure it?

  2. +++ b/core/modules/simpletest/src/TestDiscovery.php
    @@ -76,429 +44,12 @@ public function __construct($root, $class_loader, ModuleHandlerInterface $module
    -   * Returns all available extensions.
    ...
    -  protected function getExtensions() {
    -    $listing = new ExtensionDiscovery($this->root);
    

    it could use core discovery (alterable) to allow other extension types, like db-drivers

andypost’s picture

I mean that simpletest means that core can bootstrap and probably already yep

Status: Needs review » Needs work

The last submitted patch, 47: 2863055_47.patch, failed testing. View results
- codesniffer_fixes.patch Interdiff of automated coding standards fixes only.

Mile23’s picture

Status: Needs work » Needs review
FileSize
44.4 KB
7.15 KB

Fail on #47.... SOOOOOO many deprecations.

Important subsequent changes, documented here because your future git log might not show them to you: #2296615: Accurately support multiple @groups per test class #2973127: Exclude *TestBase.php, *Trait.php and *Interface.php files from test discovery reflection #2949363: Impossible to make trigger_error in some files without test fails

The interdiff here is a catch-up with those issues. Git apparently doesn't think this is a file move, so the rebase was a reversion.

Since the service container now automatically triggers deprecation errors for services marked @deprecated and that makes things complicated, let's move formal deprecation of 'test_discovery' to a follow-up.

#48: TestDiscovery shouldn't be configurable. If theme engines can be testable then their tests should be discovered. Also I'm not quite sure why db drivers require alteration of extension discovery in order to have their tests discovered. They should use @requires and then we're done.

It seems like both of these are out of scope here anyway, since this is mostly a 1:1 move out of simpletest module.

#49: Not sure exactly what you mean... Ideally, we don't want to bootstrap core in order to run tests.

Also I still see #3034015: Class to test deprecation error for deprecated trait triggers deprecation error itself running tests locally.

Lendude’s picture

Just some nits I see

  1. +++ b/core/lib/Drupal/Core/Test/TestDiscovery.php
    @@ -0,0 +1,509 @@
    +   * @todo Remove this when we deprecate simpletest module.
    

    remove when we remove simpletest module I'd say, not deprecate.

  2. +++ b/core/modules/simpletest/src/Exception/MissingGroupException.php
    @@ -2,8 +2,19 @@
    +@trigger_error('Deprecated in Drupal 8.6.x for removal before Drupal 9.0.0 release. Use \Drupal\Core\Test\Exception\MissingGroupException instead. https://www.drupal.org/node/2949692', E_USER_DEPRECATED);
    ...
    + * @deprecated in Drupal 8.4.x for removal before Drupal 9.0.0 release. Use
    

    8.4/6.x => 8.7.x

  3. +++ b/core/tests/Drupal/Tests/Core/Test/TestDiscoveryTest.php
    @@ -433,7 +436,8 @@ public function testGetTestClassesWithSelectedTypes() {
    -      'example' => [],
    +      'example' => [
    +      ],
    

    unrelated, this is hard enough to read, lets make it as small as possible.

Other then that, I went through the move of TestDiscovery with FileMerge and it is indeed only a move of old to new with two changes:
- the removal of moduleHandler
- the addition of alterHook to provide BC in the new version

Annoying indeed that git doesn't detect this as a move as it makes the diff hard to read. *shrug*

Mile23’s picture

Thanks. Got the things.

Lendude’s picture

Status: Needs review » Reviewed & tested by the community

@Mile23 thanks, looks good to me, and would remove another blocker for removing Simpletest.

larowlan’s picture

Status: Reviewed & tested by the community » Needs work
Issue tags: +Needs reroll
error: patch failed: core/modules/simpletest/src/TestDiscovery.php:70
error: core/modules/simpletest/src/TestDiscovery.php: patch does not apply
make: *** [patch88] Error 1
Mile23’s picture

Status: Needs work » Needs review
Issue tags: -Needs reroll
FileSize
44.09 KB

Rerolled.

Lendude’s picture

Status: Needs review » Reviewed & tested by the community

Thanks, looks good, back to RTBC.

alexpott’s picture

Status: Reviewed & tested by the community » Needs work
  1. +++ b/core/lib/Drupal/Core/Test/TestDiscovery.php
    @@ -0,0 +1,512 @@
    +  /**
    +   * Allow subclasses to invoke module hooks on the test list.
    +   *
    +   * This method can manipulate the test list.
    +   *
    +   * @param array $test_list
    +   *   An array of tests keyed by the the group name.
    +   *
    +   * @todo Remove this when the simpletest module no longer needs to fire its
    +   *   hook.
    +   *
    +   * @see hook_simpletest_alter()
    +   * @see https://www.drupal.org/project/drupal/issues/2866082
    +   * @see https://www.drupal.org/node/2939892
    +   * @see https://www.drupal.org/node/2949692
    +   */
    +  protected function alterHook(&$test_list) {
    +    return;
    +  }
    

    I think this is really odd to include here. But I cant think of another way of doing this.

  2. +++ b/core/scripts/run-tests.sh
    @@ -19,7 +19,7 @@
    -use Drupal\simpletest\TestDiscovery;
    +use Drupal\Core\Test\TestDiscovery;
    
    +++ b/core/tests/TestSuites/TestSuiteBase.php
    @@ -2,7 +2,7 @@
    -use Drupal\simpletest\TestDiscovery;
    +use Drupal\Core\Test\TestDiscovery;
    

    I'm not sure we can make these changes yet as this means the hooks aren't fired for run-tests.sh or for phpunit - and they currently are - right?

Mile23’s picture

Re: #58: The hooks are only fired from the UI form handler. We have the alterHook() method only so that we can have BC for hook_simpletest_alter().

#2460521: Deprecate hook_simpletest_alter() and #2234479: Deprecate hook_test_* hooks in simpletest have the details.

In the CR for deprecating hook_simpletest_alter(), we tell people to quit using simpletest in favor of phpunit and then add a test listener instead of implementing the hook: https://www.drupal.org/node/2939892

Mile23’s picture

Status: Needs work » Needs review
alexpott’s picture

Status: Needs review » Needs work

hook_simpletest_alter() is triggered in run-tests.sh for sure.

Add


/**
 * Implements hook_simpletest_alter().
 */
function system_simpletest_alter(&$groups) {
  print __FUNCTION__ . "\n";
}

and use run-tests.sh to list all tests and you see

Available test groups & classes
-------------------------------

system_simpletest_alter
#slow
 - Drupal\KernelTests\Core\Extension\ModuleConfigureRouteTest
 - Drupal\Tests\settings_tray\FunctionalJavascript\SettingsTrayBlockFormTest
 - Drupal\Tests\simpletest\Functional\SimpletestUiTest
 - Drupal\Tests\system\Functional\Module\InstallUninstallTest
 - Drupal\Tests\system\Functional\Update\UpdatePathTestBaseFilledTest
 - Drupal\Tests\workspaces\Kernel\WorkspaceIntegrationTest
Access

As far as I can see you're right that these hook are not fired for PHP unit so yeah the change to TestSuiteBase is fine.

I think rather than adding an alterDefinitions method in the new core class we should override the whole TestDiscovery::getTestClasses() in \Drupal\simpletest\TestDiscovery that way the new core class never has any pretensions of alterability.

Mile23’s picture

Version: 8.7.x-dev » 8.8.x-dev
Status: Needs work » Needs review
FileSize
42.95 KB
43.17 KB

See the interdiff to see how old and crusty the #56 patch was. It didn't even account for #2949363: Impossible to make trigger_error in some files without test fails which is almost exactly a year ago.

Copypasting code back into \Drupal\simpletest\TestDiscovery for the special purpose of supporting a deprecated hook. Re-adding the tests for that code so we can maintain it. (I should put 'maintain' in air quotes.)

Un-deprecating \Drupal\simpletest\TestDiscovery because we don't actually have a replacement until we decide whether the UI and its test runner are to be deprecated. #2750461: Remove Simpletest UI because we don't want to maintain a graphical test runner (Also because if it does @trigger_error() then there are a bunch of deprecation errors that fail a bunch of simpletest-based tests, which we can't handle like we can with PHPUnit ones.)

Added a getTestDiscoveryMock() method to the simpletest version of TestDiscoveryTest, in order to get around the problem of that test file causing a deprecation error outside of the test context. (It declared a subclass of TestDiscovery.) But now I've removed the deprecation, and I think it's a better test anyway. Now it's in both TestDiscovery tests.

Also TestRunnerKernel no longer has a stealth dependency on simpletest module.

Mile23’s picture

Mile23’s picture

Reroll and fixed some deprecated test assertions.

Mile23’s picture

+++ b/core/scripts/run-tests copy.sh.php	

Woops.

Lendude’s picture

Status: Needs review » Reviewed & tested by the community
FileSize
420 bytes
61.16 KB

Feedback has been addressed, fixed a minor nit, went through this again and this seems like a good BC solution. I'm not convinced we need all the BC here (who uses the simpletest hooks? seriously?), but this seems the safe way to do it.

Status: Reviewed & tested by the community » Needs work

The last submitted patch, 66: 2863055-66.patch, failed testing. View results

Lendude’s picture

Status: Needs work » Needs review
FileSize
477 bytes
61.14 KB

Also update the test...

Mile23’s picture

Status: Needs review » Needs work
Issue tags: +Needs reroll
martin107’s picture

Assigned: Unassigned » martin107

I am rerolling.

Mile23’s picture

Some planning happening in this meta.

martin107’s picture

Resolving conflicts -- I blindly copied methods from

Drupal\simpletest\TestDiscovery

to

Drupal\Tests\Core\Test\TestDiscovery

I may have missed a subtle change so I will keep this assigned to myself until the test come back green. and the test count comeback unchanged.

martin107’s picture

Status: Needs work » Needs review
martin107’s picture

Assigned: martin107 » Unassigned

I think the reroll is ok.

martin107’s picture

FileSize
61.17 KB
470 bytes

Spoke too soon just cleaning up a coding standard nit ... I introduced. Sorry for all the noise.

Mile23’s picture

LGTM but I can't RTBC.

Re @Lendude #66: We already got this one: #2460521: Deprecate hook_simpletest_alter() and this one remains: #2234479: Deprecate hook_test_* hooks in simpletest

+++ b/core/modules/simpletest/src/TestDiscovery.php
@@ -5,50 +5,20 @@
+ *
+ * This class provides backwards compatibility for code which uses the legacy
+ * \Drupal\simpletest\TestDiscovery.
+ *
+ * @todo Formally deprecate this class when we decide the fate of the Simpletest
+ *   UI test runner: https://www.drupal.org/project/drupal/issues/2750461

I think we can formally deprecate here with @trigger_error(), given that we're probably going to move simpletest module to contrib.

Of course we don't yet have an issue to link to for that.

Mile23’s picture

Adds @trigger_error() to \Drupal\simpletest\TestDiscovery, which means marking a few tests @group legacy.

The thinking here is this: We'll likely move the simpletest module to contrib. Therefore, people need to quit using Drupal\simpletest\TestDiscovery. Eventually it will go away from core, and in contrib it can be un-deprecated as needed.

Remove a bunch of duplicate testing from core/modules/simpletest/tests/src/Unit/TestDiscoveryTest.php. We leave behind the tests of Drupal\simpletest\TestDiscovery::getTestClasses() which is really all that's left in that version of TestDiscovery.

Status: Needs review » Needs work

The last submitted patch, 77: 2863055_77.patch, failed testing. View results

Mile23’s picture

Status: Needs work » Needs review
FileSize
79.89 KB
2.17 KB

Added @group legacy to some simpletest tests, and made that work in WebTestBase, thanks to #2296615: Accurately support multiple @groups per test class

Lendude’s picture

Status: Needs review » Reviewed & tested by the community

The reasoning in #77 makes sense to me, so +1

Went through this again, not an easy diff to read, with all the stuff being moved around, but I didn't spot anything getting lost.

If it turns out we do need to move more stuff it could probably be done in a follow up to minimise scope here

larowlan’s picture

Status: Reviewed & tested by the community » Fixed

Committed 590ca4a and pushed to 8.8.x. Thanks!

  • larowlan committed 590ca4a on 8.8.x
    Issue #2863055 by Mile23, Lendude, martin107, alexpott, dawehner,...
Mile23’s picture

Fan freaking tastic.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.