@@ -198,6 +198,12 @@ public static function get_bin_path() {
198198 * Get the environment variables required for launched `wp` processes
199199 */
200200 private static function get_process_env_variables () {
201+ static $ env = null ;
202+
203+ if ( null !== $ env ) {
204+ return $ env ;
205+ }
206+
201207 // Ensure we're using the expected `wp` binary.
202208 $ bin_path = self ::get_bin_path ();
203209 wp_cli_behat_env_debug ( "WP-CLI binary path: {$ bin_path }" );
@@ -333,30 +339,15 @@ public static function prepare( BeforeSuiteScope $scope ) {
333339 }
334340
335341 $ result = Process::create ( 'wp cli info ' , null , self ::get_process_env_variables () )->run_check ();
336- echo PHP_EOL ;
337- echo $ result ->stdout ;
338- echo PHP_EOL ;
339-
340- if ( getenv ( 'WP_CLI_TEST_DEBUG_BEHAT_ENV ' ) ) {
341- exit ;
342- }
342+ echo "{$ result ->stdout }\n" ;
343343
344344 self ::cache_wp_files ();
345345
346346 $ result = Process::create ( Utils \esc_cmd ( 'wp core version --debug --path=%s ' , self ::$ cache_dir ), null , self ::get_process_env_variables () )->run_check ();
347+ echo "[Debug messages] \n" ;
348+ echo "{$ result ->stderr }\n" ;
347349
348- $ ci = getenv ( 'CI ' );
349- $ travis = getenv ( 'TRAVIS ' );
350- if ( $ travis || $ ci ) {
351- $ travis && print ( "travis_fold:start:wp_cli_debug \n" );
352- echo "[Debug messages] \n" ;
353- echo $ result ->stderr ;
354- $ travis && print ( "travis_fold:end:wp_cli_debug \n" );
355- }
356-
357- echo PHP_EOL ;
358- echo 'WordPress ' . $ result ->stdout ;
359- echo PHP_EOL ;
350+ echo "WordPress {$ result ->stdout }\n" ;
360351
361352 // Remove install cache if any (not setting the static var).
362353 $ wp_version = getenv ( 'WP_VERSION ' );
@@ -365,6 +356,10 @@ public static function prepare( BeforeSuiteScope $scope ) {
365356 if ( file_exists ( $ install_cache_dir ) ) {
366357 self ::remove_dir ( $ install_cache_dir );
367358 }
359+
360+ if ( getenv ( 'WP_CLI_TEST_DEBUG_BEHAT_ENV ' ) ) {
361+ exit ;
362+ }
368363 }
369364
370365 /**
0 commit comments