Problem/Motivation

From what I can tell #2791163: Random automatic testing failures on SQLite with PHP 5.5 primarily did a pattern based replacement of the test prefix code that lived in KernelTestBase.

However, between setting of $this->siteDirectory and $this->databasePrefix in KernelTestBase::bootEnvironment and calling KernelTestBase::setUpFilesystem from that same function, there's no room for those values to change.

In KernelTestBase the test site path is determined not from $this->siteDirectory but from

    $test_db = new TestDatabase($this->databasePrefix);
    $test_site_path = $test_db->getTestSitePath();

The implementation of $test_db->getTestSitePath() is return 'sites/simpletest/' . $this->lockId;

From what I see from a few days of puzzling, the lockId can not change between bootEnvironment and setUpFilesystem.

The lockId in the second use case is derived from $this->databasePrefix which is itself initially created based on the lockId in the first place.

Unless I'm missing something in how these pieces of code interact within the test system. The whole loop essentially turns into:

$test_db = new TestDatabase();
$this->siteDirectory = $test_db->getTestSitePath();
$this->databasePrefix = $test_db->getDatabasePrefix();

$test_db = new TestDatabase($this->databasePrefix);
$test_site_path = $test_db->getTestSitePath();

assert($test_site_path === $this->siteDirectory);

This the second TestDatabase instance is redundant and all usages of $test_site_path can be replaced with $this->siteDirectory.

Steps to reproduce

Proposed resolution

Replace $test_site_path with $this->siteDirectory in KernelTestBase::setUpFilesystem() and remove the now unused $test_db = new TestDatabase($this->databasePrefix); line.

Remaining tasks

User interface changes

Introduced terminology

API changes

Data model changes

Release notes snippet

Issue fork drupal-3590491

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

kingdutch created an issue. See original summary.

kingdutch’s picture

Assigned: kingdutch » Unassigned
Status: Active » Needs review

Easiest way to test my hypothesis is to create an MR and kick off all the tests.

mondrake’s picture

Status: Needs review » Reviewed & tested by the community

Nice cleanup!