From 4e1f77e38bd5bbab6ce2470211f02c653f0a6897 Mon Sep 17 00:00:00 2001 From: Arnaud Le Blanc Date: Fri, 11 Apr 2025 13:27:17 +0200 Subject: [PATCH 1/2] run-tests.php: Remove extra env vars --- run-tests.php | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/run-tests.php b/run-tests.php index 0db6937c7a848..57e2cd04c0e72 100755 --- a/run-tests.php +++ b/run-tests.php @@ -2723,8 +2723,12 @@ function run_test(string $php, $file, array $env): string if (!$passed || $leaked) { // write .sh if (strpos($log_format, 'S') !== false) { - $env_lines = []; + $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"; @@ -2733,7 +2737,7 @@ function run_test(string $php, $file, array $env): string {$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} From efd0edd6a137c4c7772ceadb950aa67f87801956 Mon Sep 17 00:00:00 2001 From: Arnaud Le Blanc Date: Tue, 15 Apr 2025 17:26:21 +0200 Subject: [PATCH 2/2] Comment --- run-tests.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/run-tests.php b/run-tests.php index 57e2cd04c0e72..9dec25361298e 100755 --- a/run-tests.php +++ b/run-tests.php @@ -2723,6 +2723,8 @@ function run_test(string $php, $file, array $env): string if (!$passed || $leaked) { // write .sh if (strpos($log_format, 'S') !== false) { + // 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) === '') {