Create a new console for each test worker on Windows

The primary motivation to have each test worker running its own console
is to allow the windows_mb_path tests to run in parallel.  A nice side
effect is that this also prevents changing the code page of the
tester's console window (which can even cause its font to be changed).

To be able to do so, we introduce the `create_new_console` option for
`proc_open()`, which might occasionally be useful for other purposes
than testing.
This commit is contained in:
Christoph M. Becker 2020-02-12 14:34:48 +01:00
parent 54ecf57fe2
commit e1de11d467
3 changed files with 13 additions and 5 deletions

View file

@ -504,6 +504,7 @@ PHP_FUNCTION(proc_open)
int bypass_shell = 0;
int blocking_pipes = 0;
int create_process_group = 0;
int create_new_console = 0;
#else
char **argv = NULL;
#endif
@ -598,6 +599,13 @@ PHP_FUNCTION(proc_open)
create_process_group = 1;
}
}
item = zend_hash_str_find(Z_ARRVAL_P(other_options), "create_new_console", sizeof("create_new_console") - 1);
if (item != NULL) {
if (Z_TYPE_P(item) == IS_TRUE || ((Z_TYPE_P(item) == IS_LONG) && Z_LVAL_P(item))) {
create_new_console = 1;
}
}
}
#endif
@ -921,7 +929,9 @@ PHP_FUNCTION(proc_open)
if (create_process_group) {
dwCreateFlags |= CREATE_NEW_PROCESS_GROUP;
}
if (create_new_console) {
dwCreateFlags |= CREATE_NEW_CONSOLE;
}
envpw = php_win32_cp_env_any_to_w(env.envp);
if (envpw) {
dwCreateFlags |= CREATE_UNICODE_ENVIRONMENT;

View file

@ -1,3 +0,0 @@
# These tests depend on the console codepage, which is shared across all parallel workers.
# Force these tests to run sequentially to make sure the codepage isn't change by another process.
all

View file

@ -1424,7 +1424,8 @@ function run_all_tests_parallel($test_files, $env, $redir_tested) {
"TEST_PHP_URI" => $sockUri,
],
[
"suppress_errors" => TRUE
"suppress_errors" => TRUE,
'create_new_console' => TRUE,
]
);
if ($proc === FALSE) {