Skip to content

Commit b4ee5df

Browse files
committed
Support %e, %f, %i in bless_tests.php
And don't replace trailing --CLEAN-- sections.
1 parent 259af93 commit b4ee5df

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

scripts/dev/bless_tests.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,10 @@ function normalizeOutput(string $out): string {
7878
function formatToRegex(string $format): string {
7979
$result = preg_quote($format, '/');
8080
$result = str_replace('%d', '\d+', $result);
81+
$result = str_replace('%i', '[+-]?\d+', $result);
8182
$result = str_replace('%s', '[^\r\n]+', $result);
83+
$result = str_replace('%e', '\\' . DIRECTORY_SEPARATOR, $result);
84+
$result = str_replace('%f', '[+-]?\.?\d+\.?\d*(?:[Ee][+-]?\d+)?', $result);
8285
return "/^$result$/s";
8386
}
8487

@@ -105,10 +108,10 @@ function generateMinimallyDifferingOutput(string $out, string $oldExpect) {
105108
}
106109

107110
function insertOutput(string $phpt, string $out): string {
108-
return preg_replace_callback('/--EXPECTF?--.*$/s', function($matches) use($out) {
111+
return preg_replace_callback('/--EXPECTF?--.*?(--CLEAN--|$)/sD', function($matches) use($out) {
109112
$hasWildcard = preg_match('/%[resSaAwidxfc]/', $out);
110113
$F = $hasWildcard ? 'F' : '';
111-
return "--EXPECT$F--\n" . $out . "\n";
114+
return "--EXPECT$F--\n" . $out . "\n" . $matches[1];
112115
}, $phpt);
113116
}
114117

0 commit comments

Comments
 (0)