Skip to content

Change bless to clean up absolute paths#22067

Open
NattyNarwhal wants to merge 1 commit into
php:masterfrom
NattyNarwhal:bless-absolute-paths
Open

Change bless to clean up absolute paths#22067
NattyNarwhal wants to merge 1 commit into
php:masterfrom
NattyNarwhal:bless-absolute-paths

Conversation

@NattyNarwhal
Copy link
Copy Markdown
Member

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.

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 phpGH-12276. While the approved
RFC doesn't enable function parameters to be printed for tests, the
functionality is generally useful.
$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);
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this regex should be aligned with the one for the error messages: (\/|[A-Z]:\\\\)\S+ (i.e. support for Windows and no whitespace).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants