Deprecate TestDiscovery test file scanning, use PHPUnit API instead

Created on 5 January 2025, 6 months ago

Problem/Motivation

Drupal is using its own code to discover tests to be executed, which along time lead to discrepancies in the tests executed betwen PHPUnit CLI and run-tests.sh.

PHPUnit 10 introduced an API to discover the test suites, that can be used instead.

Proposed resolution

  • Deprecate TestDiscovery::getTestClasses() and related methods.
  • Introduce a like-for-like replacement that uses PHPUnit's API for the discovery, and enriches the information returned by the API to provide same info as TestDiscovery::getTestInfor().
  • Make the new code ready for PHpUnit's 10+ attributes instead of annotations.
  • In the process, fix some bugs of TestDiscovery::getTestClasses() that were identified:
    • for each test class, it only reports groups present in the class-level annotations: this means that method level annotations do not qualify test classes for a group, potentially missing the execution of some tests. PHPUnit is more accurate in bubbling up method-level annotations/attributes to the class
    • it does not check duplication of @group annotations that specify the same group. PHPUnit make them unique.
    • when filtering by test suite, it reports some test groups with an empty array, since in any case it iterates all test directories and files. PHPUnit only scans the directories indicated in phpunit.xml for each test suite, providing more accurate results.

Remaining tasks

User interface changes

nope

API changes

nope

Data model changes

nope

Release notes snippet

Drupal tests now can use PHPUnit's 10+ attributes instead of the legacy annotations. New tests MUST use attributes.

๐Ÿ“Œ Task
Status

Active

Version

11.0 ๐Ÿ”ฅ

Component

phpunit

Created by

๐Ÿ‡ฎ๐Ÿ‡นItaly mondrake ๐Ÿ‡ฎ๐Ÿ‡น

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Merge Requests

Comments & Activities

  • Issue created by @mondrake
  • Merge request !10809Closes #3497431 โ†’ (Closed) created by mondrake
  • Pipeline finished with Failed
    6 months ago
    Total: 136s
    #386235
  • Pipeline finished with Failed
    6 months ago
    Total: 175s
    #386257
  • Pipeline finished with Failed
    6 months ago
    #386276
  • Pipeline finished with Failed
    6 months ago
    #386277
  • Pipeline finished with Failed
    6 months ago
    Total: 88s
    #386279
  • Pipeline finished with Failed
    6 months ago
    Total: 420s
    #386438
  • Pipeline finished with Failed
    6 months ago
    Total: 131s
    #386605
  • Pipeline finished with Failed
    6 months ago
    Total: 429s
    #386613
  • Pipeline finished with Failed
    6 months ago
    Total: 345s
    #386630
  • Pipeline finished with Failed
    6 months ago
    Total: 702s
    #386639
  • Pipeline finished with Failed
    6 months ago
    Total: 129s
    #386645
  • Pipeline finished with Failed
    6 months ago
    Total: 89s
    #386651
  • Pipeline finished with Failed
    6 months ago
    Total: 990s
    #386652
  • Pipeline finished with Failed
    6 months ago
    Total: 1222s
    #387009
  • Pipeline finished with Success
    6 months ago
    Total: 709s
    #387172
  • Pipeline finished with Failed
    6 months ago
    Total: 503s
    #387395
  • Pipeline finished with Failed
    6 months ago
    Total: 129s
    #387696
  • Pipeline finished with Success
    6 months ago
    Total: 495s
    #387707
  • Pipeline finished with Success
    6 months ago
    Total: 505s
    #387737
  • Pipeline finished with Canceled
    6 months ago
    Total: 117s
    #387746
  • Pipeline finished with Failed
    6 months ago
    Total: 111s
    #387750
  • Pipeline finished with Failed
    6 months ago
    Total: 381s
    #388227
  • Pipeline finished with Failed
    6 months ago
    Total: 112s
    #388331
  • Pipeline finished with Success
    6 months ago
    Total: 382s
    #388341
  • ๐Ÿ‡ฎ๐Ÿ‡นItaly mondrake ๐Ÿ‡ฎ๐Ÿ‡น
  • ๐Ÿ‡ฎ๐Ÿ‡นItaly mondrake ๐Ÿ‡ฎ๐Ÿ‡น
  • Pipeline finished with Failed
    6 months ago
    Total: 141s
    #390881
  • Pipeline finished with Failed
    6 months ago
    Total: 317s
    #390921
  • Pipeline finished with Failed
    6 months ago
    Total: 331s
    #390964
  • ๐Ÿ‡ฎ๐Ÿ‡นItaly mondrake ๐Ÿ‡ฎ๐Ÿ‡น

    We are hitting a PHPUnit bug here, The file attribute of node of XML test list can be wrong. So we still need to read the file of a test class from the classloader.

  • ๐Ÿ‡ฎ๐Ÿ‡นItaly mondrake ๐Ÿ‡ฎ๐Ÿ‡น
  • Pipeline finished with Success
    6 months ago
    Total: 1231s
    #392885
  • ๐Ÿ‡ฎ๐Ÿ‡นItaly mondrake ๐Ÿ‡ฎ๐Ÿ‡น

    I think we can still avoid the classloader. On it.

  • Pipeline finished with Canceled
    6 months ago
    Total: 411s
    #397047
  • Pipeline finished with Failed
    6 months ago
    Total: 5512s
    #397051
  • Pipeline finished with Failed
    6 months ago
    Total: 626s
    #397148
  • ๐Ÿ‡ฎ๐Ÿ‡นItaly mondrake ๐Ÿ‡ฎ๐Ÿ‡น

    Very interesting side effect of this - since PHPUnit discovery actually executes the dataproviders, and includes in the discovery list as many test cases as the number of datasets provided for a test method, we can now be precise in the number of test cases run for each test class, and use that information in run-tests.sh instead of the current approximate count.

  • Pipeline finished with Failed
    6 months ago
    Total: 654s
    #397523
  • ๐Ÿ‡ฎ๐Ÿ‡นItaly mondrake ๐Ÿ‡ฎ๐Ÿ‡น
  • Pipeline finished with Failed
    6 months ago
    Total: 1661s
    #397531
  • Pipeline finished with Failed
    6 months ago
    Total: 492s
    #397680
  • Pipeline finished with Failed
    6 months ago
    Total: 3578s
    #397725
  • Pipeline finished with Failed
    6 months ago
    Total: 125s
    #397813
  • Pipeline finished with Canceled
    6 months ago
    Total: 249s
    #398024
  • Pipeline finished with Success
    6 months ago
    Total: 700s
    #398029
  • Pipeline finished with Failed
    6 months ago
    Total: 208s
    #400143
  • Pipeline finished with Failed
    6 months ago
    Total: 179s
    #400161
  • Pipeline finished with Failed
    6 months ago
    Total: 497s
    #400164
  • Pipeline finished with Failed
    6 months ago
    Total: 1015s
    #400252
  • First commit to issue fork.
  • Pipeline finished with Success
    5 months ago
    Total: 840s
    #411054
  • ๐Ÿ‡ฌ๐Ÿ‡งUnited Kingdom catch

    This looks really good and cleans up quite a lot of mess.

    I went ahead and added @group #slow to mainly kernel tests that are now ending up towards the end of the run. This is not a fault in the ordering logic at all, it's just a side effect that some tests that happened to run earlier in a test run now could run later either purely because other tests moved around, or subtle changes in the method counting logic.

    The debugging logic at the top of the test runs is great and I wonder if we should just keep that all the time.

  • ๐Ÿ‡ฎ๐Ÿ‡นItaly mondrake ๐Ÿ‡ฎ๐Ÿ‡น

    I was thinking in a follow up we could introduce a โ€œweightโ€œ to #slow (i.e. #slow300, #slow200, etc) and further tune the start sequence.

  • ๐Ÿ‡ฌ๐Ÿ‡งUnited Kingdom catch

    @mondrake I think at the moment this is OK because we have less #slow tests than we run tests concurrently per-job (e.g. we might have 5 slow tests but start 8 at the same time), however it took a while for that to be the case and it might not be the case again, so definitely worth an issue. Even now it might save a few seconds which is worth having.

  • ๐Ÿ‡ฎ๐Ÿ‡นItaly mondrake ๐Ÿ‡ฎ๐Ÿ‡น

    We can leverage on PHPUnit API also to determine the test description, instead of doing separate parsing. On it.

  • Pipeline finished with Failed
    5 months ago
    Total: 428s
    #413389
  • Pipeline finished with Failed
    5 months ago
    Total: 179s
    #413442
  • Pipeline finished with Success
    5 months ago
    Total: 357s
    #413443
  • ๐Ÿ‡ฎ๐Ÿ‡นItaly mondrake ๐Ÿ‡ฎ๐Ÿ‡น

    Done #14.

  • ๐Ÿ‡ฎ๐Ÿ‡นItaly mondrake ๐Ÿ‡ฎ๐Ÿ‡น

    Filed ๐Ÿ“Œ Introduce a โ€œweightโ€œ to #slow tests Postponed re #12 and #13.

  • Pipeline finished with Canceled
    5 months ago
    Total: 106s
    #422211
  • Pipeline finished with Failed
    5 months ago
    Total: 553s
    #422212
  • ๐Ÿ‡ฎ๐Ÿ‡นItaly mondrake ๐Ÿ‡ฎ๐Ÿ‡น

    merged with HEAD after commit of ๐Ÿ› Extend PhpUnitTestDiscoveryTest to test also PHPUnit API Active

  • Pipeline finished with Success
    5 months ago
    Total: 4893s
    #424571
  • Pipeline finished with Failed
    4 months ago
    Total: 731s
    #434842
  • Pipeline finished with Failed
    4 months ago
    Total: 329s
    #435548
  • Pipeline finished with Success
    4 months ago
    Total: 439s
    #436786
  • Pipeline finished with Success
    4 months ago
    Total: 421s
    #439168
  • Pipeline finished with Success
    4 months ago
    Total: 1557s
    #439579
  • Pipeline finished with Failed
    4 months ago
    Total: 599s
    #441372
  • Pipeline finished with Failed
    4 months ago
    Total: 518s
    #447250
  • Pipeline finished with Success
    4 months ago
    Total: 624s
    #456038
  • Pipeline finished with Success
    3 months ago
    Total: 780s
    #457802
  • Pipeline finished with Failed
    3 months ago
    Total: 660s
    #466780
  • Status changed to Needs review 3 months ago
  • ๐Ÿ‡ฎ๐Ÿ‡นItaly mondrake ๐Ÿ‡ฎ๐Ÿ‡น
  • Pipeline finished with Success
    3 months ago
    Total: 2642s
    #473283
  • ๐Ÿ‡ฎ๐Ÿ‡นItaly mondrake ๐Ÿ‡ฎ๐Ÿ‡น

    Thanks for review @mstrelan, added some of your suggestions and replied inline to some other ones; NW to address the remaining comments.

  • Pipeline finished with Success
    3 months ago
    Total: 533s
    #473617
  • Pipeline finished with Success
    3 months ago
    Total: 731s
    #473627
  • Pipeline finished with Success
    3 months ago
    Total: 1934s
    #473734
  • Pipeline finished with Failed
    3 months ago
    Total: 219s
    #473786
  • ๐Ÿ‡ฎ๐Ÿ‡นItaly mondrake ๐Ÿ‡ฎ๐Ÿ‡น
  • Pipeline finished with Failed
    3 months ago
    Total: 120s
    #474982
  • Pipeline finished with Failed
    3 months ago
    Total: 120s
    #474985
  • Pipeline finished with Failed
    3 months ago
    Total: 532s
    #475047
  • Pipeline finished with Canceled
    2 months ago
    #482571
  • Pipeline finished with Failed
    2 months ago
    Total: 482s
    #482574
  • Pipeline finished with Failed
    2 months ago
    Total: 598s
    #483002
  • Pipeline finished with Failed
    2 months ago
    Total: 1970s
    #484977
  • ๐Ÿ‡ฎ๐Ÿ‡นItaly mondrake ๐Ÿ‡ฎ๐Ÿ‡น
  • Pipeline finished with Failed
    2 months ago
    Total: 252s
    #485040
  • Pipeline finished with Failed
    2 months ago
    Total: 557s
    #485056
  • Pipeline finished with Success
    2 months ago
    Total: 626s
    #485148
  • ๐Ÿ‡ฎ๐Ÿ‡นItaly mondrake ๐Ÿ‡ฎ๐Ÿ‡น
  • Pipeline finished with Failed
    2 months ago
    Total: 292s
    #486752
  • Pipeline finished with Success
    2 months ago
    Total: 764s
    #486758
  • Pipeline finished with Success
    2 months ago
    Total: 498s
    #488417
  • ๐Ÿ‡ฎ๐Ÿ‡นItaly mondrake ๐Ÿ‡ฎ๐Ÿ‡น

    Found some issues while testing this in combination with ๐ŸŒฑ [meta] Support PHPUnit 11 in Drupal 10 Postponed . Given that one is RTBC, let's postpone on that.

  • Pipeline finished with Failed
    2 months ago
    #491130
  • ๐Ÿ‡ฎ๐Ÿ‡นItaly mondrake ๐Ÿ‡ฎ๐Ÿ‡น
  • Pipeline finished with Success
    2 months ago
    #491137
  • ๐Ÿ‡ฆ๐Ÿ‡บAustralia larowlan ๐Ÿ‡ฆ๐Ÿ‡บ๐Ÿ.au GMT+10

    Blocker is in

  • ๐Ÿ‡ฎ๐Ÿ‡นItaly mondrake ๐Ÿ‡ฎ๐Ÿ‡น

    Rebased. Since when this was RTBC, added logic for determining group metadata information under PHPUnit 11.

  • Pipeline finished with Success
    2 months ago
    Total: 2585s
    #491994
  • ๐Ÿ‡ฌ๐Ÿ‡งUnited Kingdom catch

    Adding this as a release priority because it will allow #[Group] to be used in contrib in combination with run-tests.sh (at least when 11.1 support is dropped).

  • ๐Ÿ‡ฎ๐Ÿ‡นItaly mondrake ๐Ÿ‡ฎ๐Ÿ‡น

    Thanks for reviews!

    I'd love to add @phpstan-type, but I am reluctant because of ๐Ÿ“Œ Forbid limited length primary and unique keys, allow only in indexes Needs work and โœจ Support PHPStan's annotations for local type aliases and array shapes Active .

  • Pipeline finished with Failed
    about 2 months ago
    Total: 608s
    #492989
  • ๐Ÿ‡ฆ๐Ÿ‡บAustralia larowlan ๐Ÿ‡ฆ๐Ÿ‡บ๐Ÿ.au GMT+10

    No worries, it's a nice to have and shouldn't hold this up

  • Pipeline finished with Failed
    about 2 months ago
    Total: 684s
    #496345
  • Pipeline finished with Success
    about 2 months ago
    Total: 568s
    #496726
  • ๐Ÿ‡ฎ๐Ÿ‡นItaly mondrake ๐Ÿ‡ฎ๐Ÿ‡น

    removed duplicate @group #slow annotations

  • Pipeline finished with Failed
    about 2 months ago
    Total: 599s
    #499594
  • ๐Ÿ‡ฎ๐Ÿ‡นItaly mondrake ๐Ÿ‡ฎ๐Ÿ‡น

    Made some updates to the CR to provide some input how to convert tests from annotation to attributes. Would be lovely to get a review there too.

  • ๐Ÿ‡ฆ๐Ÿ‡บAustralia larowlan ๐Ÿ‡ฆ๐Ÿ‡บ๐Ÿ.au GMT+10

    CR looks great, nice one ๐Ÿ™Œ

  • There are failing tests in the latest build that are not familiar to me as intermittent failures, but they probably need a re-run attempt at least.

  • ๐Ÿ‡ฎ๐Ÿ‡นItaly mondrake ๐Ÿ‡ฎ๐Ÿ‡น

    Only merged with head, now tests are green. There's fortuity in randomness of test failures.

  • I see only one unresolved MR comment from @larowlan about the file naming, but that comment was answered and seems to make sense to me. RTBC.

    • catch โ†’ committed 4193887a on 11.2.x
      Issue #3497431 by mondrake, catch, larowlan, godotislate: Deprecate...
    • catch โ†’ committed f955ab18 on 11.x
      Issue #3497431 by mondrake, catch, larowlan, godotislate: Deprecate...
  • ๐Ÿ‡ฌ๐Ÿ‡งUnited Kingdom catch

    OK I read through this again. It's a really nice clean-up of test discovery.

    Personally I am excited about the improvements to test ordering, both for core test suite performance and also because it unblocks potential improvements in contrib as described in ๐Ÿ“Œ Lower default concurrency Active .

    Committed/pushed to 11.x and cherry-picked to 11.2.x, thanks!

  • ๐Ÿ‡ฌ๐Ÿ‡งUnited Kingdom catch

    I think this may have broken pipelines, e.g. https://git.drupalcode.org/issue/drupal-3046670/-/pipelines/505134 it's not possible to see the default test job. Reverting for now.

    • catch โ†’ committed b236cc00 on 11.2.x
      Revert "Issue #3497431 by mondrake, catch, larowlan, godotislate:...
    • catch โ†’ committed 75bf2e53 on 11.x
      Revert "Issue #3497431 by mondrake, catch, larowlan, godotislate:...
  • ๐Ÿ‡ฎ๐Ÿ‡นItaly mondrake ๐Ÿ‡ฎ๐Ÿ‡น

    Can't figure out what would be impacting pipelines here - the MR one after revert and rebase seems to work fine. Pipeline config is not touched apart from the addition of a parameter when calling run-tests.sh.

  • Pipeline finished with Success
    about 1 month ago
    Total: 364s
    #505165
    • catch โ†’ committed 749a119e on 11.2.x
      Issue #3497431 by mondrake, catch, larowlan, godotislate: Deprecate...
    • catch โ†’ committed 64212ca3 on 11.x
      Issue #3497431 by mondrake, catch, larowlan, godotislate: Deprecate...
  • ๐Ÿ‡ฌ๐Ÿ‡งUnited Kingdom catch

    Yeah it doesn't make sense to me either - going to try again and trigger a couple of pipelines on different MRs in case it was a one-off.

  • ๐Ÿ‡ฌ๐Ÿ‡งUnited Kingdom catch

    Seems OK now, I think it was a false alarm/ gitlab itself having a problem.

  • ๐Ÿ‡ฎ๐Ÿ‡นItaly mondrake ๐Ÿ‡ฎ๐Ÿ‡น

    Do we need publishing the CR?

  • ๐Ÿ‡ฆ๐Ÿ‡บAustralia larowlan ๐Ÿ‡ฆ๐Ÿ‡บ๐Ÿ.au GMT+10

    Change record appears to already be published ๐Ÿ‘

  • ๐Ÿ‡ฎ๐Ÿ‡นItaly mondrake ๐Ÿ‡ฎ๐Ÿ‡น

    Filed ๐Ÿ› PhpUnitApiGetTestClassesTest and PhpUnitApiFindAllClassFilesTest need to execute PHPUnit discovery before TestDiscovery Active after finding an issue while working on the followup conversions from annotations to attributes.

  • ๐Ÿ‡ฎ๐Ÿ‡นItaly mondrake ๐Ÿ‡ฎ๐Ÿ‡น
  • ๐Ÿ‡ฎ๐Ÿ‡นItaly mondrake ๐Ÿ‡ฎ๐Ÿ‡น
  • ๐Ÿ‡ช๐Ÿ‡ธSpain fjgarlin

    Note that this has broken testing for 11.2.x+ pipelines for all contrib.

    Related issue in "gitlab_templates": ๐Ÿ“Œ MissingGroupException: Missing group metadata with run-tests.sh in 11.2.0-dev Active

    Modules are either getting MissingGroupException or ERROR: No valid tests were specified.

    Key projects like Project Browser are affected ๐Ÿ“Œ Update for changes to System requirements Active , but again, this is all contrib testing NEXT_MINOR via run-tests.sh

    • catch โ†’ committed aa346e2e on 11.2.x
      Revert "Issue #3497431 by mondrake, catch, larowlan, godotislate:...
    • catch โ†’ committed b281a7ae on 11.x
      Revert "Issue #3497431 by mondrake, catch, larowlan, godotislate:...
  • ๐Ÿ‡ฌ๐Ÿ‡งUnited Kingdom catch

    Yes let's revert for now - hopefully we have enough to go on from the failed runs to figure out what's missing here.

  • ๐Ÿ‡ฎ๐Ÿ‡นItaly mondrake ๐Ÿ‡ฎ๐Ÿ‡น

    In next iteration, I would consider doing:

    1) Bump PHPUnit to 11 in the lock file, instead of keeping it locked to 10. ๐ŸŒฑ [meta] Support PHPUnit 11 in Drupal 10 Postponed has been in for 3 weeks now and AFAICS no issue have been reported about that. PHPUnit 11 also support PHP 8.3, which is minimum for D11. We can still keep 10 in the composer.json in case anyone has the need to downgrade for incompatibility (which, again, was not found yet).

    2) Include ๐Ÿ› PhpUnitApiGetTestClassesTest and PhpUnitApiFindAllClassFilesTest need to execute PHPUnit discovery before TestDiscovery Active which was meant to be a followup of this, but since now itโ€™s open again, better do straight ahead.

    Then, if ๐Ÿ“Œ MissingGroupException: Missing group metadata with run-tests.sh in 11.2.0-dev Active willl still not be resolved, it should be (theoretically) only a matter of listing the relevant directories in phpunit.xml.dist - and that would require another core fix if contrib is meant to run with core configuration.

    Iโ€™d also suggest to commit initially only to 11.x to allow proper checking in gitlab templates, and only eventually backport to 11.2.x upon complete validation.

  • ๐Ÿ‡ฌ๐Ÿ‡งUnited Kingdom catch

    @mondrake that all sounds good. I think defaulting to phpunit 11 is fine

  • Pipeline finished with Canceled
    about 1 month ago
    Total: 130s
    #510197
  • Pipeline finished with Failed
    about 1 month ago
    Total: 146s
    #510198
  • ๐Ÿ‡ซ๐Ÿ‡ทFrance andypost

    One more strong reason is that PHPUnit 10 no longer has bugfix support (since Feb'25) https://phpunit.de/supported-versions.html

    So moving to 11 is required step to start transition to 12

  • Pipeline finished with Failed
    about 1 month ago
    Total: 214s
    #510250
  • Pipeline finished with Failed
    about 1 month ago
    Total: 153s
    #510254
  • Pipeline finished with Failed
    about 1 month ago
    Total: 270s
    #510260
  • ๐Ÿ‡ฎ๐Ÿ‡นItaly mondrake ๐Ÿ‡ฎ๐Ÿ‡น

    I do not understand why the CSpell job fail given that the file reported is included in the ignored paths in .cspell.json.

    Then waiting for feedback to question in #3527063-8: Update for changes required by D11.2 โ†’ to see if we do need to edit the <directory> sections of phpunit.xml.dist to accomodate contrib testing.

  • Pipeline finished with Success
    about 1 month ago
    Total: 454s
    #510369
  • ๐Ÿ‡ฎ๐Ÿ‡นItaly mondrake ๐Ÿ‡ฎ๐Ÿ‡น

    Solved the CSpell problem.

  • ๐Ÿ‡ฎ๐Ÿ‡นItaly mondrake ๐Ÿ‡ฎ๐Ÿ‡น

    Done #58.

  • ๐Ÿ‡ฎ๐Ÿ‡นItaly mondrake ๐Ÿ‡ฎ๐Ÿ‡น

    Apparently the syntax to pick the test files in the /module subdirectory was failing somehow, changed after some thorough manual testing documented in https://drupal.slack.com/archives/CGKLP028K/p1748635336355999

    This should hopefully fix the issue in ๐Ÿ“Œ Update for changes to System requirements Active with no changes to need happen there (once this is back in).

  • Pipeline finished with Success
    about 1 month ago
    Total: 2508s
    #511476
  • ๐Ÿ‡จ๐Ÿ‡ฆCanada Charlie ChX Negyesi ๐ŸCanada

    Currently you can enable test modules with a simple setting , it's extremely useful for debugging is that kept?

  • ๐Ÿ‡ฎ๐Ÿ‡นItaly mondrake ๐Ÿ‡ฎ๐Ÿ‡น

    @ghost of drupal past sorry I do not understand your question. Can you please elaborate?

  • ๐Ÿ‡ฌ๐Ÿ‡งUnited Kingdom catch

    There's no change to module discovery here, only the test classes themselves.

  • Pipeline finished with Success
    about 1 month ago
    Total: 6088s
    #511923
  • Pipeline finished with Success
    about 1 month ago
    Total: 530s
    #512338
  • Pipeline finished with Success
    about 1 month ago
    Total: 9896s
    #512410
  • Pipeline finished with Success
    about 1 month ago
    Total: 530s
    #516016
  • Pipeline finished with Success
    26 days ago
    Total: 2116s
    #519956
  • OK, confirmed that the changes for the build in[#3527555] for Project browser are passing (phpstan issues there are unrelated), and the changes there are the same as the changes in the MR 10809 here, other than the use of globstar patterns core/.phpunit-next.xml here. But that file isn't used in the PB build per https://git.drupalcode.org/project/drupal/-/merge_requests/10809#note_51..., so everything LGTM.

    • catch โ†’ committed 6ab557df on 11.x
      Issue #3497431 by mondrake, catch, larowlan, godotislate, fjgarlin:...
    • catch โ†’ committed 5b9badb7 on 11.2.x
      Issue #3497431 by mondrake, catch, larowlan, godotislate, fjgarlin:...
  • ๐Ÿ‡ฌ๐Ÿ‡งUnited Kingdom catch

    Discussed this with @xjm - since this was committed for the beta, then reverted during the beta, and the actual change since is tiny, and it unblocks several other things, going ahead and committing it again relatively last minute during rc. Would be good peace of mind to see a successful contrib test run before we get anywhere near tagging 11.2.0 next week, but generally very glad to see this in!

    Committed/pushed to 11.x and cherry-picked to 11.2.x, thanks!

  • ๐Ÿ‡ฎ๐Ÿ‡นItaly mondrake ๐Ÿ‡ฎ๐Ÿ‡น

    Image Effects seems to work fine Test with 11.2.0-rc2 ๐Ÿ“Œ Test with 11.2.0-rc2 Active

  • ๐Ÿ‡ฎ๐Ÿ‡นItaly mondrake ๐Ÿ‡ฎ๐Ÿ‡น

    Project Browser seems to work too Test with 11.2.0-rc2 ๐Ÿ“Œ Test with 11.2.0-rc2 Active

  • Status changed to Fixed 24 days ago
  • ๐Ÿ‡ฎ๐Ÿ‡นItaly mondrake ๐Ÿ‡ฎ๐Ÿ‡น

    Updated release note snippet.

  • ๐Ÿ‡ฌ๐Ÿ‡งUnited Kingdom jonathan1055

    I know this was going to be committed to 11.x but was surprised to see it also committed to 11.2.x

    As soon as Gitlab Templates makes the shift from 11.1 to 11.2 as 'current core version' this will break some existing contrib pipelines, see https://git.drupalcode.org/project/scheduler/-/jobs/5557961 This phpunit job uses the documented @group to divide the tests into parallel streams. I know we can also add the #[group ] metadata, but until contrib has a chance to do that then some pipelines will break. Maybe that's acceptable, but I just wanted to let you know, and to understand the process for Contrib changes.

  • ๐Ÿ‡ฎ๐Ÿ‡นItaly mondrake ๐Ÿ‡ฎ๐Ÿ‡น

    The new code can manage both @group annotations and #[Group] attributes, otherwise 99% of core would be failing. So contrib is not requested to add the attribute. The linked tests in #72 and #73 prove it anyway.

    So it must be something else, looking.

  • ๐Ÿ‡ฎ๐Ÿ‡นItaly mondrake ๐Ÿ‡ฎ๐Ÿ‡น

    The error is

    Drupal\Core\Test\Exception\MissingGroupException: Missing group metadata in test class Drupal\Tests\Composer\Generator\BuilderTest in /builds/project/scheduler/web/core/lib/Drupal/Core/Test/PhpUnitTestDiscovery.php:304

    which is very very strange as that test (which is a core test btw) clearly DOES have a @group Metapackage annotation and it runs no problem in core.

    Gut feeling is that the contrib is playing with the pwd of the job and PHPUnit/autoloading cannot find the class.

  • ๐Ÿ‡ฌ๐Ÿ‡งUnited Kingdom jonathan1055

    The actual command that runs the test in these jobs is
    sudo -u www-data -H -E php web/core/scripts/run-tests.sh --php '/usr/local/bin/php' --color --keep-results --concurrency 32 --repeat '1' --sqlite 'sites/default/files/.sqlite' --dburl mysql://drupaltestbot:drupaltestbotpw@database/mysql --url http://localhost/web --xml /builds/project/scheduler/web/sites/default/files/simpletest --verbose --non-html scheduler_js
    It is the final argument, 'scheduler_js' in the above example, which in 11.1 runs the tests annotated with @group scheduler_js but which fails at 11.2

  • ๐Ÿ‡ฌ๐Ÿ‡งUnited Kingdom catch

    The main reason to commit this to 11.2 is to allow contrib to start using attributes to support future updates to phpunit 11 and higher.

    If we can make #79 work with a quick follow-up that would be great, but otherwise I think we'd need to revert this from 11.2 before we tag 11.2.0 (but probably leave it in 11.x) this time.

  • ๐Ÿ‡ฎ๐Ÿ‡นItaly mondrake ๐Ÿ‡ฎ๐Ÿ‡น

    I am looking into this. Knowing the inners, it's very strange as that exception is thrown after the test list has been already built by PHPUnit, which is common with the other two tests.

  • ๐Ÿ‡ฎ๐Ÿ‡นItaly mondrake ๐Ÿ‡ฎ๐Ÿ‡น

    Image Effects runs tests with pwd = /builds/project/image_effects
    Project Browser runs tests with pwd = /builds/issue/project_browser-3530110

  • ๐Ÿ‡ฎ๐Ÿ‡นItaly mondrake ๐Ÿ‡ฎ๐Ÿ‡น

    Opened ๐Ÿ“Œ Test with 11.2.0-rc2 Active in Scheduler's module issue queue to try and understand what's going on.

  • ๐Ÿ‡บ๐Ÿ‡ธUnited States xjm

    But with test changes, isn't the breakage broken regardless of whether it's in the release branch or not? Like 11.x will break things just as hard if it's broken, no? If what it's breaking are contrib pipelines?

  • ๐Ÿ‡ฎ๐Ÿ‡นItaly mondrake ๐Ÿ‡ฎ๐Ÿ‡น

    ๐Ÿ“Œ Test with 11.2.0-rc2 Active has a debug patch for core that now makes tests pass. Most important would now be to understand why PHPUnit sometimes does not pass a filled in Test object; then we can make a core patch.

    Do I need to open a separate issue or an additional MR in this issue, eventually?

  • ๐Ÿ‡ฎ๐Ÿ‡นItaly mondrake ๐Ÿ‡ฎ๐Ÿ‡น

    Filed ๐Ÿ“Œ Introduce PHPUNIT_FAIL_ON_PHPUNIT_DEPRECATION Active in GitLab Templates issue queue.

  • Merge request !12382Closes #3497431 followup โ†’ (Closed) created by mondrake
  • ๐Ÿ‡ฎ๐Ÿ‡นItaly mondrake ๐Ÿ‡ฎ๐Ÿ‡น

    We might have surfaced a bug upstream (PHPUnit's test suites builder seems to be adding empty TestSuite sub-objects to the main TestSuite object under some unclear circumstances), but this minimal MR!12382 fix seems to let the overall testing discovery complete in that case. ๐Ÿ“Œ Test with 11.2.0-rc2 Active is now passing with the equivalent of the MR as a patch.

    Will try to see if I can report upstream, but that will require quite some investigation before being able to - building a self-contained minimal patch reproducing the issue is not going to be a simple one.

  • ๐Ÿ‡ฎ๐Ÿ‡นItaly mondrake ๐Ÿ‡ฎ๐Ÿ‡น

    Copy/pasting here more details I added in #3530183-8: Test with 11.2.0-rc2 โ†’ .

    I could replicate the issue in Image Effects https://git.drupalcode.org/project/image_effects/-/merge_requests/72 by choosing to select tests by group instead of by directory.

    To me the issue is a bug upstream: PHPUnit 'builds' the list of tests to execute as a hierarchical structure of TestSuite and TestCase objects, and seems to be adding empty TestSuite sub-objects to the main TestSuite object under some unclear circumstances.

    Core patch developed here seems to work, and it is now a follow-up MR in core's #3497431-88: Deprecate TestDiscovery test file scanning, use PHPUnit API instead โ†’ .

    It just skips, though, empty TestSuite objects which may lead to skipped test runs if the @group/#[Group] of the test class skipped corresponds to the group filter when running runt-tests.sh. I will keep investigating in Image Effects issue ๐Ÿ“Œ Test with 11.2.0-rc2 Active .

    I think core's ๐Ÿ“Œ Allow indicating alternative phpunit.xml than core's when testing via run-tests.sh Active would help as it could open up the possibility to declare the directories to be searched for test discovery by the module, if run-tests.sh execution is filtered by test group. This will prevent discovering all of the core test files as it is happening now.

  • Pipeline finished with Failed
    22 days ago
    #522873
  • ๐Ÿ‡ฎ๐Ÿ‡นItaly mondrake ๐Ÿ‡ฎ๐Ÿ‡น

    So as detailed in #3530183-13: Test Scheduler at 11.2.x-dev with patched PhpUnitTestDiscovery.php โ†’ , issue reported in #76 are due to gaps present elsewhere, that the PHPUnit discovery process legitimately cannot deal with.

    In the MR, now, an implementation of PHPUnit's Tracer is collecting warnings thrown by PHPUnit during discovery, and reporting them in the run-tests.sh output so they can be actioned. The discovery process is now completed insetad of failing as it was identified in #76, but the actual list of tests to be executed will be missing those tests that errored during discovery.

  • Pipeline finished with Failed
    22 days ago
    Total: 594s
    #522879
  • Pipeline finished with Failed
    22 days ago
    Total: 202s
    #522893
  • Pipeline finished with Success
    22 days ago
    Total: 801s
    #522905
  • ๐Ÿ‡ฌ๐Ÿ‡งUnited Kingdom catch

    The MR looks tidy to me, and the new error output is good. I think we should go ahead and commit this as a follow-up to both 11.x and 11.2.x.

  • ๐Ÿ‡ฎ๐Ÿ‡นItaly mondrake ๐Ÿ‡ฎ๐Ÿ‡น

    I was on the verge of self-RTBC already, #91 confirms, so let's get going.

    • catch โ†’ committed 85215b03 on 11.2.x
      Issue #3497431 by mondrake, catch, larowlan, godotislate, jonathan1055,...
    • catch โ†’ committed 375995de on 11.x
      Issue #3497431 by mondrake, catch, larowlan, godotislate, jonathan1055,...
  • ๐Ÿ‡ฌ๐Ÿ‡งUnited Kingdom catch

    unless we just wanted to leave it around a little bit for aggressively enforced debugging or something. :)

    Yes this is more or less the reason. It turned out the last round of failures was surfacing specific issues discovering tests in specific modules due to things like non-static data providers and missing directories etc.

    I think we probably need a new CR here that modules that previously had silent test discovery errors will now get a loud error with useful information, however I don't feel like I understand the intricacies of the specific errors found to write a useful summary.

    Committed/pushed to 11.x and cherry-picked to 11.2.x, thanks!

    Moving to needs work for the new/updated change record.

  • ๐Ÿ‡ฌ๐Ÿ‡งUnited Kingdom jonathan1055

    I had just written the below, simultaneously, but copy/pasting here anyway.

    the issue reported in #76 is due to gaps present elsewhere, that the PHPUnit discovery process legitimately cannot deal with.

    It seems that PHPUnit 11 is obviously a lot more picky about test discovery than PHPUnit 10, which easily found all the @group mygroup and did not complain at all.

    But yes I agree, get this in 11.2.x then those tests at Next Minor will start running again. If the output clearly lists the skipped tests and the reasons then at least we have something to work on. But if they are skipped due to 3rd-party module problems then that will me we lose test coverage until they can be fixed. In the earlier 11.2.x work, those were merely reported as deprecations in 3rd-party modules wich could be ignored and the tests ran. Anyway, we have to move forward, so yes RTBC+1. Good work mondrake, thank you for taking this on.

  • ๐Ÿ‡ฎ๐Ÿ‡นItaly mondrake ๐Ÿ‡ฎ๐Ÿ‡น

    I'll work on a CR. Re #97:

    But if they are skipped due to 3rd-party module problems then that will me we lose test coverage until they can be fixed.

    to me this is not going to mean lost test coverage. We need to distinguish test discovery from test execution. Test discovery looks for ALL the test classes available (based on some pre-constraints sometimes, e.g. if you specifically indicate a directory to search in, it will be limited to that), then filters only those that need to be executed.

    In the case of the wrong dataprovider in address and token modules of the related issue, these are reported as failing when building the test list during discovery, but are not executed because the filter is @group scheduler_xxx. So, the scheduler tests are not really affected. They would fail loud on tests executed on those modules with PHPUnit 11 (time to apply the static modifier...), or if, from the scheduler module, you'd run tests for @group token or @group address. But that's because the dataprovider must be static, not for the discovery.

  • ๐Ÿ‡ฌ๐Ÿ‡งUnited Kingdom jonathan1055

    Ah thank you for explaining that. I see now that your comment in #90 "but the actual list of tests to be executed will be missing those tests that errored during discovery." is actually the "list of tests discovered will be missing ..." but the full list for the intended module should still be run (providing the errors are only in 3rd-party modules). That sounds perfect.

  • ๐Ÿ‡ฎ๐Ÿ‡นItaly mondrake ๐Ÿ‡ฎ๐Ÿ‡น

    Added CR https://www.drupal.org/node/3530388 โ†’ , appreciate review and publishing.

  • ๐Ÿ‡ฆ๐Ÿ‡บAustralia mstrelan

    This issue added some new deprecations to the baseline. I've opened ๐Ÿ“Œ Remove deprecated use of Assert::isType Active to fix them.

  • ๐Ÿ‡ฎ๐Ÿ‡นItaly mondrake ๐Ÿ‡ฎ๐Ÿ‡น

    @jonathan1055 kindly reviewed the new CR, I published it. Tentatively marking this fixed as it looks to me there's nothing else to do.

  • ๐Ÿ‡บ๐Ÿ‡ธUnited States xjm

    Thanks all for the hotfix and related followup work!

    Retroactively bumping priority.

  • ๐Ÿ‡ฌ๐Ÿ‡งUnited Kingdom jonathan1055

    Now that this has been re-committed to 11.2.x I presume the idea is to fix all the Core tests so that they do not produce PHPUnit test runner deprecations? Contrib tests get deprecation warnings for Core classes and methods that don't have the new attributes yet. For example a javascript test that extends use Drupal\FunctionalJavascriptTests\WebDriverTestBase gets warings that the failOnJavaScriptErrors() method contains doc-comment metadata.
    See https://git.drupalcode.org/project/scheduler/-/jobs/5596390#L670

    Here is the failOnJavaScriptErrors() method in webDriverTestBase

    I've not found any open core issues to start takling this task yet, or maybe I missed it. I can open an issue if this is the plan.

  • ๐Ÿ‡ฌ๐Ÿ‡งUnited Kingdom catch

    ๐Ÿ“Œ Remove support for PHPUnit 10 Postponed or ๐Ÿ“Œ Allow indicating alternative phpunit.xml than core's when testing via run-tests.sh Active are probably the first steps towards that - e.g. we would stop running core tests against phpunit 10 at all. Until we do that I don't think we can remove deprecated usages in the test themselves because they'd be needed for phpunit 10. I don't know if there's a specific issue for that bit though or not.

  • ๐Ÿ‡ฌ๐Ÿ‡งUnited Kingdom jonathan1055

    Thanks for the info. But you don't have to remove the deprecated @ metadata just yet, you only need to add the equivalent #[ ] version to prevent the deprecation messages. Both can exist, and the tests run at both PHPUnit11 and PHPUnit10 without a problem. At least, they do with Contrib @group and @dataprovider, because I've done that here.

  • ๐Ÿ‡ฎ๐Ÿ‡นItaly mondrake ๐Ÿ‡ฎ๐Ÿ‡น

    There are a few issues already towards converting metadata from annotations to attributes, see related ๐Ÿ“Œ [meta] Define a Rector rule to convert test annotations to attributes Active , ๐Ÿ“Œ Convert test annotation to attributes in Drupal/Test/Component Active , ๐Ÿ“Œ Convert test annotations to attributes in Drupal/BuildTests Active . But they are currently children of the original ๐ŸŒฑ [meta] Support PHPUnit 11 in Drupal 10 Postponed . It would be probably be the case now to open a new meta for the conversions (there are 000s of files to convert), and reparent those to it.

    When it comes to the deprecations, with PHPUnit 11 we need to distinguish between SUT deprecations and PHPUnit runner deprecations - the former are the 'traditional' ones, the latter are internal to PHPUnit. Core, when running tests through run-tests.sh, currently DISABLES PHPUnit runner deprecations by setting the env variable PHPUNIT_FAIL_ON_PHPUNIT_DEPRECATION to FALSE. This leads to SUT deprecations being reported but no PHPUnit ones. ๐Ÿ“Œ Introduce PHPUNIT_FAIL_ON_PHPUNIT_DEPRECATION Active aims at introducing the same capability in GitLab Templates; contrib using run-tests.sh can anyway already use it if needed.

  • ๐Ÿ‡ฎ๐Ÿ‡นItaly mondrake ๐Ÿ‡ฎ๐Ÿ‡น

    Re #105

    Until we do that I don't think we can remove deprecated usages in the test themselves because they'd be needed for phpunit 10.

    per se PHPUnit 10 can perfectly process attributes only, so if tests are run via PHPUnit CLI, no problem to have attributes only in contrib. See https://www.drupal.org/project/sophron โ†’ for example. The problem is if tests are run via the run-tests.sh script BEFORE Drupal 11.2: in that case the 'old' TestDiscovery process is in place, and that one is not capable of dealing with test classes that lack the @group annotation.

  • ๐Ÿ‡ฌ๐Ÿ‡งUnited Kingdom catch

    Ah OK that makes things a lot easier then, thanks for the clarification.

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

Production build 0.71.5 2024