From d75af9a36388d99f819695d65ec6d49ac6b72181 Mon Sep 17 00:00:00 2001 From: Gintautas Miselis Date: Sat, 20 Feb 2021 13:10:12 +0200 Subject: [PATCH] Clean: Do not delete .gitkeep files Because they are often used in _output directories --- src/Codeception/Util/FileSystem.php | 2 +- tests/cli/CleanCest.php | 21 +++++++++++++++++++++ tests/cli/IncludedCest.php | 1 - 3 files changed, 22 insertions(+), 2 deletions(-) create mode 100644 tests/cli/CleanCest.php diff --git a/src/Codeception/Util/FileSystem.php b/src/Codeception/Util/FileSystem.php index f896defc9c..ce79aea77f 100644 --- a/src/Codeception/Util/FileSystem.php +++ b/src/Codeception/Util/FileSystem.php @@ -20,7 +20,7 @@ public static function doEmptyDir($path) foreach ($iterator as $path) { $basename = basename((string)$path); - if ($basename === '.' || $basename === '..' || $basename === '.gitignore') { + if ($basename === '.' || $basename === '..' || $basename === '.gitignore' || $basename === '.gitkeep') { continue; } diff --git a/tests/cli/CleanCest.php b/tests/cli/CleanCest.php new file mode 100644 index 0000000000..6e9609c63c --- /dev/null +++ b/tests/cli/CleanCest.php @@ -0,0 +1,21 @@ +amInPath('tests/data/included'); + $I->executeCommand('clean'); + $I->seeInShellOutput("included{$ds}_log"); + $I->seeInShellOutput("included{$ds}jazz{$ds}tests/_log"); + $I->seeInShellOutput("included{$ds}jazz{$ds}pianist{$ds}tests/_log"); + $I->seeInShellOutput("included{$ds}shire{$ds}tests/_log"); + $I->seeInShellOutput('Done'); + $I->seeFileFound("_log/.gitkeep"); + $I->seeFileFound("jazz{$ds}tests/_log/.gitkeep"); + $I->seeFileFound("jazz{$ds}pianist{$ds}tests/_log/.gitkeep"); + $I->seeFileFound("shire{$ds}tests/_log/.gitkeep"); + } +} diff --git a/tests/cli/IncludedCest.php b/tests/cli/IncludedCest.php index 2e790d0311..d1e4c2d8e2 100644 --- a/tests/cli/IncludedCest.php +++ b/tests/cli/IncludedCest.php @@ -6,7 +6,6 @@ public function _before() { $logDir = codecept_root_dir('tests/data/included/_log'); \Codeception\Util\FileSystem::doEmptyDir($logDir); - file_put_contents($logDir . '/.gitkeep', ''); } /**