summaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
authorNikita Popov <nikita.ppv@gmail.com>2020-09-08 12:16:31 +0200
committerNikita Popov <nikita.ppv@gmail.com>2020-09-08 14:22:20 +0200
commitababa221369568addd8af3c96097a78dda80db9b (patch)
tree96fbc33477475aa15d59fe685e4fd7a3f3215b64 /scripts
parent5a201ddad0cf655e1d07e720200ae425166d0a6d (diff)
downloadphp-git-ababa221369568addd8af3c96097a78dda80db9b.tar.gz
Support more placeholders in bless_tests.php
And don't replace trailing --CLEAN-- sections.
Diffstat (limited to 'scripts')
-rwxr-xr-xscripts/dev/bless_tests.php13
1 files changed, 10 insertions, 3 deletions
diff --git a/scripts/dev/bless_tests.php b/scripts/dev/bless_tests.php
index 49160d0cc9..674bbeda8e 100755
--- a/scripts/dev/bless_tests.php
+++ b/scripts/dev/bless_tests.php
@@ -77,8 +77,15 @@ function normalizeOutput(string $out): string {
function formatToRegex(string $format): string {
$result = preg_quote($format, '/');
- $result = str_replace('%d', '\d+', $result);
+ $result = str_replace('%e', '\\' . DIRECTORY_SEPARATOR, $result);
$result = str_replace('%s', '[^\r\n]+', $result);
+ $result = str_replace('%S', '[^\r\n]*', $result);
+ $result = str_replace('%w', '\s*', $result);
+ $result = str_replace('%i', '[+-]?\d+', $result);
+ $result = str_replace('%d', '\d+', $result);
+ $result = str_replace('%x', '[0-9a-fA-F]+', $result);
+ $result = str_replace('%f', '[+-]?\.?\d+\.?\d*(?:[Ee][+-]?\d+)?', $result);
+ $result = str_replace('%c', '.', $result);
return "/^$result$/s";
}
@@ -105,10 +112,10 @@ function generateMinimallyDifferingOutput(string $out, string $oldExpect) {
}
function insertOutput(string $phpt, string $out): string {
- return preg_replace_callback('/--EXPECTF?--.*$/s', function($matches) use($out) {
+ return preg_replace_callback('/--EXPECTF?--.*?(--CLEAN--|$)/sD', function($matches) use($out) {
$hasWildcard = preg_match('/%[resSaAwidxfc]/', $out);
$F = $hasWildcard ? 'F' : '';
- return "--EXPECT$F--\n" . $out . "\n";
+ return "--EXPECT$F--\n" . $out . "\n" . $matches[1];
}, $phpt);
}