| 135 | | include_once "Stagehand/TestRunner/Collector/$testRunnerName.php"; |
| 136 | | $className = "Stagehand_TestRunner_Collector_$testRunnerName"; |
| 137 | | $collector = new $className($directory, $isRecursive); |
| 138 | | |
| 139 | | try { |
| 140 | | $suite = $collector->collect(); |
| 141 | | } catch (Stagehand_TestRunner_Exception $e) { |
| 142 | | echo 'ERROR: ' . $e->getMessage() . "\n"; |
| 143 | | self::_displayUsage(); |
| 144 | | return 1; |
| | 145 | if (!$enableAutotest) { |
| | 146 | include_once "Stagehand/TestRunner/Collector/$testRunnerName.php"; |
| | 147 | $className = "Stagehand_TestRunner_Collector_$testRunnerName"; |
| | 148 | $collector = new $className($directory, $isRecursive); |
| | 149 | |
| | 150 | try { |
| | 151 | $suite = $collector->collect(); |
| | 152 | } catch (Stagehand_TestRunner_Exception $e) { |
| | 153 | echo 'ERROR: ' . $e->getMessage() . "\n"; |
| | 154 | self::_displayUsage(); |
| | 155 | return 1; |
| | 156 | } |
| | 157 | |
| | 158 | include_once "Stagehand/TestRunner/Runner/$testRunnerName.php"; |
| | 159 | $className = "Stagehand_TestRunner_Runner_$testRunnerName"; |
| | 160 | $runner = new $className(); |
| | 161 | $runner->run($suite, $color); |
| | 162 | } else { |
| | 163 | if (php_uname('s') !== 'Windows NT') { |
| | 164 | echo "ERROR: -a option is not supported for your platform.\n"; |
| | 165 | self::_displayUsage(); |
| | 166 | return 1; |
| | 167 | } |
| | 168 | |
| | 169 | $directory = realpath($directory); |
| | 170 | if ($directory === false || !is_dir($directory)) { |
| | 171 | echo "ERROR: The specified path [ $directory ] is not found or not a directory.\n"; |
| | 172 | self::_displayUsage(); |
| | 173 | return 1; |
| | 174 | } |
| | 175 | |
| | 176 | if (array_key_exists('_', $_SERVER)) { |
| | 177 | $command = $_SERVER['_']; |
| | 178 | } else { |
| | 179 | $command = $_SERVER['argv'][0]; |
| | 180 | } |
| | 181 | |
| | 182 | $options = array(); |
| | 183 | if (preg_match('!^/cygdrive/([a-z])/(.+)!', $command, $matches)) { |
| | 184 | $command = "{$matches[1]}:\\" . str_replace('/', '\\', $matches[2]); |
| | 185 | } |
| | 186 | |
| | 187 | if (preg_match('/\.bat$/', $command)) { |
| | 188 | $command = str_replace('/', '\\', $command); |
| | 189 | } |
| | 190 | |
| | 191 | if (!preg_match('/(?:test|spec)runner(?:\.bat)?$/', $command)) { |
| | 192 | $configFile = get_cfg_var('cfg_file_path'); |
| | 193 | if ($configFile !== false) { |
| | 194 | $options[] = '-c'; |
| | 195 | $options[] = dirname($configFile); |
| | 196 | } |
| | 197 | |
| | 198 | $options[] = $_SERVER['argv'][0]; |
| | 199 | } |
| | 200 | |
| | 201 | $options[] = '-R'; |
| | 202 | |
| | 203 | if ($preload) { |
| | 204 | $options[] = "-p $preloadFile"; |
| | 205 | } |
| | 206 | |
| | 207 | if ($color) { |
| | 208 | $options[] = '-c'; |
| | 209 | } |
| | 210 | |
| | 211 | $options[] = $directory; |
| | 212 | |
| | 213 | define('FILE_NOTIFY_CHANGE_FILE_NAME', 0x00000001); |
| | 214 | define('FILE_NOTIFY_CHANGE_DIR_NAME', 0x00000002); |
| | 215 | define('FILE_NOTIFY_CHANGE_ATTRIBUTES', 0x00000004); |
| | 216 | define('FILE_NOTIFY_CHANGE_SIZE', 0x00000008); |
| | 217 | define('FILE_NOTIFY_CHANGE_LAST_WRITE', 0x00000010); |
| | 218 | define('FILE_NOTIFY_CHANGE_LAST_ACCESS', 0x00000020); |
| | 219 | define('FILE_NOTIFY_CHANGE_CREATION', 0x00000040); |
| | 220 | define('FILE_NOTIFY_CHANGE_EA', 0x00000080); |
| | 221 | define('FILE_NOTIFY_CHANGE_SECURITY', 0x00000100); |
| | 222 | define('FILE_NOTIFY_CHANGE_STREAM_NAME', 0x00000200); |
| | 223 | define('FILE_NOTIFY_CHANGE_STREAM_SIZE', 0x00000400); |
| | 224 | define('FILE_NOTIFY_CHANGE_STREAM_WRITE', 0x00000800); |
| | 225 | define('INFINITE', 0xffffffff); |
| | 226 | |
| | 227 | $kernel32 = wb_load_library('kernel32.dll'); |
| | 228 | while (true) { |
| | 229 | $h1 = wb_call_function(wb_get_function_address('FindFirstChangeNotification', $kernel32), |
| | 230 | array($directory, |
| | 231 | 1, |
| | 232 | FILE_NOTIFY_CHANGE_FILE_NAME | FILE_NOTIFY_CHANGE_DIR_NAME | FILE_NOTIFY_CHANGE_ATTRIBUTES | FILE_NOTIFY_CHANGE_LAST_WRITE | FILE_NOTIFY_CHANGE_EA | FILE_NOTIFY_CHANGE_SECURITY) |
| | 233 | ); |
| | 234 | |
| | 235 | print "Waiting for changes in the directory [ $directory ] ...\n"; |
| | 236 | $h2 = wb_call_function(wb_get_function_address('WaitForSingleObject', $kernel32), |
| | 237 | array($h1, INFINITE) |
| | 238 | ); |
| | 239 | passthru("$command " . implode(' ', $options), $result); |
| | 240 | |
| | 241 | $h3 = wb_call_function(wb_get_function_address('FindCloseChangeNotification', $kernel32), |
| | 242 | array($h1) |
| | 243 | ); |
| | 244 | |
| | 245 | if ($result !== 0) { |
| | 246 | return 1; |
| | 247 | } |
| | 248 | } |