diff -r 9b7a2c5fff98 -r c3780102207c SConstruct --- a/SConstruct Fri Apr 06 19:10:21 2012 +0100 +++ b/SConstruct Fri Apr 06 19:36:36 2012 +0100 @@ -463,6 +463,8 @@ Export('Transform') +# enable the regression script to determine whether to use color or not +main['USECOLORS'] = use_colors if GetOption('verbose'): def MakeAction(action, string, *args, **kwargs): diff -r 9b7a2c5fff98 -r c3780102207c tests/SConscript --- a/tests/SConscript Fri Apr 06 19:10:21 2012 +0100 +++ b/tests/SConscript Fri Apr 06 19:36:36 2012 +0100 @@ -38,6 +38,17 @@ env['DIFFOUT'] = File('diff-out') +# determine the use of colors or not based on the imported environment +use_colors = env['USECOLORS'] + +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 + # Dict that accumulates lists of tests by category (quick, medium, long) env.Tests = {} @@ -171,7 +182,26 @@ 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 failed make it red, if 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)