Commit 9390b68d5d6 for php.net
commit 9390b68d5d68c03bbfddf5ae7b48a28751b1b62b
Author: Calvin Buckley <calvinb@php.net>
Date: Tue Jul 7 15:35:43 2026 -0300
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.
diff --git a/scripts/dev/bless_tests.php b/scripts/dev/bless_tests.php
index 7493a504729..b38935503ae 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;
}