Skip to content

12696 Delete all test modules after integration tests #18459

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions dev/tests/integration/framework/bootstrap.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,15 @@
define('INTEGRATION_TESTS_DIR', $testsBaseDir);
}

$testFrameworkDir = __DIR__;
require_once 'deployTestModules.php';

try {
setCustomErrorHandler();

/* Bootstrap the application */
$settings = new \Magento\TestFramework\Bootstrap\Settings($testsBaseDir, get_defined_constants());

$testFrameworkDir = __DIR__;
require_once 'deployTestModules.php';

if ($settings->get('TESTS_EXTRA_VERBOSE_LOG')) {
$filesystem = new \Magento\Framework\Filesystem\Driver\File();
$exceptionHandler = new \Magento\Framework\Logger\Handler\Exception($filesystem);
Expand Down
28 changes: 27 additions & 1 deletion dev/tests/integration/framework/deployTestModules.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
*/

/**
* @var $testFrameworkDir string - Must be defined in parent script.
* @var string $testFrameworkDir - Must be defined in parent script.
* @var \Magento\TestFramework\Bootstrap\Settings $settings - Must be defined in parent script.
*/

/** Copy test modules to app/code/Magento to make them visible for Magento instance */
Expand Down Expand Up @@ -38,3 +39,28 @@
foreach ($files as $file) {
include $file;
}

if (!$settings->get('TESTS_PARALLEL_THREAD', 0)) {
// Only delete modules if we are not using parallel executions
register_shutdown_function('deleteTestModules', $pathToCommittedTestModules, $pathToInstalledMagentoInstanceModules);
}

/**
* Delete all test module directories which have been created before
*
* @param string $pathToCommittedTestModules
* @param string $pathToInstalledMagentoInstanceModules
*/
function deleteTestModules($pathToCommittedTestModules, $pathToInstalledMagentoInstanceModules)
{
$filesystem = new \Symfony\Component\Filesystem\Filesystem();
$iterator = new DirectoryIterator($pathToCommittedTestModules);
/** @var SplFileInfo $file */
foreach ($iterator as $file) {
if ($file->isDir() && !in_array($file->getFilename(), ['.', '..'])) {
$targetDirPath = $pathToInstalledMagentoInstanceModules . '/' . $file->getFilename();
$filesystem->remove($targetDirPath);
}
}
unset($iterator, $file);
}