diff --git a/core/drupalci.yml b/core/drupalci.yml index 2085b9737b..581bc3f0b6 100644 --- a/core/drupalci.yml +++ b/core/drupalci.yml @@ -3,17 +3,6 @@ # https://www.drupal.org/drupalorg/docs/drupal-ci/customizing-drupalci-testing build: assessment: - validate_codebase: - phplint: - csslint: - halt-on-fail: false - eslint: - # A test must pass eslinting standards check in order to continue processing. - halt-on-fail: false - phpcs: - # phpcs will use core's specified version of Coder. - sniff-all-files: false - halt-on-fail: false testing: # run_tests task is executed several times in order of performance speeds. # halt-on-fail can be set on the run_tests tasks in order to fail fast. @@ -21,30 +10,7 @@ build: # deprecated code. run_tests.phpunit: types: 'PHPUnit-Unit' - testgroups: '--all' - suppress-deprecations: false - halt-on-fail: false - run_tests.kernel: - types: 'PHPUnit-Kernel' - testgroups: '--all' - suppress-deprecations: false - halt-on-fail: false - run_tests.simpletest: - types: 'Simpletest' - testgroups: '--all' - suppress-deprecations: false - halt-on-fail: false - run_tests.functional: - types: 'PHPUnit-Functional' - testgroups: '--all' - suppress-deprecations: false - halt-on-fail: false - run_tests.javascript: - concurrency: 15 - types: 'PHPUnit-FunctionalJavascript' - testgroups: '--all' + testgroups: '--class "Drupal\Tests\Component\Scaffold\Integration\ScaffoldFileCollectionTest"' suppress-deprecations: false halt-on-fail: false - # Run nightwatch testing. - # @see https://www.drupal.org/project/drupal/issues/2869825 - nightwatchjs: + repeat: 6400 diff --git a/core/tests/Drupal/Tests/Component/Scaffold/Fixtures.php b/core/tests/Drupal/Tests/Component/Scaffold/Fixtures.php index d66d7802f9..bafb7b0529 100644 --- a/core/tests/Drupal/Tests/Component/Scaffold/Fixtures.php +++ b/core/tests/Drupal/Tests/Component/Scaffold/Fixtures.php @@ -19,6 +19,11 @@ */ class Fixtures { + /** + * Keep a persistent prefix to help group our tmp directories together + */ + protected static $randomPrefix = ''; + /** * Directories to delete when we are done. * @@ -167,7 +172,7 @@ public function sourcePath($project_name, $source) { * @see \Drupal\Component\Scaffold\ManageOptions::getLocationReplacements() */ public function getLocationReplacements() { - $destinationTmpDir = $this->mkTmpDir(); + $destinationTmpDir = $this->mkTmpDir('location-replacements'); $interpolator = new Interpolator(); $interpolator->setData(['web-root' => $destinationTmpDir, 'package-name' => 'fixtures/tmp-destination']); return $interpolator; @@ -237,29 +242,46 @@ public function destinationPath($destination, Interpolator $interpolator = NULL, /** * Generates a path to a temporary location, but do not create the directory. * - * @param string $extraSalt - * Extra characters to throw into the md5 to add to name. + * @param string $prefix + * A prefix for the temporary directory name. * * @return string * Path to temporary directory */ - public function tmpDir($extraSalt = '') { - $tmpDir = sys_get_temp_dir() . '/composer-scaffold-test-' . md5($extraSalt . microtime()); + public function tmpDir($prefix) { + $prefix .= static::persistentPrefix(); + $tmpDir = sys_get_temp_dir() . '/scaffold-' . $prefix . uniqid(md5($prefix . microtime()), TRUE); $this->tmpDirs[] = $tmpDir; return $tmpDir; } + /** + * Generates a persistent prefix to use with all of our temporary directories. + * + * The presumption is that this should reduce collisions in highly-parallel tests. + * We prepend the process id to play nicely with phpunit process isolation. + * + * @returns string + * A random string that will remain the same throughout the execution of the tests. + */ + protected static function persistentPrefix() { + if (empty(static::$randomPrefix)) { + static::$randomPrefix = getmypid() . md5(microtime()); + } + return static::$randomPrefix; + } + /** * Creates a temporary directory. * - * @param string $extraSalt - * Extra characters to throw into the md5 to add to name. + * @param string $prefix + * A prefix for the temporary directory name. * * @return string * Path to temporary directory */ - public function mkTmpDir($extraSalt = '') { - $tmpDir = $this->tmpDir($extraSalt); + public function mkTmpDir($prefix) { + $tmpDir = $this->tmpDir($prefix); $filesystem = new Filesystem(); $filesystem->ensureDirectoryExists($tmpDir); return $tmpDir; @@ -342,28 +364,21 @@ public function runScaffold($cwd) { * The Composer command to execute (escaped as required) * @param string $cwd * The current working directory to run the command from. - * @param int $expectedExitCode - * The expected exit code; will throw if a different exit code is returned. * * @return string * Standard output and standard error from the command. */ - public function runComposer($cmd, $cwd, $expectedExitCode = 0) { + public function runComposer($cmd, $cwd) { chdir($cwd); $input = new StringInput($cmd); $output = new BufferedOutput(); $application = new Application(); $application->setAutoExit(FALSE); - try { - $exitCode = $application->run($input, $output); - if ($exitCode != $expectedExitCode) { - print "Command '{$cmd}' - Expected exit code: {$expectedExitCode}, actual exit code: {$exitCode}\n"; - } - } - catch (\Exception $e) { - print "Exception: " . $e->getMessage() . "\n"; - } + $exitCode = $application->run($input, $output); $output = $output->fetch(); + if ($exitCode != 0) { + throw new \Exception("Fixtures::runComposer failed to set up fixtures.\n\nCommand: '{$cmd}'\nExit code: {$exitCode}\nOutput: \n\n$output"); + } return $output; } diff --git a/core/tests/Drupal/Tests/Component/Scaffold/Functional/ManageGitIgnoreTest.php b/core/tests/Drupal/Tests/Component/Scaffold/Functional/ManageGitIgnoreTest.php index c27e3e2fdf..6cffd62eab 100644 --- a/core/tests/Drupal/Tests/Component/Scaffold/Functional/ManageGitIgnoreTest.php +++ b/core/tests/Drupal/Tests/Component/Scaffold/Functional/ManageGitIgnoreTest.php @@ -169,6 +169,7 @@ public function testUnmanagedGitIgnoreWhenGitNotAvailable() { $this->assertFileNotExists($sut . '/docroot/sites/.gitignore'); // Confirm that 'git' is available (n.b. if it were not, createSutWithGit() // would fail). + $output = ''; exec('git --help', $output, $status); $this->assertEquals(0, $status); // Modify our $PATH so that it begins with a path that contains an @@ -177,12 +178,44 @@ public function testUnmanagedGitIgnoreWhenGitNotAvailable() { // not need to restore the PATH when we are done. $unavailableGitPath = $this->fixtures->binFixtureDir('disable-git-bin'); chmod($unavailableGitPath . '/git', 0755); + $oldPath = getenv('PATH'); putenv('PATH=' . $unavailableGitPath . ':' . getenv('PATH')); // Confirm that 'git' is no longer available. + $output = ''; exec('git --help', $output, $status); $this->assertEquals(127, $status); // Run the scaffold command. + $output = ''; exec('composer composer:scaffold', $output, $status); + + putenv('PATH=' . $oldPath . ':' . getenv('PATH')); + + $expected = <<assertEquals($expected, $status . "\n\n" . implode("\n", $output)); $this->assertFileExists($sut . '/docroot/index.php'); $this->assertFileNotExists($sut . '/docroot/sites/default/.gitignore'); }