From 1cf32dd01d3b5a807f763f3dc38e387cb330425d Mon Sep 17 00:00:00 2001 From: Thomas Gelf Date: Wed, 12 Nov 2014 09:15:04 +0100 Subject: [PATCH] test/php: add colorized testdox output for verbose This shows all tests as a cute summary and marks failed and good ones red and green. --- .../application/clicommands/PhpCommand.php | 20 +++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/modules/test/application/clicommands/PhpCommand.php b/modules/test/application/clicommands/PhpCommand.php index 126e0c462..dbcb58f05 100644 --- a/modules/test/application/clicommands/PhpCommand.php +++ b/modules/test/application/clicommands/PhpCommand.php @@ -56,7 +56,7 @@ class PhpCommand extends Command $options = array(); if ($this->isVerbose) { - $options[] = '--verbose'; + $options[] = '--verbose --testdox'; } if ($build) { $reportPath = $this->setupAndReturnReportDirectory(); @@ -71,7 +71,23 @@ class PhpCommand extends Command } chdir(realpath(__DIR__ . '/../..')); - passthru($phpUnit . ' ' . join(' ', array_merge($options, $this->params->getAllStandalone()))); + $command = $phpUnit . ' ' . join(' ', array_merge($options, $this->params->getAllStandalone())); + if ($this->isVerbose) { + $res = `$command`; + foreach (preg_split('/\n/', $res) as $line) { + if (preg_match('~\s+\[([x\s])\]\s~', $line, $m)) { + if ($m[1] === 'x') { + echo $this->screen->colorize($line, 'green') . "\n"; + } else { + echo $this->screen->colorize($line, 'red') . "\n"; + } + } else { + echo $line . "\n"; + } + } + } else { + passthru($command); + } } /**