summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorAndreas Hansson <andreas.hansson@arm.com>2012-04-14 05:44:27 -0400
committerAndreas Hansson <andreas.hansson@arm.com>2012-04-14 05:44:27 -0400
commitb9bc530ad20bceeed6e43ea459d271046f43e70c (patch)
tree8ff4ae20d6d05f4ca7267b0f5339e56c2b5e92a7 /tests
parentb6aa6d55eb856f99a06c400b5dcda118c46dacfa (diff)
downloadgem5-b9bc530ad20bceeed6e43ea459d271046f43e70c.tar.xz
Regression: Add ANSI colours to highlight test status
This patch adds a very basic pretty-printing of the test status (passed or failed) to highlight failing tests even more: green for passed, and red for failed. The printing only uses ANSI it the target output is a tty and supports ANSI colours. Hence, any regression scripts that are outputting to files or sending e-mails etc should still be fine.
Diffstat (limited to 'tests')
-rw-r--r--tests/SConscript24
1 files changed, 23 insertions, 1 deletions
diff --git a/tests/SConscript b/tests/SConscript
index 93bdcf9b4..d9c40ebe3 100644
--- a/tests/SConscript
+++ b/tests/SConscript
@@ -38,6 +38,9 @@ Import('env')
env['DIFFOUT'] = File('diff-out')
+# get the termcap from the environment
+termcap = env['TERMCAP']
+
# Dict that accumulates lists of tests by category (quick, medium, long)
env.Tests = {}
@@ -171,7 +174,26 @@ def run_test_string(target, source, env):
testAction = env.Action(run_test, run_test_string)
def print_test(target, source, env):
- print '***** ' + contents(source[0])
+ # print the status with colours to make it easier to see what
+ # passed and what failed
+ line = contents(source[0])
+
+ # split the line to words and get the last one
+ words = line.split()
+ status = words[-1]
+
+ # if the test failed make it red, if it passed make it green, and
+ # skip the punctuation
+ if status == "FAILED!":
+ status = termcap.Red + status[:-1] + termcap.Normal + status[-1]
+ elif status == "passed.":
+ status = termcap.Green + status[:-1] + termcap.Normal + status[-1]
+
+ # put it back in the list and join with space
+ words[-1] = status
+ line = " ".join(words)
+
+ print '***** ' + line
return 0
printAction = env.Action(print_test, strfunction = None)