Problem/Motivation

TemplateProjectTestBase::assertExpectedStageEventsFired() has a $wait parameter, so that a build test can wait for stage events that happen in the background. But the first thing the loop does is $this->assertFileIsReadable($log_file). If the event log file doesn't exist yet, the test fails right away, without waiting at all.

Core itself doesn't call this method with $wait, so core's tests don't run into this. Automatic Updates does, in its cron build tests (CronUpdateTest and AutomatedCronCoreUpdateTest pass wait: 360). In #3567049: Make automated updates test pass, those tests failed most of the time with:

Failed asserting that file ".../project/package_manager_test_event.log" exists.

When the test failed, the background update had only been running for about 5 seconds. It was still running its status checks and hadn't logged any events yet. That issue in automatic Updates now works around this by waiting for the file itself, before calling the parent method, but core should fix this too. :)

Proposed resolution

Inside the loop, treat a missing log file the same as "not enough events yet", and keep waiting. Only assert that the file exists after the loop, when the waiting time is up. When $wait is 0, which is what core's own tests use, the result is the same as before.

Remaining tasks

  • Make the change.
  • Decide if it needs a test. The method is a test helper, and core doesn't call it with $wait yet.

User interface changes

None.

API changes

None. The test helper method now waits as its $wait parameter already said it does.

Data model changes

None.

Issue fork drupal-3634751

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

gábor hojtsy created an issue.