From fcf3ecc4d51eab2fa37a020676c77931c687cb50 Mon Sep 17 00:00:00 2001 From: Pascal Birchler Date: Mon, 23 Mar 2026 13:27:38 +0100 Subject: [PATCH 1/2] 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; From bc9d294584b04e6a5677feb21af6467090f4acfc Mon Sep 17 00:00:00 2001 From: Pascal Birchler Date: Mon, 23 Mar 2026 23:10:32 +0100 Subject: [PATCH 2/2] Set `WP_CLI_SKIP_PROMPT` by default in tests --- src/Context/FeatureContext.php | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/Context/FeatureContext.php b/src/Context/FeatureContext.php index 9a576f71..07bb3299 100644 --- a/src/Context/FeatureContext.php +++ b/src/Context/FeatureContext.php @@ -450,11 +450,12 @@ private static function get_process_env_variables(): array { $path_separator = Utils\is_windows() ? ';' : ':'; $php_binary_path = dirname( PHP_BINARY ); $env = [ - 'PATH' => $php_binary_path . $path_separator . $bin_path . $path_separator . getenv( 'PATH' ), - 'BEHAT_RUN' => 1, - 'HOME' => sys_get_temp_dir() . '/wp-cli-home', - 'COMPOSER_HOME' => sys_get_temp_dir() . '/wp-cli-composer-home', - 'TEST_RUN_DIR' => self::$behat_run_dir, + 'PATH' => $php_binary_path . $path_separator . $bin_path . $path_separator . getenv( 'PATH' ), + 'BEHAT_RUN' => 1, + 'HOME' => sys_get_temp_dir() . '/wp-cli-home', + 'COMPOSER_HOME' => sys_get_temp_dir() . '/wp-cli-composer-home', + 'TEST_RUN_DIR' => self::$behat_run_dir, + 'WP_CLI_SKIP_PROMPT' => 'no', ]; $env = array_merge( $_ENV, $env );