Skip to content

Commit 0a66d82

Browse files
committed
Merge branch 'PHP-7.4'
2 parents 0e34217 + e53e753 commit 0a66d82

File tree

2 files changed

+30
-18
lines changed

2 files changed

+30
-18
lines changed

run-tests.php

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -160,10 +160,6 @@ function main()
160160
$environment["SystemRoot"] = getenv("SystemRoot");
161161
}
162162

163-
// Don't ever guess at the PHP executable location.
164-
// Require the explicit specification.
165-
// Otherwise we could end up testing the wrong file!
166-
167163
$php = null;
168164
$php_cgi = null;
169165
$phpdbg = null;
@@ -461,11 +457,7 @@ function main()
461457
$environment['TEST_PHP_EXECUTABLE'] = $php;
462458
break;
463459
case 'P':
464-
if (constant('PHP_BINARY')) {
465-
$php = PHP_BINARY;
466-
} else {
467-
break;
468-
}
460+
$php = PHP_BINARY;
469461
putenv("TEST_PHP_EXECUTABLE=$php");
470462
$environment['TEST_PHP_EXECUTABLE'] = $php;
471463
break;
@@ -567,7 +559,7 @@ function main()
567559
568560
-p <php> Specify PHP executable to run.
569561
570-
-P Use PHP_BINARY as PHP executable to run.
562+
-P Use PHP_BINARY as PHP executable to run (default).
571563
572564
-q Quiet, no user interaction (same as environment NO_INTERACTION).
573565
@@ -652,6 +644,13 @@ function main()
652644
}
653645
}
654646

647+
// Default to PHP_BINARY as executable
648+
if (!isset($environment['TEST_PHP_EXECUTABLE'])) {
649+
$php = PHP_BINARY;
650+
putenv("TEST_PHP_EXECUTABLE=$php");
651+
$environment['TEST_PHP_EXECUTABLE'] = $php;
652+
}
653+
655654
if (strlen($conf_passed)) {
656655
if (substr(PHP_OS, 0, 3) == "WIN") {
657656
$pass_options .= " -c " . escapeshellarg($conf_passed);

scripts/dev/bless_tests.php

100644100755
Lines changed: 21 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,11 @@
22
<?php
33

44
if ($argc < 2) {
5-
die("Usage: php bless_tests.php dir/");
5+
die("Usage: php bless_tests.php dir/\n");
66
}
77

8-
$dir = $argv[1];
9-
$it = new RecursiveIteratorIterator(
10-
new RecursiveDirectoryIterator($dir),
11-
RecursiveIteratorIterator::LEAVES_ONLY
12-
);
13-
foreach ($it as $file) {
14-
$path = $file->getPathName();
8+
$files = getFiles(array_slice($argv, 1));
9+
foreach ($files as $path) {
1510
if (!preg_match('/^(.*)\.phpt$/', $path, $matches)) {
1611
// Not a phpt test
1712
continue;
@@ -35,6 +30,24 @@
3530
file_put_contents($path, $phpt);
3631
}
3732

33+
function getFiles(array $dirsOrFiles): \Iterator {
34+
foreach ($dirsOrFiles as $dirOrFile) {
35+
if (is_dir($dirOrFile)) {
36+
$it = new RecursiveIteratorIterator(
37+
new RecursiveDirectoryIterator($dirOrFile),
38+
RecursiveIteratorIterator::LEAVES_ONLY
39+
);
40+
foreach ($it as $file) {
41+
yield $file->getPathName();
42+
}
43+
} else if (is_file($dirOrFile)) {
44+
yield $dirOrFile;
45+
} else {
46+
die("$dirOrFile is not a directory or file\n");
47+
}
48+
}
49+
}
50+
3851
function normalizeOutput(string $out): string {
3952
$out = preg_replace('/in \/.+ on line \d+$/m', 'in %s on line %d', $out);
4053
$out = preg_replace('/in \/.+:\d+$/m', 'in %s:%d', $out);

0 commit comments

Comments
 (0)