Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Add progress indicator for test_old.

I hate waiting for something without seeing at least *some* output.
  • Loading branch information...
commit 5438cc0d69c7e40b900393ed3a434d002352e96e 1 parent 101a6dd
@nikic authored
Showing with 51 additions and 10 deletions.
  1. +51 −10 test_old/run.php
View
61 test_old/run.php
@@ -7,14 +7,51 @@
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
+ );
+}
+
+$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 = $argv[1];
-$DIR = $argv[2];
+$TEST_TYPE = $arguments[0];
+$DIR = $arguments[1];
if ('Symfony' === $TEST_TYPE) {
function filter_func($path) {
@@ -25,7 +62,7 @@ function filter_func($path) {
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 @@ function filter_func($path) {
$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 @@ function filter_func($path) {
++$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 @@ function filter_func($path) {
}
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";
}
Please sign in to comment.
Something went wrong with that request. Please try again.