Skip to content

Commit 0056f0a

Browse files
committed
another one
1 parent b7b0b5c commit 0056f0a

File tree

1 file changed

+15
-11
lines changed

1 file changed

+15
-11
lines changed

tests/tests/TestBehatTags.php

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -68,26 +68,30 @@ private function run_behat_tags_script( $env = '' ) {
6868
// Use the `-n` flag to disable loading of `php.ini` and ensure a clean environment.
6969
$php_run = escapeshellarg( PHP_BINARY ) . ' -n ' . escapeshellarg( $behat_tags );
7070

71+
$features_dir = $this->temp_dir . DIRECTORY_SEPARATOR . 'features';
72+
7173
$command = '';
72-
if ( ! empty( $env ) ) {
73-
// putenv() can be unreliable. Prepending the variable to the command is more robust.
74-
if ( Utils\is_windows() ) {
75-
// `set` is internal to `cmd.exe`. Do not escape the $env variable, as it's from a trusted
76-
// data provider and `escapeshellarg` adds quotes that `set` doesn't understand.
77-
// Note: `set "VAR=VALUE"` is more robust than `set VAR=VALUE`.
78-
$command = 'set "' . $env . '" && ';
79-
} else {
80-
// On Unix-like systems, this sets the variable for the duration of the command.
81-
$command = $env . ' ';
74+
if ( Utils\is_windows() ) {
75+
// `set` is internal to `cmd.exe`. Do not escape the values, as `set` doesn't understand quotes from escapeshellarg.
76+
// Note: `set "VAR=VALUE"` is more robust than `set VAR=VALUE`.
77+
$command = 'set "BEHAT_FEATURES_FOLDER=' . $features_dir . '" && ';
78+
if ( ! empty( $env ) ) {
79+
$command .= 'set "' . $env . '" && ';
8280
}
81+
} else {
82+
// On Unix-like systems, this sets the variable for the duration of the command.
83+
$command = 'BEHAT_FEATURES_FOLDER=' . escapeshellarg( $features_dir );
84+
if ( ! empty( $env ) ) {
85+
$command .= ' ' . $env;
86+
}
87+
$command .= ' ';
8388
}
8489

8590
$command = 'cd ' . escapeshellarg( $this->temp_dir ) . ' && ' . $command . $php_run;
8691
$output = exec( $command );
8792

8893
return $output;
8994
}
90-
9195
/**
9296
* @dataProvider data_behat_tags_wp_version_github_token
9397
*

0 commit comments

Comments
 (0)