-
Notifications
You must be signed in to change notification settings - Fork 241
Expand file tree
/
Copy pathrunner.php
More file actions
executable file
·103 lines (77 loc) · 2.48 KB
/
runner.php
File metadata and controls
executable file
·103 lines (77 loc) · 2.48 KB
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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
<?php
include_once __DIR__ . '/bootstrap.php';
use WhichBrowser\Testrunner;
use WhichBrowser\Tests;
use SebastianBergmann\CodeCoverage\CodeCoverage;
use SebastianBergmann\CodeCoverage\Report\Clover;
set_error_handler(function ($errno, $errstr, $errfile, $errline) {
// error was suppressed with the @-operator
if (0 === error_reporting()) {
return false;
}
throw new ErrorException($errstr, 0, $errno, $errfile, $errline);
});
$all = false;
$command = 'compare';
$files = [];
$options = [];
array_shift($argv);
if (count($argv)) {
foreach ($argv as $argument) {
if (in_array($argument, [ 'compare', 'check', 'rebase', 'list' ])) {
$command = $argument;
} elseif (substr($argument, 0, 2) == '--') {
$options[] = substr($argument, 2);
} else {
if (fnmatch("*.yaml", $argument)) {
$files[] = $argument;
} else {
$files = array_merge($files, Tests::getFromCategory($argument));
}
}
}
}
if (count($files) === 0) {
$files = Tests::getAll();
}
switch ($command) {
case 'list':
Testrunner::search($files);
break;
case 'check':
if (in_array('coverage', $options)) {
$coverage = new CodeCoverage;
$coverage->filter()->addDirectoryToWhitelist('src');
$coverage->start('Testrunner');
}
$result = Testrunner::compare($files, false);
if (in_array('coverage', $options)) {
$coverage->stop();
$writer = new Clover;
$writer->process($coverage, 'runner.xml');
echo "\nCoverage saved as runner.xml\n\n";
}
if (!$result) {
echo "\033[0;31mTestrunner failed, please fix or rebase before building or deploying!\033[0m\n\n";
if (in_array('show', $options)) {
echo file_get_contents('runner.log') . "\n\n";
echo "Done!\n\n";
}
exit(1);
}
break;
case 'compare':
$result = Testrunner::compare($files, false);
if (!$result) {
echo "\033[0;31mTestrunner failed, please look at runner.log for the details!\033[0m\n\n";
if (in_array('show', $options)) {
echo file_get_contents('runner.log') . "\n\n";
echo "Done!\n\n";
}
exit(1);
}
break;
case 'rebase':
Testrunner::rebase($files, false);
break;
}