From 935a6a323b165866af284375e3d0705fb3d98517 Mon Sep 17 00:00:00 2001 From: Daniel Bachhuber Date: Thu, 6 Oct 2022 13:05:06 -0700 Subject: [PATCH 1/2] Always run WP core caching process, and display `wp core version` --- src/Context/FeatureContext.php | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/Context/FeatureContext.php b/src/Context/FeatureContext.php index a73e01e3..cdfa81a6 100644 --- a/src/Context/FeatureContext.php +++ b/src/Context/FeatureContext.php @@ -337,10 +337,6 @@ public static function prepare( BeforeSuiteScope $scope ) { echo $result->stdout; echo PHP_EOL; - if ( getenv( 'WP_CLI_TEST_DEBUG_BEHAT_ENV' ) ) { - exit; - } - self::cache_wp_files(); $result = Process::create( Utils\esc_cmd( 'wp core version --debug --path=%s', self::$cache_dir ), null, self::get_process_env_variables() )->run_check(); From 1a3da516bc5fb9d894d98458bba708414b47006c Mon Sep 17 00:00:00 2001 From: Alain Schlesser Date: Thu, 6 Oct 2022 15:56:15 -0700 Subject: [PATCH 2/2] Adapt debug info logic --- src/Context/FeatureContext.php | 29 ++++++++++++++--------------- 1 file changed, 14 insertions(+), 15 deletions(-) diff --git a/src/Context/FeatureContext.php b/src/Context/FeatureContext.php index cdfa81a6..976fc97b 100644 --- a/src/Context/FeatureContext.php +++ b/src/Context/FeatureContext.php @@ -198,6 +198,12 @@ public static function get_bin_path() { * Get the environment variables required for launched `wp` processes */ private static function get_process_env_variables() { + static $env = null; + + if ( null !== $env ) { + return $env; + } + // Ensure we're using the expected `wp` binary. $bin_path = self::get_bin_path(); wp_cli_behat_env_debug( "WP-CLI binary path: {$bin_path}" ); @@ -333,26 +339,15 @@ public static function prepare( BeforeSuiteScope $scope ) { } $result = Process::create( 'wp cli info', null, self::get_process_env_variables() )->run_check(); - echo PHP_EOL; - echo $result->stdout; - echo PHP_EOL; + echo "{$result->stdout}\n"; self::cache_wp_files(); $result = Process::create( Utils\esc_cmd( 'wp core version --debug --path=%s', self::$cache_dir ), null, self::get_process_env_variables() )->run_check(); + echo "[Debug messages]\n"; + echo "{$result->stderr}\n"; - $ci = getenv( 'CI' ); - $travis = getenv( 'TRAVIS' ); - if ( $travis || $ci ) { - $travis && print( "travis_fold:start:wp_cli_debug\n" ); - echo "[Debug messages]\n"; - echo $result->stderr; - $travis && print( "travis_fold:end:wp_cli_debug\n" ); - } - - echo PHP_EOL; - echo 'WordPress ' . $result->stdout; - echo PHP_EOL; + echo "WordPress {$result->stdout}\n"; // Remove install cache if any (not setting the static var). $wp_version = getenv( 'WP_VERSION' ); @@ -361,6 +356,10 @@ public static function prepare( BeforeSuiteScope $scope ) { if ( file_exists( $install_cache_dir ) ) { self::remove_dir( $install_cache_dir ); } + + if ( getenv( 'WP_CLI_TEST_DEBUG_BEHAT_ENV' ) ) { + exit; + } } /**