Skip to content

Commit 0eea5d3

Browse files
authored
run-tests.php: Remove extra env vars in the generated .sh file (#18306)
1 parent 3737e0a commit 0eea5d3

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

run-tests.php

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2735,8 +2735,14 @@ function run_test(string $php, $file, array $env): string
27352735
if (!$passed || $leaked) {
27362736
// write .sh
27372737
if (strpos($log_format, 'S') !== false) {
2738-
$env_lines = [];
2738+
// Unset all environment variables so that we don't inherit extra
2739+
// ones from the parent process.
2740+
$env_lines = ['unset $(env | cut -d= -f1)'];
27392741
foreach ($env as $env_var => $env_val) {
2742+
if (strval($env_val) === '') {
2743+
// proc_open does not pass empty env vars
2744+
continue;
2745+
}
27402746
$env_lines[] = "export $env_var=" . escapeshellarg($env_val ?? "");
27412747
}
27422748
$exported_environment = "\n" . implode("\n", $env_lines) . "\n";
@@ -2745,7 +2751,7 @@ function run_test(string $php, $file, array $env): string
27452751
{$exported_environment}
27462752
case "$1" in
27472753
"gdb")
2748-
gdb --args {$orig_cmd}
2754+
gdb -ex 'unset environment LINES' -ex 'unset environment COLUMNS' --args {$orig_cmd}
27492755
;;
27502756
"lldb")
27512757
lldb -- {$orig_cmd}

0 commit comments

Comments
 (0)