mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
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:
parent
9a2675aa4f
commit
43434fba61
7
Makefile
7
Makefile
@ -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
|
||||
|
@ -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,6 +76,7 @@ class TestRunner extends Controller {
|
||||
}
|
||||
|
||||
function runTests($classList) {
|
||||
if(!Director::is_cli()) {
|
||||
self::$default_reporter->writeHeader();
|
||||
echo '<div class="info">';
|
||||
echo "<h1>Sapphire PHPUnit Test Runner</h1>";
|
||||
@ -82,9 +84,13 @@ class TestRunner extends Controller {
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user