Currently implementation of vendorTestCodeCleanup() from core/lib/Drupal/Core/Composer/Composer.php coming with some room of space for improvement:

  • It is now hardcode mapping the cleanup target directories with static::$packageToCleanup, so will not cleanup other else vendor package's test code if possible
  • Custom implementation of findPackageKey() can be replaced by the use of symfony/finder, plus the use of regex for matching
  • Custom implementation of deleteRecursive() can be replaced by the use of symfony/filesystem

Original implementation cloned from (ok these 2 files are just identical):

Usage example:

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

hswong3i created an issue. See original summary.

hswong3i’s picture

Title: Enhance vendorTestCodeCleanup() with symfony/finder and symfony/filesystem » Improve vendorTestCodeCleanup() with symfony/finder and symfony/filesystem
FileSize
7.92 KB
hswong3i’s picture

hswong3i’s picture

Issue summary: View changes
Mile23’s picture

Status: Needs review » Needs work

This kind of change would definitely be in 8.2.x.

+1 on using symfony/finder, but it's not a dependency of core.

-1 on tossing away the big array of directories. We made that in order to be specific about what we're removing.

We also need to have a way to show whether the directory is missing or has otherwise changed. See the conversation here: #2664274: Combination of --prefer-dist and .gitattributes confuses our vendor test cleanup

hswong3i’s picture

  • Add symfony/filesystem and symfony/finder as core dependency. Actually there must be room of space for utilize these 2 package in order to replace some of our legacy core code with manual folder/file handling.
  • Add back the original big array of directories, which just transform it as regex for symfony/finder.

Moreover, after a quick check with original though for #2664274: Combination of --prefer-dist and .gitattributes confuses our vendor test cleanup:

The result is that our post-install script throws an exception when e.g. tests/ directory is missing.

Now we will not hit such exception anymore, because of the use of symfony/finder ;-)

Status: Needs review » Needs work
hswong3i’s picture

Fix typo during translate original big array with regex...

Version: 8.2.x-dev » 8.3.x-dev

Drupal 8.2.0-beta1 was released on August 3, 2016, which means new developments and disruptive changes should now be targeted against the 8.3.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.3.x-dev » 8.4.x-dev

Drupal 8.3.0-alpha1 will be released the week of January 30, 2017, which means new developments and disruptive changes should now be targeted against the 8.4.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.4.x-dev » 8.5.x-dev

Drupal 8.4.0-alpha1 will be released the week of July 31, 2017, which means new developments and disruptive changes should now be targeted against the 8.5.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.5.x-dev » 8.6.x-dev

Drupal 8.5.0-alpha1 will be released the week of January 17, 2018, which means new developments and disruptive changes should now be targeted against the 8.6.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.6.x-dev » 8.7.x-dev

Drupal 8.6.0-alpha1 will be released the week of July 16, 2018, which means new developments and disruptive changes should now be targeted against the 8.7.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.7.x-dev » 8.8.x-dev

Drupal 8.7.0-alpha1 will be released the week of March 11, 2019, which means new developments and disruptive changes should now be targeted against the 8.8.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Mile23’s picture

Status: Needs review » Closed (outdated)

vendorTestCodeCleanup() has been moved to a Composer plugin: https://www.drupal.org/node/3059717

We didn't use the symfony components, though it would still make sense to do so.

The plugin is configurable: https://www.drupal.org/docs/develop/using-composer/using-drupals-vendor-...

Closing here. Thanks, @hswong3i.