@@ -405,26 +405,12 @@ public static function get_bin_path(): ?string {
405405 self ::get_framework_dir () . DIRECTORY_SEPARATOR . 'bin ' ,
406406 ];
407407
408- if ( Utils \is_windows () ) {
409- foreach ( $ bin_paths as $ path ) {
410- $ wp_script_path = $ path . DIRECTORY_SEPARATOR . 'wp ' ;
411- if ( is_file ( $ wp_script_path ) ) {
412- $ wp_bat_path = $ path . DIRECTORY_SEPARATOR . 'wp.bat ' ;
413- if ( ! is_file ( $ wp_bat_path ) ) {
414- $ bat_content = '@ECHO OFF ' . PHP_EOL ;
415- // Use the currently running PHP executable to avoid PATH issues.
416- $ bat_content .= '" ' . PHP_BINARY . '" " ' . realpath ( $ wp_script_path ) . '" %* ' ;
417- file_put_contents ( $ wp_bat_path , $ bat_content );
418- }
419- return $ path ;
420- }
421- }
422- } else {
423- foreach ( $ bin_paths as $ path ) {
424- $ full_bin_path = $ path . DIRECTORY_SEPARATOR . 'wp ' ;
425- if ( is_file ( $ full_bin_path ) && is_executable ( $ full_bin_path ) ) {
426- return $ path ;
427- }
408+ $ bin = Utils \is_windows () ? 'wp.bat ' : 'wp ' ;
409+
410+ foreach ( $ bin_paths as $ path ) {
411+ $ full_bin_path = $ path . DIRECTORY_SEPARATOR . $ bin ;
412+ if ( is_file ( $ full_bin_path ) && ( Utils \is_windows () || is_executable ( $ full_bin_path ) ) ) {
413+ return $ path ;
428414 }
429415 }
430416
@@ -684,6 +670,10 @@ public static function prepare( BeforeSuiteScope $scope ): void {
684670 if ( file_exists ( $ install_cache_dir ) ) {
685671 self ::remove_dir ( $ install_cache_dir );
686672 }
673+
674+ if ( getenv ( 'WP_CLI_TEST_DEBUG_BEHAT_ENV ' ) ) {
675+ exit ;
676+ }
687677 }
688678
689679 /**
@@ -1847,9 +1837,6 @@ private static function log_proc_method_run_time( $key, $start_time ): void {
18471837 * @param string $message
18481838 */
18491839function wp_cli_behat_env_debug ( $ message ): void { // phpcs:ignore Universal.Files.SeparateFunctionsFromOO.Mixed
1850- // Always print the message to STDERR for debugging purposes.
1851- fwrite ( STDERR , "{$ message }\n" );
1852-
18531840 if ( ! getenv ( 'WP_CLI_TEST_DEBUG_BEHAT_ENV ' ) ) {
18541841 return ;
18551842 }
0 commit comments