mirror of
https://github.com/danog/PHP-Parser.git
synced 2024-11-30 04:19:30 +01:00
Add progress indicator for test_old.
I hate waiting for something without seeing at least *some* output.
This commit is contained in:
parent
101a6ddcfc
commit
5438cc0d69
@ -7,14 +7,51 @@ if ('cli' !== php_sapi_name()) {
|
||||
die('This script is designed for running on the command line.');
|
||||
}
|
||||
|
||||
if (3 !== $argc) {
|
||||
die('This script expects exactly two arguments:
|
||||
1. The test type (either "Symfony" or "PHP")
|
||||
2. The path to the test files');
|
||||
function showHelp($error) {
|
||||
die($error . "\n\n" .
|
||||
<<<OUTPUT
|
||||
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 following options are available:
|
||||
|
||||
--no-progress Disables showing which file is currently tested.
|
||||
OUTPUT
|
||||
);
|
||||
}
|
||||
|
||||
$TEST_TYPE = $argv[1];
|
||||
$DIR = $argv[2];
|
||||
$options = array();
|
||||
$arguments = array();
|
||||
|
||||
// remove script name from argv
|
||||
array_shift($argv);
|
||||
|
||||
foreach ($argv as $arg) {
|
||||
if ('-' === $arg[0]) {
|
||||
$options[] = $arg;
|
||||
} else {
|
||||
$arguments[] = $arg;
|
||||
}
|
||||
}
|
||||
|
||||
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;
|
||||
} else {
|
||||
showHelp('Invalid option passed!');
|
||||
}
|
||||
}
|
||||
|
||||
$TEST_TYPE = $arguments[0];
|
||||
$DIR = $arguments[1];
|
||||
|
||||
if ('Symfony' === $TEST_TYPE) {
|
||||
function filter_func($path) {
|
||||
@ -25,7 +62,7 @@ if ('Symfony' === $TEST_TYPE) {
|
||||
return preg_match('~\.phpt$~', $path);
|
||||
};
|
||||
} else {
|
||||
die('The test type must be either "Symfony" or "PHP".');
|
||||
showHelp('Test type must be either "Symfony" or "PHP"!');
|
||||
}
|
||||
|
||||
require_once dirname(__FILE__) . '/../lib/PHPParser/Autoloader.php';
|
||||
@ -35,7 +72,7 @@ $parser = new PHPParser_Parser(new PHPParser_Lexer_Emulative);
|
||||
$prettyPrinter = new PHPParser_PrettyPrinter_Zend;
|
||||
$nodeDumper = new PHPParser_NodeDumper;
|
||||
|
||||
$parseFail = $ppFail = $compareFail = $count = 0;;
|
||||
$parseFail = $ppFail = $compareFail = $count = 0;
|
||||
|
||||
$readTime = $parseTime = $ppTime = $reparseTime = $compareTime = 0;
|
||||
$totalStartTime = microtime(true);
|
||||
@ -85,6 +122,10 @@ foreach (new RecursiveIteratorIterator(
|
||||
|
||||
++$count;
|
||||
|
||||
if ($SHOW_PROGRESS) {
|
||||
echo substr(str_pad('Testing file ' . $count . ': ' . substr($file, strlen($DIR)), 79), 0, 79), "\r";
|
||||
}
|
||||
|
||||
try {
|
||||
$startTime = microtime(true);
|
||||
$stmts = $parser->parse($code);
|
||||
@ -121,9 +162,9 @@ foreach (new RecursiveIteratorIterator(
|
||||
}
|
||||
|
||||
if (0 === $parseFail && 0 === $ppFail && 0 === $compareFail) {
|
||||
echo 'All tests passed.', "\n";
|
||||
echo "\n\n", 'All tests passed.', "\n";
|
||||
} else {
|
||||
echo "\n", '==========', "\n\n", 'There were: ', "\n";
|
||||
echo "\n\n", '==========', "\n\n", 'There were: ', "\n";
|
||||
if (0 !== $parseFail) {
|
||||
echo ' ', $parseFail, ' parse failures.', "\n";
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user