2 namespace Civi\CiUtil\Command
;
5 static function main($argv) {
7 echo "summary: Compares the output of different test runs\n";
8 echo "usage: phpunit-compare [--out=txt|csv] [--phpunit-json|--jenkins-xml] <file1> <file2>...\n";
12 $parser = array('\Civi\CiUtil\PHPUnitParser', 'parseJsonResults');
14 $suites = array(); // array('file' => string, 'results' => array)
15 for ($i = 1; $i < count($argv); $i++
) {
17 case '--phpunit-json':
18 $parser = array('\Civi\CiUtil\PHPUnitParser', 'parseJsonResults');
21 $parser = array('\Civi\CiUtil\JenkinsParser', 'parseXmlResults');
32 'results' => call_user_func($parser, file_get_contents($argv[$i])),
37 $tests = array(); // array(string $name)
38 foreach ($suites as $suite) {
39 $tests = array_unique(array_merge(
41 array_keys($suite['results'])
46 if ($printerType == 'csv') {
47 $printer = new \Civi\CiUtil\
CsvPrinter('php://stdout', \Civi\CiUtil\Arrays
::collect($suites, 'file'));
49 $printer = new \Civi\CiUtil\
ComparisonPrinter(\Civi\CiUtil\Arrays
::collect($suites, 'file'));
51 foreach ($tests as $test) {
53 foreach ($suites as $suite) {
54 $values[] = isset($suite['results'][$test]) ?
$suite['results'][$test] : 'MISSING';
57 if (count(array_unique($values)) > 1) {
58 $printer->printRow($test, $values);