summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xSConstruct12
-rw-r--r--src/python/m5/util/terminal.py9
-rw-r--r--tests/SConscript24
3 files changed, 36 insertions, 9 deletions
diff --git a/SConstruct b/SConstruct
index baf95724a..a45a6e63f 100755
--- a/SConstruct
+++ b/SConstruct
@@ -120,6 +120,7 @@ extra_python_paths = [
sys.path[1:1] = extra_python_paths
from m5.util import compareVersions, readCommand
+from m5.util.terminal import get_termcap
help_texts = {
"options" : "",
@@ -169,14 +170,7 @@ AddLocalOption('--update-ref', dest='update_ref', action='store_true',
AddLocalOption('--verbose', dest='verbose', action='store_true',
help='Print full tool command lines')
-use_colors = GetOption('use_colors')
-if use_colors:
- from m5.util.terminal import termcap
-elif use_colors is None:
- # option unspecified; default behavior is to use colors iff isatty
- from m5.util.terminal import tty_termcap as termcap
-else:
- from m5.util.terminal import no_termcap as termcap
+termcap = get_termcap(GetOption('use_colors'))
########################################################################
#
@@ -462,6 +456,8 @@ class Transform(object):
Export('Transform')
+# enable the regression script to use the termcap
+main['TERMCAP'] = termcap
if GetOption('verbose'):
def MakeAction(action, string, *args, **kwargs):
diff --git a/src/python/m5/util/terminal.py b/src/python/m5/util/terminal.py
index 9038c1f54..6bf85f14d 100644
--- a/src/python/m5/util/terminal.py
+++ b/src/python/m5/util/terminal.py
@@ -93,6 +93,15 @@ if sys.stdout.isatty():
else:
tty_termcap = no_termcap
+def get_termcap(use_colors = None):
+ if use_colors:
+ return termcap
+ elif use_colors is None:
+ # option unspecified; default behavior is to use colors iff isatty
+ return tty_termcap
+ else:
+ return no_termcap
+
def test_termcap(obj):
for c_name in color_names:
c_str = getattr(obj, c_name)
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)