Commit 1975fe08 authored by catch's avatar catch

Issue #2804675 by alexpott, hideaway: Tests using TestDatabase class are stuck...

Issue #2804675 by alexpott, hideaway: Tests using TestDatabase class are stuck in an infinite loop in Windows (8.2.0-rc2 only)
parent 397b680a
......@@ -115,27 +115,16 @@ protected function getTestLock() {
// tests are run concurrently.
do {
$lock_id = mt_rand(10000000, 99999999);
if (@symlink(__FILE__, $this->getLockFile($lock_id)) === FALSE) {
// If we're only running with a concurrency of 1 there's no need to create
// a test lock file as there is no chance of the random number generated
// clashing.
if (getenv('RUN_TESTS_CONCURRENCY') > 1 && @symlink(__FILE__, $this->getLockFile($lock_id)) === FALSE) {
$lock_id = NULL;
}
} while ($lock_id === NULL);
return $lock_id;
}
/**
* Releases a test lock.
*
* This should only be called once the related test fixtures have been cleaned
* up.
*/
public function releaseTestLock() {
$concurrency = getenv('RUN_TESTS_CONCURRENCY');
// If we're doing concurrent testing then ensure no dupes in the whole run.
if (!$concurrency || $concurrency == 1) {
unlink($this->getLockFile($this->lockId));
}
}
/**
* Releases all test locks.
*
......
......@@ -1366,10 +1366,6 @@ private function restoreEnvironment() {
// Delete test site directory.
file_unmanaged_delete_recursive($this->siteDirectory, array($this, 'filePreDeleteCallback'));
// Release the test lock.
$test_db = new TestDatabase($test_prefix);
$test_db->releaseTestLock();
// Restore original database connection.
Database::removeConnection('default');
Database::renameConnection('simpletest_original_default', 'default');
......
......@@ -5,6 +5,7 @@
* This script runs Drupal tests from command line.
*/
use Drupal\Component\FileSystem\FileSystem;
use Drupal\Component\Utility\Html;
use Drupal\Component\Utility\Timer;
use Drupal\Component\Uuid\Php;
......@@ -455,6 +456,12 @@ function simpletest_script_init() {
$_SERVER['HTTP_USER_AGENT'] = 'Drupal command line';
if ($args['concurrency'] > 1) {
$directory = FileSystem::getOsTemporaryDirectory();
$test_symlink = @symlink(__FILE__, $directory . '/test_symlink');
if (!$test_symlink) {
throw new \RuntimeException('In order to use a concurrency higher than 1 the test system needs to be able to create symlinks in ' . $directory);
}
unlink($directory . '/test_symlink');
putenv('RUN_TESTS_CONCURRENCY=' . $args['concurrency']);
}
......
......@@ -701,10 +701,6 @@ protected function tearDown() {
$this->vfsRoot = NULL;
$this->configImporter = NULL;
// Release the prefix.
$test_db = new TestDatabase($test_prefix);
$test_db->releaseTestLock();
// Free up memory: Custom test class properties.
// Note: Private properties cannot be cleaned up.
$rc = new \ReflectionClass(__CLASS__);
......
......@@ -601,10 +601,6 @@ protected function cleanupEnvironment() {
// Delete test site directory.
file_unmanaged_delete_recursive($this->siteDirectory, array($this, 'filePreDeleteCallback'));
// Release the prefix.
$test_db = new TestDatabase($test_prefix);
$test_db->releaseTestLock();
}
/**
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment