[php-src] master: Change bless to clean up absolute paths (#22067)
Calvin Buckley via GitHub <[email protected]>
| Newsgroups | gmane.comp.php.cvs.general |
|---|---|
| Message-ID | <[email protected]> |
Author: Calvin Buckley (NattyNarwhal)
Committer: GitHub (web-flow)
Pusher: NattyNarwhal
Date: 2026-07-07T15:35:43-03:00
Commit: https://github.com/php/php-src/commit/9390b68d5d68c03bbfddf5ae7b48a28751b1b62b
Raw diff: https://github.com/php/php-src/commit/9390b68d5d68c03bbfddf5ae7b48a28751b1b62b.diff
Change bless to clean up absolute paths (#22067)
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.
Changed paths:
M scripts/dev/bless_tests.php
Diff:
diff --git a/scripts/dev/bless_tests.php b/scripts/dev/bless_tests.php
index 7493a504729c..b38935503ae3 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("/'(\/|[A-Z]:\\\\)\S+\\.\\.\\.'/", "'%s'", $out);
+ $out = preg_replace("/'file:(\/|[A-Z]:\\\\)\S+\\.\\.\\.'/", "'%s'", $out);
$out = str_replace("\0", '%0', $out);
return $out;
}