summaryrefslogtreecommitdiff
path: root/modules/gallery_unit_test/views
diff options
context:
space:
mode:
authorBharat Mediratta <bharat@menalto.com>2008-12-16 02:25:47 +0000
committerBharat Mediratta <bharat@menalto.com>2008-12-16 02:25:47 +0000
commit02aa98b6e0f4bfdc70cbb28e16910c2f173072f9 (patch)
tree08718b4219d80f398d618314c79b905cd435359b /modules/gallery_unit_test/views
parent61618af0db392e044ce54ab4cd585cf792b21751 (diff)
Colorize test output
Diffstat (limited to 'modules/gallery_unit_test/views')
-rw-r--r--modules/gallery_unit_test/views/kohana_unit_test.php36
1 files changed, 29 insertions, 7 deletions
diff --git a/modules/gallery_unit_test/views/kohana_unit_test.php b/modules/gallery_unit_test/views/kohana_unit_test.php
index e11f13bf..df6289a9 100644
--- a/modules/gallery_unit_test/views/kohana_unit_test.php
+++ b/modules/gallery_unit_test/views/kohana_unit_test.php
@@ -1,27 +1,47 @@
<? defined("SYSPATH") or die("No direct script access."); ?>
<?php
+
+function green_start() {
+ return "\x1B[32m";
+}
+
+function color_end() {
+ return "\x1B[0m";
+}
+
+function red_start() {
+ return "\x1B[31m";
+}
+
+function magenta_start() {
+ return "\x1B[35m";
+}
+
foreach ($results as $class => $methods) {
echo "+", str_repeat("-", 98), "+\n";
printf("| %-96.96s |\n", $class);
- echo "+", str_repeat("-", 57), "+", str_repeat("-", 40), "+\n";
+ echo "+", str_repeat("-", 87), "+", str_repeat("-", 10), "+\n";
foreach (array("score", "total", "passed", "failed", "errors") as $key) {
@$totals[$key] += $stats[$class][$key];
}
if (empty($methods)) {
- printf("| %-96.96s |\n", "NO TESTS FOUND");
+ printf("| %-96.96s |\n", magenta("NO TESTS FOUND"));
} else {
foreach ($methods as $method => $result) {
// Hide passed tests from report
if ($result === true AND $hide_passed === true) {
continue;
}
- printf("| %-56.56s", $method);
if ($result === true) {
- printf("| PASS |\n");
+ printf("| %s%-85.85s%s | %sPASS%s |\n",
+ green_start(), $method, color_end(),
+ green_start(), color_end());
} else if ($result instanceof Kohana_Unit_Test_Exception) {
- printf("| FAIL |\n");
+ printf("| %s%-85.85s%s | %sFAIL%s |\n",
+ red_start(), $method, color_end(),
+ red_start(), color_end());
echo " ", $result->getMessage(), "\n";
echo " ", $result->getFile();
echo " ", "(" . Kohana::lang("unit_test.line") . " " . $result->getLine(), ")\n";
@@ -31,7 +51,9 @@ foreach ($results as $class => $methods) {
}
echo "\n";
} else if ($result instanceof Exception) {
- printf("| ERROR |\n");
+ printf("| %s%-85.85s%s | %sERROR%s |\n",
+ magenta_start(), $method, color_end(),
+ magenta_start(), color_end());
if ($result->getMessage()) {
echo " ", $result->getMessage(), "\n";
}
@@ -41,7 +63,7 @@ foreach ($results as $class => $methods) {
}
}
- echo "+", str_repeat("=", 57), "+", str_repeat("=", 40), "+\n";
+ echo "+", str_repeat("=", 87), "+", str_repeat("=", 10), "+\n";
printf("| %-40.40s %-13.13s %-13.13s %-13.13s %-13.13s |\n",
$class,
"Score: {$stats[$class]['score']}",