Changeset 165
- Timestamp:
- 05/25/08 12:55:44 (8 months ago)
- Location:
- trunk
- Files:
-
- 4 modified
-
bin/specrunner (modified) (1 diff)
-
bin/testrunner (modified) (1 diff)
-
bin/testrunner-st (modified) (1 diff)
-
src/Stagehand/TestRunner.php (modified) (11 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/bin/specrunner
r160 r165 45 45 require_once 'Stagehand/TestRunner.php'; 46 46 47 $result = Stagehand_TestRunner::run('PHPSpec'); 47 $runner = new Stagehand_TestRunner('PHPSpec'); 48 $result = $runner->run(); 48 49 49 50 exit($result); -
trunk/bin/testrunner
r160 r165 45 45 require_once 'Stagehand/TestRunner.php'; 46 46 47 $result = Stagehand_TestRunner::run('PHPUnit'); 47 $runner = new Stagehand_TestRunner('PHPUnit'); 48 $result = $runner->run(); 48 49 49 50 exit($result); -
trunk/bin/testrunner-st
r160 r165 45 45 require_once 'Stagehand/TestRunner.php'; 46 46 47 $result = Stagehand_TestRunner::run('SimpleTest'); 47 $runner = new Stagehand_TestRunner('SimpleTest'); 48 $result = $runner->run(); 48 49 49 50 exit($result); -
trunk/src/Stagehand/TestRunner.php
r163 r165 72 72 */ 73 73 74 private $_testRunnerName; 75 private $_config; 76 74 77 /**#@-*/ 75 78 … … 77 80 * @access public 78 81 */ 82 83 // }}} 84 // {{{ __construct() 85 86 /** 87 * @param string $testRunnerName 88 */ 89 public function __construct($testRunnerName) 90 { 91 $this->_testRunnerName = $testRunnerName; 92 } 79 93 80 94 // }}} … … 84 98 * Runs tests automatically. 85 99 * 86 * @ param string $testRunnerName87 */ 88 public static function run($testRunnerName)100 * @return integer 101 */ 102 public function run() 89 103 { 90 104 if (!array_key_exists('argv', $_SERVER)) { … … 94 108 95 109 try { 96 $ config = self::_parseOptions();97 if (is_null($ config)) {110 $this->_config = $this->_parseOptions(); 111 if (is_null($this->_config)) { 98 112 return 1; 99 113 } 100 114 101 if (!$ config->enableAutotest) {102 self::_runTests($testRunnerName, $config);115 if (!$this->_config->enableAutotest) { 116 $this->_runTests(); 103 117 } else { 104 self::_monitorAlteration($config);118 $this->_monitorAlteration(); 105 119 } 106 120 } catch (Stagehand_TestRunner_Exception $e) { 107 121 echo 'ERROR: ' . $e->getMessage() . "\n"; 108 self::_displayUsage();122 $this->_displayUsage(); 109 123 return 1; 110 124 } … … 131 145 * Displays the usage. 132 146 */ 133 private staticfunction _displayUsage()147 private function _displayUsage() 134 148 { 135 149 echo "Usage: {$_SERVER['SCRIPT_NAME']} [options] [directory or file] … … 155 169 * Displays the version. 156 170 */ 157 private staticfunction _displayVersion()158 { 159 echo "Stagehand_TestRunner @package_version@ 171 private function _displayVersion() 172 { 173 echo "Stagehand_TestRunner @package_version@ ({$this->_testRunnerName}) 160 174 161 175 Copyright (c) 2005-2008 KUBO Atsuhiro <iteman@users.sourceforge.net>, … … 173 187 * directory is always added to the target directories. 174 188 * 175 * @param stdClass $config176 189 * @throws Stagehand_TestRunner_Exception 177 190 * @since Method available since Release 2.1.0 178 191 */ 179 private static function _monitorAlteration($config)192 private function _monitorAlteration() 180 193 { 181 194 $targetDirectories = array(); 182 foreach (array_merge($ config->targetDirectories, (array)$config->directory)195 foreach (array_merge($this->_config->targetDirectories, (array)$this->_config->directory) 183 196 as $directory 184 197 ) { … … 224 237 $options[] = '-R'; 225 238 226 if (!is_null($ config->preloadFile)) {227 $options[] = "-p {$ config->preloadFile}";228 } 229 230 if ($ config->color) {239 if (!is_null($this->_config->preloadFile)) { 240 $options[] = "-p {$this->_config->preloadFile}"; 241 } 242 243 if ($this->_config->color) { 231 244 $options[] = '-c'; 232 245 } 233 246 234 if ($ config->useGrowl) {247 if ($this->_config->useGrowl) { 235 248 $options[] = '-g'; 236 249 } 237 250 238 $options[] = $ config->directory;251 $options[] = $this->_config->directory; 239 252 240 253 $monitor = new Stagehand_TestRunner_AlterationMonitor($targetDirectories, … … 254 267 * @since Method available since Release 2.1.0 255 268 */ 256 private staticfunction _parseOptions()269 private function _parseOptions() 257 270 { 258 271 PEAR::staticPushErrorHandling(PEAR_ERROR_RETURN); … … 287 300 switch ($option[0]) { 288 301 case 'h': 289 self::_displayUsage();302 $this->_displayUsage(); 290 303 return; 291 304 case 'V': 292 self::_displayVersion();305 $this->_displayVersion(); 293 306 return; 294 307 case 'R': … … 337 350 * Runs tests. 338 351 * 339 * @param string $testRunnerName340 * @param stdClass $config341 352 * @since Method available since Release 2.1.0 342 353 */ 343 private static function _runTests($testRunnerName, $config) 344 { 345 include_once "Stagehand/TestRunner/Collector/$testRunnerName.php"; 346 $className = "Stagehand_TestRunner_Collector_$testRunnerName"; 347 $collector = new $className($config->directory, $config->isRecursive); 354 private function _runTests() 355 { 356 include_once "Stagehand/TestRunner/Collector/{$this->_testRunnerName}.php"; 357 $className = "Stagehand_TestRunner_Collector_{$this->_testRunnerName}"; 358 $collector = new $className($this->_config->directory, 359 $this->_config->isRecursive 360 ); 348 361 $suite = $collector->collect(); 349 362 350 include_once "Stagehand/TestRunner/Runner/ $testRunnerName.php";351 $className = "Stagehand_TestRunner_Runner_ $testRunnerName";363 include_once "Stagehand/TestRunner/Runner/{$this->_testRunnerName}.php"; 364 $className = "Stagehand_TestRunner_Runner_{$this->_testRunnerName}"; 352 365 $runner = new $className(); 353 $runner->run($suite, $ config);354 355 if ($ config->useGrowl) {366 $runner->run($suite, $this->_config); 367 368 if ($this->_config->useGrowl) { 356 369 $notification = $runner->getNotification(); 357 370 $application = new Net_Growl_Application('Stagehand_TestRunner',
