forked from cordoval/PHPAutotest
-
Notifications
You must be signed in to change notification settings - Fork 1
/
autotest.php
executable file
·54 lines (40 loc) · 1023 Bytes
/
autotest.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
#!/usr/bin/php
<?php
/*
* This file is part of PHPAutotest
*
* (c) Guillermo Gutiérrez Almazor <guille@ggalmazor.com>
* (c) Luis Cordoval <cordoval@gmail.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
include('bootstrap.php');
list($file, $framework) = parseArguments($argv);
try {
$autotest = Autotest\Factory::create($file, $framework);
} catch (\Exception $e) {
die(printUsage($e->getMessage()));
}
while (true && $autotest) {
$autotest->executeTest();
while (!$autotest->canRetry()) {
// we wait while prompting for retry key press
}
}
function parseArguments($args) {
if (3 == count($args))
return array($args[2], $args[1]);
if (2 == count($args))
return array($args[1], null);
die(printUsage("Wrong argument count"));
}
function printUsage($error) {
return <<<EOT
{$error}
Usage:
autotest <file/path>
or
autotest <phpunit|phpspec|behat> <file/path>
EOT;
}