From dbfed10a97ecde9df0bc6bcbc607f0d71038582d Mon Sep 17 00:00:00 2001 From: Calvin Buckley Date: Wed, 27 Sep 2023 13:45:50 -0300 Subject: [PATCH] Change bless to clean up absolute paths User-specific absolute paths should be avoided in tests, since they aren't portable. Change bless to detect common places where this occurs and make it use %s in EXPECTF if so. This was originally developed as part of GH-12276. While the approved RFC doesn't enable function parameters to be printed for tests, the functionality is generally useful. --- scripts/dev/bless_tests.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/scripts/dev/bless_tests.php b/scripts/dev/bless_tests.php index 7493a504729c..a578903ef6dd 100755 --- a/scripts/dev/bless_tests.php +++ b/scripts/dev/bless_tests.php @@ -74,6 +74,10 @@ function normalizeOutput(string $out): string { 'Resource ID#%d used as offset, casting to integer (%d)', $out); $out = preg_replace('/string\(\d+\) "([^"]*%d)/', 'string(%d) "$1', $out); + // Inside of strings, replace absolute paths that have been truncated with + // any string. These tend to contain homedirs with usernames, not good. + $out = preg_replace("/'\\/.*\.\\.\\.'/", "'%s'", $out); + $out = preg_replace("/'file:\/\\/.*\.\\.\\.'/", "'%s'", $out); $out = str_replace("\0", '%0', $out); return $out; }