@@ -653,11 +653,12 @@ public static function prepare( BeforeSuiteScope $scope ): void {
653653 self ::log_run_times_before_suite ( $ scope );
654654 }
655655 self ::$ behat_run_dir = getcwd ();
656- self ::$ mysql_binary = Utils \get_mysql_binary_path ();
657656
658657 // TODO: Improve Windows support upstream in Utils\get_mysql_binary_path().
659- if ( Utils \is_windows () && ! self :: $ mysql_binary ) {
658+ if ( Utils \is_windows () ) {
660659 self ::$ mysql_binary = 'mysql.exe ' ;
660+ } else {
661+ self ::$ mysql_binary = Utils \get_mysql_binary_path ();
661662 }
662663
663664 $ result = Process::create ( 'wp cli info ' , null , self ::get_process_env_variables () )->run_check ();
@@ -1056,14 +1057,18 @@ public function build_phar( $version = 'same' ): void {
10561057 $ this ->composer_command ( 'dump-autoload --working-dir= ' . dirname ( self ::get_vendor_dir () ) );
10571058 }
10581059
1059- $ this ->proc (
1060- Utils \esc_cmd (
1061- 'php -dphar.readonly=0 %1$s %2$s --version=%3$s && chmod +x %2$s ' ,
1062- $ make_phar_path ,
1063- $ this ->variables ['PHAR_PATH ' ],
1064- $ version
1065- )
1066- )->run_check ();
1060+ $ command = Utils \esc_cmd (
1061+ 'php -dphar.readonly=0 %1$s %2$s --version=%3$s ' ,
1062+ $ make_phar_path ,
1063+ $ this ->variables ['PHAR_PATH ' ],
1064+ $ version
1065+ );
1066+
1067+ if ( ! Utils \is_windows () ) {
1068+ $ command .= Utils \esc_cmd ( ' && chmod +x %s ' , $ this ->variables ['PHAR_PATH ' ] );
1069+ }
1070+
1071+ $ this ->proc ( $ command )->run_check ();
10671072
10681073 // Revert the suffix change again
10691074 if ( $ is_bundle && self ::running_with_code_coverage () ) {
@@ -1565,7 +1570,14 @@ public function start_php_server( $subdir = '' ): void {
15651570 */
15661571 private function composer_command ( $ cmd ): void {
15671572 if ( ! isset ( $ this ->variables ['COMPOSER_PATH ' ] ) ) {
1568- $ this ->variables ['COMPOSER_PATH ' ] = exec ( 'which composer ' );
1573+ $ command = Utils \is_windows () ? 'where composer ' : 'which composer ' ;
1574+ $ path = exec ( $ command );
1575+ if ( false === $ path ) {
1576+ throw new RuntimeException ( 'Could not find composer. ' );
1577+ }
1578+ // In case of multiple paths, pick the first one.
1579+ $ path = strtok ( $ path , PHP_EOL );
1580+ $ this ->variables ['COMPOSER_PATH ' ] = $ path ;
15691581 }
15701582 $ this ->proc ( $ this ->variables ['COMPOSER_PATH ' ] . ' --no-interaction ' . $ cmd )->run_check ();
15711583 }
0 commit comments