cvs: pear /PHPUnit/TextUI TestRunner.php
| From: | Sebastian Bergmann | Date: | Sun, 04 Jan 2004 16:44:09 +0000 |
| Subject: | cvs: pear /PHPUnit/TextUI TestRunner.php | ||
| Groups: | php.pear.cvs | ||
| Request: | Send a blank email to pear-cvs+get-15348@lists.php.net to get a copy of this message | ||
sebastian Sun Jan 4 11:44:09 2004 EDT
Modified files:
/pear/PHPUnit/TextUI TestRunner.php
Log:
Flush.
Index: pear/PHPUnit/TextUI/TestRunner.php
diff -u pear/PHPUnit/TextUI/TestRunner.php:1.8 pear/PHPUnit/TextUI/TestRunner.php:1.9
--- pear/PHPUnit/TextUI/TestRunner.php:1.8 Sun Jan 4 06:28:27 2004
+++ pear/PHPUnit/TextUI/TestRunner.php Sun Jan 4 11:44:09 2004
@@ -12,7 +12,7 @@
// | license@php.net so we can mail you a copy immediately. |
// +------------------------------------------------------------------------+
//
-// $Id: TestRunner.php,v 1.8 2004/01/04 11:28:27 sebastian Exp $
+// $Id: TestRunner.php,v 1.9 2004/01/04 16:44:09 sebastian Exp $
//
if (!defined('PHPUnit_MAIN_METHOD')) {
@@ -21,6 +21,7 @@
require_once 'Benchmark/Timer.php';
require_once 'Console/Getopt.php';
+require_once 'PHPUnit/Extensions/Logger/XML.php';
require_once 'PHPUnit/Framework/Test.php';
require_once 'PHPUnit/Framework/TestResult.php';
require_once 'PHPUnit/Runner/BaseTestRunner.php';
@@ -88,33 +89,67 @@
// {{{ protected function start($arguments)
protected function start($arguments) {
- $this->printer->write(
- sprintf(
- "PHPUnit %s by Sebastian Bergmann.\n\n",
-
- PHPUnit_Runner_Version::id()
- )
- );
-
- $testCase = '';
- $wait = false;
+ $txtLogfile = false;
+ $xmlLogfile = false;
+ $wait = false;
$options = Console_Getopt::getopt(
$_SERVER['argv'],
'',
- array('wait')
+ array(
+ 'help',
+ 'log=',
+ 'version',
+ 'wait',
+ 'xml='
+ )
);
- if (PEAR::isError($options)) {
- die('XXX: IMPLEMENT ERROR HANDLING');
+ $test = isset($options[1][0]) ? $options[1][0] : false;
+
+ foreach ($options[0] as $option) {
+ switch ($option[0]) {
+ case '--help': {
+ print "NOT YET IMPLEMENTED\n";
+ exit(SUCCESS_EXIT);
+ }
+ break;
+
+ case '--log': {
+ $txtLogfile = $option[1];
+ }
+ break;
+
+ case '--version': {
+ $this->printer->write(
+ PHPUnit_Runner_Version::getVersionString()
+ );
+
+ exit(SUCCESS_EXIT);
+ }
+ break;
+
+ case '--wait': {
+ $wait = true;
+ }
+ break;
+
+ case '--xml': {
+ $xmlLogfile = $option[1];
+ }
+ break;
+ }
}
- $test = isset($options[1][0]) ? $options[1][0] : false;
- $wait = isset($options[0][0][0]) ? true : false;
+ $this->printer->write(
+ PHPUnit_Runner_Version::getVersionString() . "\n\n"
+ );
try {
return $this->doRun(
$this->getTest($test),
+ $txtLogfile,
+ $xmlLogfile,
$wait
);
}
@@ -164,13 +199,22 @@
}
// }}}
- // {{{ public function doRun(PHPUnit_Framework_Test $suite, $wait = false)
+ // {{{ public function doRun(PHPUnit_Framework_Test $suite, $txtLogfile = false, $xmlLogfile =
false, $wait = false)
- public function doRun(PHPUnit_Framework_Test $suite, $wait = false) {
+ public function doRun(PHPUnit_Framework_Test $suite, $txtLogfile = false, $xmlLogfile = false,
$wait = false) {
$result = $this->createTestResult();
+ $timer = new Benchmark_Timer;
$result->addListener($this->printer);
- $timer = new Benchmark_Timer;
+
+ if ($txtLogfile) {
+ // XXX: NOT YET IMPLEMENTED
+ }
+
+ if ($xmlLogfile &&
+ $xmlLogfileFP = fopen($xmlLogfile, 'w')) {
+ $result->addListener(new PHPUnit_Extensions_Logger_XML($xmlLogfileFP));
+ }
$timer->start();
$suite->run($result);