Skip to content
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions scripts/dev/bless_tests.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,20 @@
die("Usage: php bless_tests.php dir/\n");
}

// Build a list of known errors on this platform, so we can avoid hardcoding
// platform-specific errors in expect output, as the errno/strerror differs
// between platforms.
$strerrors = [];
if (function_exists("posix_strerror")) {
for ($i = -1; $i < 255; $i++) {
$str = posix_strerror($i);
if (str_contains($str, "Unknown error") && $i > 0 && strlen($str) > 0) {
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.

Suggested change
if (str_contains($str, "Unknown error") && $i > 0 && strlen($str) > 0) {
if (str_contains($str, "Unknown error") && $i > 0) {

if $str contains "Unknown error" then it by definition will be longer than an empty string, we shouldn't need this check?

break;
}
$strerrors[] = $str;
}
}

$files = getFiles(array_slice($argv, 1));
foreach ($files as $path) {
if (!preg_match('/^(.*)\.phpt$/', $path, $matches)) {
Expand Down Expand Up @@ -74,6 +88,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);
global $strerrors;
foreach ($strerrors as $strerror) {
$out = str_replace($strerror, "%s", $out);
}
$out = str_replace("\0", '%0', $out);
return $out;
}
Expand Down
Loading