run-tests.php: Remove extra env vars in the generated .sh file (#18306)

This commit is contained in:
Arnaud Le Blanc 2025-04-29 10:59:10 +02:00 committed by GitHub
parent 3737e0aa6f
commit 0eea5d31e0
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -2735,8 +2735,14 @@ $output
if (!$passed || $leaked) {
// write .sh
if (strpos($log_format, 'S') !== false) {
$env_lines = [];
// Unset all environment variables so that we don't inherit extra
// ones from the parent process.
$env_lines = ['unset $(env | cut -d= -f1)'];
foreach ($env as $env_var => $env_val) {
if (strval($env_val) === '') {
// proc_open does not pass empty env vars
continue;
}
$env_lines[] = "export $env_var=" . escapeshellarg($env_val ?? "");
}
$exported_environment = "\n" . implode("\n", $env_lines) . "\n";
@ -2745,7 +2751,7 @@ $output
{$exported_environment}
case "$1" in
"gdb")
gdb --args {$orig_cmd}
gdb -ex 'unset environment LINES' -ex 'unset environment COLUMNS' --args {$orig_cmd}
;;
"lldb")
lldb -- {$orig_cmd}