Problem/Motivation

Seen this quite a few times in CI recently

    PHPUnit 11.5.42 by Sebastian Bergmann and contributors.
    
    Runtime:       PHP 8.4.14
    Configuration: /builds/issue/drupal-3555557/core/phpunit.xml.dist
    
    .....F..S.                                                        10 / 10 (100%)

    Theme (Drupal\Tests\system\Functional\System\Theme)
     ✔ Theme settings
     ✔ Theme settings logo
     ✔ Theme settings color hex code
     ✔ Theme settings render cache clear
     ✔ Administration theme
     ✘ Switch default theme
       ┐
       ├ Failed asserting that two strings are equal.
       ┊ ---·Expected
       ┊ +++·Actual
       ┊ @@ @@
       ┊ -'olivero'
       ┊ +'stark'
       │
       │ /builds/issue/drupal-3555557/core/modules/system/tests/src/Functional/System/ThemeTest.php:447
       ┴
     ✔ Invalid theme
     ✔ Uninstalling themes
     ✔ Theme settings no logo no favicon
    
    FAILURES!
    Tests: 10, Assertions: 238, Failures: 1, Skipped: 1.

Steps to reproduce

Proposed resolution

Remaining tasks

User interface changes

Introduced terminology

API changes

Data model changes

Release notes snippet

Issue fork drupal-3555562

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

longwave created an issue. See original summary.

mstrelan made their first commit to this issue’s fork.

mstrelan’s picture

Status: Active » Needs work

Thought we could fix this with WaitTerminateTestTrait but doesn't seem to be the case.

3555562-theme-test-repeat:
Run 1: 3/100 fails
https://git.drupalcode.org/issue/drupal-3555562/-/jobs/7128506

Run 2: 21/100 fails
https://git.drupalcode.org/issue/drupal-3555562/-/jobs/7128619

3555562-theme-test-fix:
Run 1: 12/100 fails
https://git.drupalcode.org/issue/drupal-3555562/-/jobs/7128649

mstrelan’s picture

Sleeping for 1 or 5 seconds doesn't seem to help either:

https://git.drupalcode.org/issue/drupal-3555562/-/jobs/7128867

demeritcowboy’s picture

This might be different but maybe https://www.drupal.org/project/drupal/issues/3555844#comment-16331611 is helpful. There was a core commit in 11.x-dev last week where now after installing a theme backend and frontend are misaligned in these tests unless you also repoint "$this" at the new container.

mstrelan’s picture

Status: Needs work » Needs review

Thanks @demeritcowboy, resetting the container worked. See https://git.drupalcode.org/issue/drupal-3555562/-/jobs/7139554 where it passed 100 times.

Setting to Needs review for MR !13642, but I wonder if there is a global fix that we could apply. Possibly \Drupal\Tests\BrowserTestBase::config should call Drupal::config directly.

mstrelan changed the visibility of the branch 3555562-theme-test-repeat to hidden.

alexpott’s picture

Status: Needs review » Reviewed & tested by the community

This is happening because now a theme install rebuilds the container... interesting that it is random though.

Let's do this fix - ideally $this->container would not exist in functional tests... and we'd always use \Drupal:: for any helper functions.

alexpott’s picture

Discussed with @catch and we agreed to move the fix upstream to \Drupal\Tests\BrowserTestBase::config() - note that #2066993: Use magic methods to sync container property to \Drupal::getContainer in functional tests would also fix this... but there's no harm in moving away from $this->container here.

  • catch committed 6f02a934 on 11.3.x
    Issue #3555562 by longwave, mstrelan, demeritcowboy, alexpott: [random...

  • catch committed 40787402 on 11.x
    Issue #3555562 by longwave, mstrelan, demeritcowboy, alexpott: [random...
catch’s picture

Version: 11.x-dev » 11.3.x-dev
Status: Reviewed & tested by the community » Fixed

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

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.

Status: Fixed » Closed (fixed)

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