Unverified Commit 3b6698e9 authored by alexpott's avatar alexpott
Browse files

Issue #3088400 by heddn, Mile23: BuildTestBase->copyCodebase overly aggressive in exclusions

parent f6b2481a
...@@ -547,13 +547,12 @@ public function copyCodebase(\Iterator $iterator = NULL, $working_dir = NULL) { ...@@ -547,13 +547,12 @@ public function copyCodebase(\Iterator $iterator = NULL, $working_dir = NULL) {
if ($iterator === NULL) { if ($iterator === NULL) {
$finder = new Finder(); $finder = new Finder();
$finder->files() $finder->files()
->ignoreUnreadableDirs()
->in($this->getDrupalRoot()) ->in($this->getDrupalRoot())
->exclude([ ->notPath('#^sites/default/files#')
'sites/default/files', ->notPath('#^sites/simpletest#')
'sites/simpletest', ->notPath('#^vendor#')
'vendor', ->notPath('#^sites/default/settings\..*php#')
])
->notPath('/sites\/default\/settings\..*php/')
->ignoreDotFiles(FALSE) ->ignoreDotFiles(FALSE)
->ignoreVCS(FALSE); ->ignoreVCS(FALSE);
$iterator = $finder->getIterator(); $iterator = $finder->getIterator();
......
...@@ -4,6 +4,7 @@ ...@@ -4,6 +4,7 @@
use Drupal\BuildTests\Framework\BuildTestBase; use Drupal\BuildTests\Framework\BuildTestBase;
use org\bovigo\vfs\vfsStream; use org\bovigo\vfs\vfsStream;
use Symfony\Component\Filesystem\Filesystem;
use Symfony\Component\Finder\Finder; use Symfony\Component\Finder\Finder;
/** /**
...@@ -56,8 +57,8 @@ public function testCopyCodebase() { ...@@ -56,8 +57,8 @@ public function testCopyCodebase() {
* @covers ::copyCodebase * @covers ::copyCodebase
*/ */
public function testCopyCodebaseExclude() { public function testCopyCodebaseExclude() {
// Create a virtual file system containing only items that should be // Create a virtual file system containing items that should be
// excluded. // excluded. Exception being modules directory.
vfsStream::setup('drupal', NULL, [ vfsStream::setup('drupal', NULL, [
'sites' => [ 'sites' => [
'default' => [ 'default' => [
...@@ -65,6 +66,7 @@ public function testCopyCodebaseExclude() { ...@@ -65,6 +66,7 @@ public function testCopyCodebaseExclude() {
'a_file.txt' => 'some file.', 'a_file.txt' => 'some file.',
], ],
'settings.php' => '<?php $settings = stuff;', 'settings.php' => '<?php $settings = stuff;',
'settings.local.php' => '<?php $settings = override;',
], ],
'simpletest' => [ 'simpletest' => [
'simpletest_hash' => [ 'simpletest_hash' => [
...@@ -79,6 +81,15 @@ public function testCopyCodebaseExclude() { ...@@ -79,6 +81,15 @@ public function testCopyCodebaseExclude() {
], ],
], ],
], ],
'modules' => [
'my_module' => [
'vendor' => [
'my_vendor' => [
'composer.json' => "{\n}",
],
],
],
],
]); ]);
// Mock BuildTestBase so that it thinks our VFS is the Drupal root. // Mock BuildTestBase so that it thinks our VFS is the Drupal root.
...@@ -98,6 +109,13 @@ public function testCopyCodebaseExclude() { ...@@ -98,6 +109,13 @@ public function testCopyCodebaseExclude() {
$full_path = $base->getWorkspaceDirectory() . '/' . $test_directory; $full_path = $base->getWorkspaceDirectory() . '/' . $test_directory;
$this->assertDirectoryExists($full_path); $this->assertDirectoryExists($full_path);
// Verify nested vendor directory was not excluded. Then remove it for next
// validation.
$this->assertFileExists($full_path . DIRECTORY_SEPARATOR . 'modules/my_module/vendor/my_vendor/composer.json');
$file_system = new Filesystem();
$file_system->remove($full_path . DIRECTORY_SEPARATOR . 'modules');
// Use scandir() to determine if our target directory is empty. It should // Use scandir() to determine if our target directory is empty. It should
// only contain the system dot directories. // only contain the system dot directories.
$this->assertTrue( $this->assertTrue(
......
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