Skip to content

Commit 4e1559b

Browse files
committed
ai debugging
1 parent 8182330 commit 4e1559b

File tree

2 files changed

+16
-9
lines changed

2 files changed

+16
-9
lines changed

src/Context/FeatureContext.php

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -675,7 +675,11 @@ public static function prepare( BeforeSuiteScope $scope ): void {
675675
self::$mysql_binary = Utils\get_mysql_binary_path();
676676
}
677677

678-
$result = Process::create( 'wp cli info', null, self::get_process_env_variables() )->run_check();
678+
$command = 'wp cli info';
679+
if ( Utils\is_windows() ) {
680+
$command .= ' > NUL 2>&1';
681+
}
682+
$result = Process::create( $command, null, self::get_process_env_variables() )->run_check();
679683
echo "{$result->stdout}\n";
680684

681685
// Remove install cache if any (not setting the static var).
@@ -685,10 +689,6 @@ public static function prepare( BeforeSuiteScope $scope ): void {
685689
if ( file_exists( $install_cache_dir ) ) {
686690
self::remove_dir( $install_cache_dir );
687691
}
688-
689-
if ( getenv( 'WP_CLI_TEST_DEBUG_BEHAT_ENV' ) ) {
690-
exit;
691-
}
692692
}
693693

694694
/**
@@ -1854,6 +1854,9 @@ private static function log_proc_method_run_time( $key, $start_time ): void {
18541854
* @param string $message
18551855
*/
18561856
function wp_cli_behat_env_debug( $message ): void { // phpcs:ignore Universal.Files.SeparateFunctionsFromOO.Mixed
1857+
// Always print the message to STDERR for debugging purposes.
1858+
fwrite( STDERR, "{$message}\n" );
1859+
18571860
if ( ! getenv( 'WP_CLI_TEST_DEBUG_BEHAT_ENV' ) ) {
18581861
return;
18591862
}

tests/tests/TestBehatTags.php

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,16 +44,20 @@ protected function tear_down(): void {
4444
private function run_behat_tags_script( $env = '' ) {
4545
$behat_tags = dirname( dirname( __DIR__ ) ) . '/utils/behat-tags.php';
4646

47-
// Use the same PHP binary that is running the tests to ensure extension consistency.
48-
$php_run = escapeshellarg( PHP_BINARY ) . ' ' . escapeshellarg( $behat_tags );
47+
// Get the loaded ini file from the current process to ensure config consistency.
48+
$ini_file = php_ini_loaded_file();
49+
$ini_arg = $ini_file ? ' -c ' . escapeshellarg( $ini_file ) : '';
50+
51+
// Use the same PHP binary that is running the tests.
52+
$php_run = escapeshellarg( PHP_BINARY ) . $ini_arg . ' ' . escapeshellarg( $behat_tags );
4953

5054
$command = '';
5155
if ( ! empty( $env ) ) {
5256
// putenv() can be unreliable, especially on Windows.
5357
// Prepending the variable to the command is a more robust cross-platform solution.
54-
if ( Utils\is_windows() ) {
58+
if ( DIRECTORY_SEPARATOR === '\\' ) { // Windows
5559
// Note: `set` is internal to `cmd.exe` and works on the subsequent command after `&&`.
56-
$command = 'set ' . $env . ' && ';
60+
$command = 'set ' . escapeshellarg( $env ) . ' && ';
5761
} else {
5862
// On Unix-like systems, this sets the variable for the duration of the command.
5963
$command = $env . ' ';

0 commit comments

Comments
 (0)