Skip to content

Commit dbfed10

Browse files
committed
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.
1 parent c0af268 commit dbfed10

1 file changed

Lines changed: 4 additions & 0 deletions

File tree

scripts/dev/bless_tests.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,10 @@ function normalizeOutput(string $out): string {
7474
'Resource ID#%d used as offset, casting to integer (%d)',
7575
$out);
7676
$out = preg_replace('/string\(\d+\) "([^"]*%d)/', 'string(%d) "$1', $out);
77+
// Inside of strings, replace absolute paths that have been truncated with
78+
// any string. These tend to contain homedirs with usernames, not good.
79+
$out = preg_replace("/'\\/.*\.\\.\\.'/", "'%s'", $out);
80+
$out = preg_replace("/'file:\/\\/.*\.\\.\\.'/", "'%s'", $out);
7781
$out = str_replace("\0", '%0', $out);
7882
return $out;
7983
}

0 commit comments

Comments
 (0)