diff options
author | Josh Hoyt <josh@janrain.com> | 2006-01-07 20:01:04 +0000 |
---|---|---|
committer | Josh Hoyt <josh@janrain.com> | 2006-01-07 20:01:04 +0000 |
commit | bb49a3970af9923b624f55ea47a2cf2ccf158c39 (patch) | |
tree | b2a34e96c42f52d70419d5c0ada7ff8ce2c1a89f /admin | |
parent | 3bd85d7c5046bdc47adb8cb5a19124b04595821e (diff) | |
download | php-openid-bb49a3970af9923b624f55ea47a2cf2ccf158c39.zip php-openid-bb49a3970af9923b624f55ea47a2cf2ccf158c39.tar.gz php-openid-bb49a3970af9923b624f55ea47a2cf2ccf158c39.tar.bz2 |
[project @ Change runtests to always run in the correct directory and move texttest.php into that directory]
Diffstat (limited to 'admin')
-rw-r--r-- | admin/runtests | 20 | ||||
-rw-r--r-- | admin/texttest.php | 111 |
2 files changed, 124 insertions, 7 deletions
diff --git a/admin/runtests b/admin/runtests index 72ef639..a874761 100644 --- a/admin/runtests +++ b/admin/runtests @@ -1,36 +1,42 @@ #!/usr/bin/env bash +HERE=$(readlink --canonicalize $(dirname "$0")) + test_tabs () { - /usr/bin/env bash $(dirname "$0")/notabs + /usr/bin/env bash "$HERE/notabs" } test_longlines () { - /usr/bin/env bash $(dirname "$0")/nolonglines + /usr/bin/env bash "$HERE/nolonglines" } test_nobadbraces () { - /usr/bin/env bash $(dirname "$0")/nobadbraces + /usr/bin/env bash "$HERE/nobadbraces" } test_nobadcase () { - /usr/bin/env bash $(dirname "$0")/nobadcase + /usr/bin/env bash "$HERE/nobadcase" } test_opentag () { - /usr/bin/env bash $(dirname "$0")/open_tag + /usr/bin/env bash "$HERE/open_tag" } test_docblocks () { - /usr/bin/env bash $(dirname "$0")/docblocks + /usr/bin/env bash "$HERE/docblocks" } test_php () { - /usr/bin/env php texttest.php + /usr/bin/env php "$HERE/texttest.php" } tests="tabs longlines nobadbraces nobadcase opentag docblocks php" failures= + +# Run in repository root (parent of this directory) +cd $(dirname "$HERE") + for test_name in $tests do echo "Running test $test_name" 1>&2 diff --git a/admin/texttest.php b/admin/texttest.php new file mode 100644 index 0000000..8575500 --- /dev/null +++ b/admin/texttest.php @@ -0,0 +1,111 @@ +<?php + +require_once('Tests/TestDriver.php'); +require_once('PHPUnit/TestResult.php'); + +class TextTestResult extends PHPUnit_TestResult { + function addError(&$test, &$t) + { + parent::addError($test, $t); + echo "E"; + } + + function addFailure(&$test, &$t) + { + parent::addFailure($test, $t); + echo "F"; + } + + function addPassedTest(&$test) + { + parent::addPassedTest($test); + echo "."; + } + + function dumpBadResults() + { + foreach ($this->failures() as $failure) { + echo $failure->toString(); + } + + foreach ($this->errors() as $failure) { + echo $failure->toString(); + } + } +} + +function microtime_float() +{ + list($usec, $sec) = explode(" ", microtime()); + return ((float)$usec + (float)$sec); +} + +// Drop $argv[0] (command name) +array_shift($argv); + +$t = array_search('--thorough', $argv); +if ($t !== false && $t !== null) { + define('Tests_Net_OpenID_thorough', true); +} + +$suites = loadSuite($argv); + +$totals = array( + 'run' => 0, + 'error' => 0, + 'failure' => 0, + 'time' => 0 + ); + +foreach ($suites as $suite) { + $name = $suite->getName(); + echo "========================================== +Test suite: $name +------------------------------------------ +"; + + $result = new TextTestResult(); + $before = microtime_float(); + $suite->run($result); + $after = microtime_float(); + + $run = $result->runCount(); + $error = $result->errorCount(); + $failure = $result->failureCount(); + $delta = $after - $before; + $totals['run'] += $run; + $totals['error'] += $error; + $totals['failure'] += $failure; + $totals['time'] += $delta; + $human_delta = round($delta, 3); + echo "\nRan $run tests in $human_delta seconds"; + if ($error || $failure) { + echo " with $error errors, $failure failures"; + } + echo " +========================================== + +"; + + $failures = $result->failures(); + foreach($failures as $failure) { + $test = $failure->failedTest(); + $testName = $test->getName(); + $exception = $failure->thrownException(); + echo "* Failure in $testName: $exception + +"; + } +} + +$before = microtime_float(); +$run = $totals['run']; +$error = $totals['error']; +$failure = $totals['failure']; +$time = round($totals['time'], 3); +echo "Ran a total of $run tests in $time seconds with $error errors, $failure failures\n"; +if ($totals['error'] || $totals['failure']) { + exit(1); +} + +?>
\ No newline at end of file |