|
1 | 1 | <?php
|
2 | 2 |
|
3 | 3 | if ($argc >= 2) {
|
4 |
| - $testsDir = $argv[1]; |
5 |
| -} else { |
6 |
| - $testsDir = __DIR__ . '/../../Zend/tests'; |
7 |
| -} |
8 |
| -if ($argc >= 3) { |
9 |
| - $corpusDir = $argv[2]; |
| 4 | + $corpusDir = $argv[1]; |
10 | 5 | } else {
|
11 | 6 | $corpusDir = __DIR__ . '/corpus/execute';
|
12 | 7 | }
|
13 |
| -if ($argc >= 4) { |
14 |
| - $maxLen = (int) $argv[3]; |
| 8 | +if ($argc >= 3) { |
| 9 | + $testDirs = array_slice($argv, 2); |
15 | 10 | } else {
|
16 |
| - $maxLen = 8 * 1024; |
| 11 | + $baseDir = __DIR__ . '/../..'; |
| 12 | + $testDirs = ["$baseDir/Zend/tests", "$baseDir/ext/reflection"]; |
17 | 13 | }
|
18 | 14 |
|
19 |
| -$it = new RecursiveIteratorIterator( |
20 |
| - new RecursiveDirectoryIterator($testsDir), |
21 |
| - RecursiveIteratorIterator::LEAVES_ONLY |
22 |
| -); |
23 |
| - |
| 15 | +$maxLen = 8 * 1024; |
24 | 16 | @mkdir($corpusDir);
|
25 | 17 |
|
26 |
| -foreach ($it as $file) { |
27 |
| - if (!preg_match('/\.phpt$/', $file)) continue; |
28 |
| - $fullCode = file_get_contents($file); |
29 |
| - if (!preg_match('/--FILE--\R(.*?)\R--([_A-Z]+)--/s', $fullCode, $matches)) continue; |
30 |
| - $code = $matches[1]; |
31 |
| - if (strlen($code) > $maxLen) continue; |
| 18 | +foreach ($testDirs as $testDir) { |
| 19 | + $it = new RecursiveIteratorIterator( |
| 20 | + new RecursiveDirectoryIterator($testDir), |
| 21 | + RecursiveIteratorIterator::LEAVES_ONLY |
| 22 | + ); |
| 23 | + |
| 24 | + foreach ($it as $file) { |
| 25 | + if (!preg_match('/\.phpt$/', $file)) continue; |
| 26 | + $fullCode = file_get_contents($file); |
| 27 | + if (!preg_match('/--FILE--\R(.*?)\R--([_A-Z]+)--/s', $fullCode, $matches)) continue; |
| 28 | + $code = $matches[1]; |
| 29 | + if (strlen($code) > $maxLen) continue; |
32 | 30 |
|
33 |
| - $outFile = str_replace($testsDir, '', $file); |
34 |
| - $outFile = str_replace('/', '_', $outFile); |
35 |
| - if (!preg_match('/SKIP_SLOW_TESTS|SKIP_PERF_SENSITIVE|USE_ZEND_ALLOC/', $fullCode)) { |
36 |
| - file_put_contents($corpusDir . '/' . $outFile, $code); |
| 31 | + $outFile = str_replace($testDir, '', $file); |
| 32 | + $outFile = str_replace('/', '_', $outFile); |
| 33 | + if (!preg_match('/SKIP_SLOW_TESTS|SKIP_PERF_SENSITIVE|USE_ZEND_ALLOC/', $fullCode)) { |
| 34 | + file_put_contents($corpusDir . '/' . $outFile, $code); |
| 35 | + } |
37 | 36 | }
|
38 | 37 | }
|
0 commit comments