cvs: pear /PHPUnit2/TextUI TestRunner.php

From: Date: Wed, 07 Jun 2006 07:05:43 +0000
Subject: cvs: pear /PHPUnit2/TextUI TestRunner.php
Groups: php.pear.cvs 
Request: Send a blank email to pear-cvs+get-40549@lists.php.net to get a copy of this message
sebastian Wed Jun 7 07:05:43 2006 UTC Modified files: /pear/PHPUnit2/TextUI TestRunner.php Log: Add --printer={dots|tap} commandline option for the TextUI test runner. http://cvs.php.net/viewcvs.cgi/pear/PHPUnit2/TextUI/TestRunner.php?r1=1.98&r2=1.99&diff_format=u Index: pear/PHPUnit2/TextUI/TestRunner.php diff -u pear/PHPUnit2/TextUI/TestRunner.php:1.98 pear/PHPUnit2/TextUI/TestRunner.php:1.99 --- pear/PHPUnit2/TextUI/TestRunner.php:1.98 Wed May 31 14:38:25 2006 +++ pear/PHPUnit2/TextUI/TestRunner.php Wed Jun 7 07:05:43 2006 @@ -41,7 +41,7 @@ * @author Sebastian Bergmann <sb@sebastian-bergmann.de> * @copyright 2002-2006 Sebastian Bergmann <sb@sebastian-bergmann.de> * @license http://www.opensource.org/licenses/bsd-license.php BSD License - * @version CVS: $Id: TestRunner.php,v 1.98 2006/05/31 14:38:25 sebastian Exp $ + * @version CVS: $Id: TestRunner.php,v 1.99 2006/06/07 07:05:43 sebastian Exp $ * @link http://pear.php.net/package/PHPUnit2 * @since File available since Release 2.0.0 */ @@ -141,6 +141,7 @@ { $syntaxCheck = TRUE; $loaderName = FALSE; + $printer = FALSE; $repeat = FALSE; $reportDirectory = FALSE; $testdoxHTMLFile = FALSE; @@ -158,6 +159,7 @@ 'log-tap=', 'log-xml=', 'no-syntax-check', + 'printer=', 'repeat=', 'report=', 'skeleton', @@ -224,6 +226,22 @@ } break; + case '--printer': { + switch (strtolower($option[1])) { + case 'tap': { + $printer = new PHPUnit2_Util_Log_TAP; + } + break; + + case 'dots': + default: { + $printer = new PHPUnit2_TextUI_ResultPrinter; + } + break; + } + } + break; + case '--repeat': { $repeat = (int)$option[1]; } @@ -281,6 +299,7 @@ try { return $this->doRun( $test, + $printer, $reportDirectory, $testdoxHTMLFile, $testdoxTextFile, @@ -300,19 +319,20 @@ } /** - * @param mixed $test - * @param mixed $reportDirectory - * @param mixed $testdoxHTMLFile - * @param mixed $testdoxTextFile - * @param mixed $graphvizDirectory - * @param mixed $eclipseLogfile - * @param mixed $tapLogfile - * @param mixed $xmlLogfile - * @param boolean $wait + * @param mixed $test + * @param PHPUnit2_Util_Printer $printer + * @param mixed $reportDirectory + * @param mixed $testdoxHTMLFile + * @param mixed $testdoxTextFile + * @param mixed $graphvizDirectory + * @param mixed $eclipseLogfile + * @param mixed $tapLogfile + * @param mixed $xmlLogfile + * @param boolean $wait * @access public * @static */ - public static function run($test, $reportDirectory = FALSE, $testdoxHTMLFile = FALSE, $testdoxTextFile = FALSE, $graphvizDirectory = FALSE, $eclipseLogfile = FALSE, $tapLogfile = FALSE, $xmlLogfile = FALSE, $wait = FALSE) + public static function run($test, PHPUnit2_Util_Printer $printer = NULL, $reportDirectory = FALSE, $testdoxHTMLFile = FALSE, $testdoxTextFile = FALSE, $graphvizDirectory = FALSE, $eclipseLogfile = FALSE, $tapLogfile = FALSE, $xmlLogfile = FALSE, $wait = FALSE) { if ($test instanceof ReflectionClass) { $test = new PHPUnit2_Framework_TestSuite($test); @@ -323,6 +343,7 @@ return $aTestRunner->doRun( $test, + $printer, $reportDirectory, $testdoxHTMLFile, $testdoxTextFile, @@ -354,6 +375,7 @@ FALSE, FALSE, FALSE, + FALSE, TRUE ); } @@ -369,6 +391,7 @@ /** * @param PHPUnit2_Framework_Test $suite + * @param PHPUnit2_Util_Printer $printer * @param mixed $reportDirectory * @param mixed $testdoxHTMLFile * @param mixed $testdoxTextFile @@ -380,7 +403,7 @@ * @return PHPUnit2_Framework_TestResult * @access public */ - public function doRun(PHPUnit2_Framework_Test $suite, $reportDirectory = FALSE, $testdoxHTMLFile = FALSE, $testdoxTextFile = FALSE, $graphvizDirectory = FALSE, $eclipseLogfile = FALSE, $tapLogfile = FALSE, $xmlLogfile = FALSE, $wait = FALSE) + public function doRun(PHPUnit2_Framework_Test $suite, PHPUnit2_Util_Printer $printer = NULL, $reportDirectory = FALSE, $testdoxHTMLFile = FALSE, $testdoxTextFile = FALSE, $graphvizDirectory = FALSE, $eclipseLogfile = FALSE, $tapLogfile = FALSE, $xmlLogfile = FALSE, $wait = FALSE) { if ($graphvizDirectory !== FALSE) { $graphvizDirectory = $this->getDirectory($graphvizDirectory); @@ -393,7 +416,11 @@ $result = $this->createTestResult(); if ($this->printer === NULL) { - $this->printer = new PHPUnit2_TextUI_ResultPrinter; + if ($printer !== NULL) { + $this->printer = $printer; + } else { + $this->printer = new PHPUnit2_TextUI_ResultPrinter; + } } $this->printer->write( @@ -466,7 +493,9 @@ $this->pause($wait); - $this->printer->printResult($result, $timeElapsed); + if ($this->printer instanceof PHPUnit2_TextUI_ResultPrinter) { + $this->printer->printResult($result, $timeElapsed); + } return $result; } @@ -504,7 +533,7 @@ public function showHelp() { self::printVersionString(); - print "Usage: phpunit [switches] UnitTest [UnitTest.php]\n"; + print "Usage: phpunit [switches] UnitTest [UnitTest.php]\n\n"; if (class_exists('Image_GraphViz')) { print " --log-graphviz <dir> Log test execution in GraphViz markup.\n"; @@ -521,6 +550,7 @@ print " --testdox-html <file> Write agile documentation in HTML format to file.\n" . " --testdox-text <file> Write agile documentation in Text format to file.\n\n" . + " --printer {dots|tap} Report test execution progress in DOTS or TAP format.\n" . " --loader <loader> TestSuiteLoader implementation to use.\n" . " --no-syntax-check Do not check for syntax errors.\n\n" . " --skeleton Generate skeleton UnitTest class for Unit in Unit.php.\n\n" . @@ -540,7 +570,9 @@ return; } - $this->printer->printWaitPrompt(); + if ($this->printer instanceof PHPUnit2_TextUI_ResultPrinter) { + $this->printer->printWaitPrompt(); + } fgets(STDIN); }

« previous php.pear.cvs (#40549) next »