From fcf3ecc4d51eab2fa37a020676c77931c687cb50 Mon Sep 17 00:00:00 2001 From: Pascal Birchler Date: Mon, 23 Mar 2026 13:27:38 +0100 Subject: [PATCH] Harden cleanup on CI to avoid filesystem bottlenecks --- src/Context/FeatureContext.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/Context/FeatureContext.php b/src/Context/FeatureContext.php index 47a94dac..9a576f71 100644 --- a/src/Context/FeatureContext.php +++ b/src/Context/FeatureContext.php @@ -745,8 +745,10 @@ public function beforeScenario( BeforeScenarioScope $scope ): void { public function afterScenario( AfterScenarioScope $scope ): void { if ( self::$run_dir ) { - // Remove altered WP install, unless there's an error. - if ( $scope->getTestResult()->getResultCode() <= 10 ) { + // Remove altered WP install, unless there's an error (and we are not on CI). + $is_ci = getenv( 'CI' ); + $is_debug = getenv( 'WP_CLI_TEST_DEBUG_BEHAT_ENV' ); + if ( $scope->getTestResult()->getResultCode() <= 10 || ( $is_ci && ! $is_debug ) ) { self::remove_dir( self::$run_dir ); } self::$run_dir = null;