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.
|
# Most users should simply visit the site root in your web browser.
|
||||||
#
|
#
|
||||||
|
#
|
||||||
URL=`./cli-script.php SapphireInfo/baseurl`
|
URL=`./cli-script.php SapphireInfo/baseurl`
|
||||||
|
|
||||||
test: windmill
|
test: phpunit
|
||||||
|
|
||||||
|
phpunit:
|
||||||
|
php5 ./cli-script.php TestRunner
|
||||||
|
|
||||||
windmill:
|
windmill:
|
||||||
functest ../cms/tests/test_windmill url=${URL}admin browser=firefox
|
functest ../cms/tests/test_windmill url=${URL}admin browser=firefox
|
||||||
|
@ -53,6 +53,7 @@ class TestRunner extends Controller {
|
|||||||
if(hasPhpUnit()) {
|
if(hasPhpUnit()) {
|
||||||
$tests = ClassInfo::subclassesFor('SapphireTest');
|
$tests = ClassInfo::subclassesFor('SapphireTest');
|
||||||
array_shift($tests);
|
array_shift($tests);
|
||||||
|
unset($tests['FunctionalTest']);
|
||||||
|
|
||||||
$this->runTests($tests);
|
$this->runTests($tests);
|
||||||
} else {
|
} else {
|
||||||
@ -75,6 +76,7 @@ class TestRunner extends Controller {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function runTests($classList) {
|
function runTests($classList) {
|
||||||
|
if(!Director::is_cli()) {
|
||||||
self::$default_reporter->writeHeader();
|
self::$default_reporter->writeHeader();
|
||||||
echo '<div class="info">';
|
echo '<div class="info">';
|
||||||
echo "<h1>Sapphire PHPUnit Test Runner</h1>";
|
echo "<h1>Sapphire PHPUnit Test Runner</h1>";
|
||||||
@ -82,9 +84,13 @@ class TestRunner extends Controller {
|
|||||||
echo "</div>";
|
echo "</div>";
|
||||||
echo '<div class="trace">';
|
echo '<div class="trace">';
|
||||||
echo "<pre>";
|
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
|
// Remove our error handler so that PHP can use its own
|
||||||
restore_error_handler();
|
//restore_error_handler();
|
||||||
|
|
||||||
$suite = new PHPUnit_Framework_TestSuite();
|
$suite = new PHPUnit_Framework_TestSuite();
|
||||||
foreach($classList as $className) {
|
foreach($classList as $className) {
|
||||||
@ -94,13 +100,17 @@ class TestRunner extends Controller {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/*, array("reportDirectory" => "/Users/sminnee/phpunit-report")*/
|
/*, array("reportDirectory" => "/Users/sminnee/phpunit-report")*/
|
||||||
PHPUnit_TextUI_TestRunner::run($suite);
|
$testResult = PHPUnit_TextUI_TestRunner::run($suite);
|
||||||
echo '</div>';
|
|
||||||
|
if(!Director::is_cli()) echo '</div>';
|
||||||
|
|
||||||
// Put the error handlers back
|
// Put the error handlers back
|
||||||
Debug::loadErrorHandlers();
|
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