Skip to content

Instantly share code, notes, and snippets.

@fzaninotto
Created November 10, 2010 23:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save fzaninotto/671706 to your computer and use it in GitHub Desktop.
Save fzaninotto/671706 to your computer and use it in GitHub Desktop.
diff for phing's phpunit formatters to make cli output nicer in phinh 2.3.3
diff --git a/phpunit3/PlainPHPUnit3ResultFormatter.php b/phpunit3/PlainPHPUnit3ResultFormatter.php
index f2997aa..a671670 100644
--- a/phpunit3/PlainPHPUnit3ResultFormatter.php
+++ b/phpunit3/PlainPHPUnit3ResultFormatter.php
@@ -52,19 +52,13 @@ class PlainPHPUnit3ResultFormatter extends PHPUnit3ResultFormatter
function endTestSuite(PHPUnit_Framework_TestSuite $suite)
{
- $sb = "Testsuite: " . $suite->getName() . "\n";
- $sb.= "Tests run: " . $this->getRunCount();
- $sb.= ", Failures: " . $this->getFailureCount();
- $sb.= ", Errors: " . $this->getErrorCount();
- $sb.= ", Incomplete: " . $this->getIncompleteCount();
- $sb.= ", Skipped: " . $this->getSkippedCount();
- $sb.= ", Time elapsed: " . sprintf('%0.5f', $this->getElapsedTime()) . " s\n";
-
parent::endTestSuite($suite);
+ if ( $this->getErrorCount()) {
+ $this->inner .= "\033[31m";
+ }
if ($this->out != NULL)
{
- $this->out->write($sb);
$this->out->write($this->inner);
}
}
@@ -102,11 +96,11 @@ class PlainPHPUnit3ResultFormatter extends PHPUnit3ResultFormatter
$this->endTest($test, time());
}
- $this->inner.= $test->getName() . " " . $type . "\n";
+ $this->inner.= $type == "FAILED" ? "\033[31m" . $test->getName() . " " . $type . "\033[0m\n" : "\033[33m" . $test->getName() . " " . $type .
if ($e !== null) {
- $this->inner.= $e->getMessage() . "\n";
- $this->inner.= PHPUnit_Util_Filter::getFilteredStackTrace($e, false) . "\n";
+ $this->inner.= "\033[31m" . str_replace("\n", "\n\033[31m", $e->getMessage()) . "\n";
+ $this->inner.= "\033[31m" . str_replace("\n", "\n\033[31m", PHPUnit_Util_Filter::getFilteredStackTrace($e, false)) . "\033[0m\n";
}
}
diff --git a/phpunit3/SummaryPHPUnit3ResultFormatter.php b/phpunit3/SummaryPHPUnit3ResultFormatter.php
index 0aca54d..556bba0 100644
--- a/phpunit3/SummaryPHPUnit3ResultFormatter.php
+++ b/phpunit3/SummaryPHPUnit3ResultFormatter.php
@@ -33,7 +33,8 @@ class SummaryPHPUnit3ResultFormatter extends PHPUnit3ResultFormatter
{
function endTestSuite(PHPUnit_Framework_TestSuite $suite)
{
- $sb = "Test: " . $suite->getName();
+ $sb = $this->getFailureCount() ? "\033[31m" : '';
+ $sb .= "Test: " . $suite->getName();
$sb.= ", Run: " . $this->getRunCount();
$sb.= ", Failures: " . $this->getFailureCount();
$sb.= ", Errors: " . $this->getErrorCount();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment