Skip to content

Commit 4b71eb3

Browse files
committed
more ai fixes
1 parent a3804a6 commit 4b71eb3

File tree

2 files changed

+27
-12
lines changed

2 files changed

+27
-12
lines changed

src/Context/FeatureContext.php

Lines changed: 23 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -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
}

src/Context/GivenStepDefinitions.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -604,7 +604,10 @@ public function given_a_download( TableNode $table ): void {
604604
continue;
605605
}
606606

607-
Process::create( Utils\esc_cmd( 'curl -sSL %s > %s', $row['url'], $path ) )->run_check();
607+
$response = Utils\http_request( 'GET', $row['url'], null, [], [ 'filename' => $path ] );
608+
if ( 200 !== $response->status_code ) {
609+
throw new RuntimeException( "Could not download file (HTTP code {$response->status_code})" );
610+
}
608611
}
609612
}
610613

0 commit comments

Comments
 (0)