update v 1.0.7.5
This commit is contained in:
148
vendor/nikic/php-parser/test_old/run.php
vendored
148
vendor/nikic/php-parser/test_old/run.php
vendored
@@ -14,11 +14,12 @@ This script has to be called with the following signature:
|
||||
|
||||
php run.php [--no-progress] testType pathToTestFiles
|
||||
|
||||
The test type can be either "Symfony" or "PHP".
|
||||
The test type must be one of: PHP5, PHP7 or Symfony.
|
||||
|
||||
The following options are available:
|
||||
|
||||
--no-progress Disables showing which file is currently tested.
|
||||
|
||||
OUTPUT
|
||||
);
|
||||
}
|
||||
@@ -41,56 +42,39 @@ if (count($arguments) !== 2) {
|
||||
showHelp('Too little arguments passed!');
|
||||
}
|
||||
|
||||
$SHOW_PROGRESS = true;
|
||||
if (count($options) > 0) {
|
||||
if (count($options) === 1 && $options[0] === '--no-progress') {
|
||||
$SHOW_PROGRESS = false;
|
||||
$showProgress = true;
|
||||
$verbose = false;
|
||||
foreach ($options as $option) {
|
||||
if ($option === '--no-progress') {
|
||||
$showProgress = false;
|
||||
} elseif ($option === '--verbose') {
|
||||
$verbose = true;
|
||||
} else {
|
||||
showHelp('Invalid option passed!');
|
||||
}
|
||||
}
|
||||
|
||||
$TEST_TYPE = $arguments[0];
|
||||
$DIR = $arguments[1];
|
||||
$testType = $arguments[0];
|
||||
$dir = $arguments[1];
|
||||
|
||||
if ('Symfony' === $TEST_TYPE) {
|
||||
function filter_func($path) {
|
||||
return preg_match('~\.php(?:\.cache)?$~', $path) && false === strpos($path, 'skeleton');
|
||||
};
|
||||
} elseif ('PHP' === $TEST_TYPE) {
|
||||
function filter_func($path) {
|
||||
return preg_match('~\.phpt$~', $path);
|
||||
};
|
||||
} else {
|
||||
showHelp('Test type must be either "Symfony" or "PHP"!');
|
||||
}
|
||||
|
||||
require_once dirname(__FILE__) . '/../lib/PhpParser/Autoloader.php';
|
||||
PhpParser\Autoloader::register();
|
||||
|
||||
$parser = new PhpParser\Parser(new PhpParser\Lexer\Emulative);
|
||||
$prettyPrinter = new PhpParser\PrettyPrinter\Standard;
|
||||
$nodeDumper = new PhpParser\NodeDumper;
|
||||
|
||||
$parseFail = $ppFail = $compareFail = $count = 0;
|
||||
|
||||
$readTime = $parseTime = $ppTime = $reparseTime = $compareTime = 0;
|
||||
$totalStartTime = microtime(true);
|
||||
|
||||
foreach (new RecursiveIteratorIterator(
|
||||
new RecursiveDirectoryIterator($DIR),
|
||||
RecursiveIteratorIterator::LEAVES_ONLY)
|
||||
as $file) {
|
||||
if (!filter_func($file)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$startTime = microtime(true);
|
||||
$code = file_get_contents($file);
|
||||
$readTime += microtime(true) - $startTime;
|
||||
|
||||
if ('PHP' === $TEST_TYPE) {
|
||||
if (preg_match('~(?:
|
||||
switch ($testType) {
|
||||
case 'Symfony':
|
||||
$version = 'Php5';
|
||||
$fileFilter = function($path) {
|
||||
return preg_match('~\.php(?:\.cache)?$~', $path) && false === strpos($path, 'skeleton');
|
||||
};
|
||||
$codeExtractor = function($file, $code) {
|
||||
return $code;
|
||||
};
|
||||
break;
|
||||
case 'PHP5':
|
||||
case 'PHP7':
|
||||
$version = $testType === 'PHP5' ? 'Php5' : 'Php7';
|
||||
$fileFilter = function($path) {
|
||||
return preg_match('~\.phpt$~', $path);
|
||||
};
|
||||
$codeExtractor = function($file, $code) {
|
||||
if (preg_match('~(?:
|
||||
# skeleton files
|
||||
ext.gmp.tests.001
|
||||
| ext.skeleton.tests.001
|
||||
@@ -104,26 +88,66 @@ foreach (new RecursiveIteratorIterator(
|
||||
# pretty print difference due to INF vs 1e1000
|
||||
| ext.standard.tests.general_functions.bug27678
|
||||
| tests.lang.bug24640
|
||||
# pretty print difference due to nop statements
|
||||
| ext.mbstring.tests.htmlent
|
||||
| ext.standard.tests.file.fread_basic
|
||||
# tests using __halt_compiler as semi reserved keyword
|
||||
| Zend.tests.grammar.semi_reserved_001
|
||||
| Zend.tests.grammar.semi_reserved_002
|
||||
| Zend.tests.grammar.semi_reserved_005
|
||||
)\.phpt$~x', $file)) {
|
||||
continue;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
if (!preg_match('~--FILE--\s*(.*?)--[A-Z]+--~s', $code, $matches)) {
|
||||
continue;
|
||||
}
|
||||
if (preg_match('~--EXPECT(?:F|REGEX)?--\s*(?:Parse|Fatal) error~', $code)) {
|
||||
continue;
|
||||
}
|
||||
if (!preg_match('~--FILE--\s*(.*?)--[A-Z]+--~s', $code, $matches)) {
|
||||
return null;
|
||||
}
|
||||
if (preg_match('~--EXPECT(?:F|REGEX)?--\s*(?:Parse|Fatal) error~', $code)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
$code = $matches[1];
|
||||
return $matches[1];
|
||||
};
|
||||
break;
|
||||
default:
|
||||
showHelp('Test type must be one of: PHP5, PHP7 or Symfony');
|
||||
}
|
||||
|
||||
require_once dirname(__FILE__) . '/../lib/PhpParser/Autoloader.php';
|
||||
PhpParser\Autoloader::register();
|
||||
|
||||
$parserName = 'PhpParser\Parser\\' . $version;
|
||||
$parser = new $parserName(new PhpParser\Lexer\Emulative);
|
||||
$prettyPrinter = new PhpParser\PrettyPrinter\Standard;
|
||||
$nodeDumper = new PhpParser\NodeDumper;
|
||||
|
||||
$parseFail = $ppFail = $compareFail = $count = 0;
|
||||
|
||||
$readTime = $parseTime = $ppTime = $reparseTime = $compareTime = 0;
|
||||
$totalStartTime = microtime(true);
|
||||
|
||||
foreach (new RecursiveIteratorIterator(
|
||||
new RecursiveDirectoryIterator($dir),
|
||||
RecursiveIteratorIterator::LEAVES_ONLY)
|
||||
as $file) {
|
||||
if (!$fileFilter($file)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$startTime = microtime(true);
|
||||
$code = file_get_contents($file);
|
||||
$readTime += microtime(true) - $startTime;
|
||||
|
||||
if (null === $code = $codeExtractor($file, $code)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
set_time_limit(10);
|
||||
|
||||
++$count;
|
||||
|
||||
if ($SHOW_PROGRESS) {
|
||||
echo substr(str_pad('Testing file ' . $count . ': ' . substr($file, strlen($DIR)), 79), 0, 79), "\r";
|
||||
if ($showProgress) {
|
||||
echo substr(str_pad('Testing file ' . $count . ': ' . substr($file, strlen($dir)), 79), 0, 79), "\r";
|
||||
}
|
||||
|
||||
try {
|
||||
@@ -146,11 +170,17 @@ foreach (new RecursiveIteratorIterator(
|
||||
|
||||
if (!$same) {
|
||||
echo $file, ":\n Result of initial parse and parse after pretty print differ\n";
|
||||
if ($verbose) {
|
||||
echo "Pretty printer output:\n=====\n$code\n=====\n\n";
|
||||
}
|
||||
|
||||
++$compareFail;
|
||||
}
|
||||
} catch (PhpParser\Error $e) {
|
||||
echo $file, ":\n Parse of pretty print failed with message: {$e->getMessage()}\n";
|
||||
if ($verbose) {
|
||||
echo "Pretty printer output:\n=====\n$code\n=====\n\n";
|
||||
}
|
||||
|
||||
++$ppFail;
|
||||
}
|
||||
@@ -162,8 +192,10 @@ foreach (new RecursiveIteratorIterator(
|
||||
}
|
||||
|
||||
if (0 === $parseFail && 0 === $ppFail && 0 === $compareFail) {
|
||||
$exit = 0;
|
||||
echo "\n\n", 'All tests passed.', "\n";
|
||||
} else {
|
||||
$exit = 1;
|
||||
echo "\n\n", '==========', "\n\n", 'There were: ', "\n";
|
||||
if (0 !== $parseFail) {
|
||||
echo ' ', $parseFail, ' parse failures.', "\n";
|
||||
@@ -186,4 +218,6 @@ echo "\n",
|
||||
'Comparing took: ', $compareTime, "\n",
|
||||
"\n",
|
||||
'Total time: ', microtime(true) - $totalStartTime, "\n",
|
||||
'Maximum memory usage: ', memory_get_peak_usage(true), "\n";
|
||||
'Maximum memory usage: ', memory_get_peak_usage(true), "\n";
|
||||
|
||||
exit($exit);
|
||||
|
||||
Reference in New Issue
Block a user