diff options
author | Nikita Popov <nikita.ppv@gmail.com> | 2019-02-11 15:36:47 +0100 |
---|---|---|
committer | Nikita Popov <nikita.ppv@gmail.com> | 2019-02-11 15:36:47 +0100 |
commit | 5bd65be8a023f0640f80c47bf902af251f402cd5 (patch) | |
tree | 3efd12f1bed6172e51802dee8d5b71b1fbc1b57e | |
parent | 779b9bfe0278fdff2613c4d472c99dcefabd1312 (diff) | |
parent | 7a17be7f31be344605b244599f37b6f8579ec90b (diff) | |
download | php-git-5bd65be8a023f0640f80c47bf902af251f402cd5.tar.gz |
Merge branch 'PHP-7.4'
-rw-r--r-- | CONTRIBUTING.md | 2 | ||||
-rw-r--r-- | scripts/dev/bless_tests.php | 49 |
2 files changed, 49 insertions, 2 deletions
diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 43a8e525e4..c06ffd0b8e 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -126,8 +126,6 @@ locations. └─ ... └─ mbstring/ ├─ libmbfl/ # Forked and maintained in php-src - ├─ oniguruma/ # Bundled https://github.com/kkos/oniguruma - ├─ oniguruma.patch # Modifications patch from upstream oniguruma ├─ unicode_data.h # Generated by `ext/mbstring/ucgendat/ucgendat.php` └─ ... └─ pcre/ diff --git a/scripts/dev/bless_tests.php b/scripts/dev/bless_tests.php new file mode 100644 index 0000000000..121a011f9a --- /dev/null +++ b/scripts/dev/bless_tests.php @@ -0,0 +1,49 @@ +#!/usr/bin/env php +<?php + +if ($argc < 2) { + die("Usage: php bless_tests.php dir/"); +} + +$dir = $argv[1]; +$it = new RecursiveIteratorIterator( + new RecursiveDirectoryIterator($dir), + RecursiveIteratorIterator::LEAVES_ONLY +); +foreach ($it as $file) { + $path = $file->getPathName(); + if (!preg_match('/^(.*)\.phpt$/', $path, $matches)) { + // Not a phpt test + continue; + } + + $outPath = $matches[1] . '.out'; + if (!file_exists($outPath)) { + // Test did not fail + continue; + } + + $phpt = file_get_contents($path); + if (false !== strpos($phpt, '--XFAIL--')) { + // Don't modify expected output of XFAIL tests + continue; + } + + $out = file_get_contents($outPath); + $out = normalizeOutput($out); + $phpt = insertOutput($phpt, $out); + file_put_contents($path, $phpt); +} + +function normalizeOutput(string $out): string { + $out = preg_replace('/in \/.+ on line \d+/', 'in %s on line %d', $out); + $out = preg_replace('/Resource id #\d+/', 'Resource id #%d', $out); + return $out; +} + +function insertOutput(string $phpt, string $out): string { + return preg_replace_callback('/--EXPECTF?--.*$/s', function($matches) use($out) { + $F = strpos($out, '%') !== false ? 'F' : ''; + return "--EXPECT$F--\n" . $out . "\n"; + }, $phpt); +} |