Enabled cli running of tests with appropriate errorlevel. Enabled 'make test' for buildbot:

git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/trunk@54639 467b73ca-7a2a-4603-9d3b-597d59a354a9
This commit is contained in:
Sam Minnee 2008-05-15 08:46:40 +00:00
parent 9a2675aa4f
commit 43434fba61
2 changed files with 26 additions and 13 deletions

View File

@ -4,10 +4,13 @@
#
# Most users should simply visit the site root in your web browser.
#
#
URL=`./cli-script.php SapphireInfo/baseurl`
test: windmill
test: phpunit
phpunit:
php5 ./cli-script.php TestRunner
windmill:
functest ../cms/tests/test_windmill url=${URL}admin browser=firefox

View File

@ -53,6 +53,7 @@ class TestRunner extends Controller {
if(hasPhpUnit()) {
$tests = ClassInfo::subclassesFor('SapphireTest');
array_shift($tests);
unset($tests['FunctionalTest']);
$this->runTests($tests);
} else {
@ -75,16 +76,21 @@ class TestRunner extends Controller {
}
function runTests($classList) {
self::$default_reporter->writeHeader();
echo '<div class="info">';
echo "<h1>Sapphire PHPUnit Test Runner</h1>";
echo "<p>Using the following subclasses of SapphireTest for testing: " . implode(", ", $classList) . "</p>";
echo "</div>";
echo '<div class="trace">';
echo "<pre>";
if(!Director::is_cli()) {
self::$default_reporter->writeHeader();
echo '<div class="info">';
echo "<h1>Sapphire PHPUnit Test Runner</h1>";
echo "<p>Using the following subclasses of SapphireTest for testing: " . implode(", ", $classList) . "</p>";
echo "</div>";
echo '<div class="trace">';
echo "<pre>";
} else {
echo "Sapphire PHPUnit Test Runner\n";
echo "Using the following subclasses of SapphireTest for testing: " . implode(", ", $classList) . "\n\n";
}
// Remove our error handler so that PHP can use its own
restore_error_handler();
//restore_error_handler();
$suite = new PHPUnit_Framework_TestSuite();
foreach($classList as $className) {
@ -94,13 +100,17 @@ class TestRunner extends Controller {
}
/*, array("reportDirectory" => "/Users/sminnee/phpunit-report")*/
PHPUnit_TextUI_TestRunner::run($suite);
echo '</div>';
$testResult = PHPUnit_TextUI_TestRunner::run($suite);
if(!Director::is_cli()) echo '</div>';
// Put the error handlers back
Debug::loadErrorHandlers();
self::$default_reporter->writeFooter();
if(!Director::is_cli()) self::$default_reporter->writeFooter();
// Todo: we should figure out how to pass this data back through Director more cleanly
if(Director::is_cli() && $testResult->errorCount() > 0) exit(2);
}
}