|
11 | 11 | from SCons.Action import Action |
12 | 12 | from subprocess import check_output, STDOUT, CalledProcessError |
13 | 13 | import sys |
| 14 | +import os |
14 | 15 |
|
15 | 16 |
|
16 | 17 | def BoostCompileTest(env, test, source = None, **kw): |
| 18 | + |
| 19 | + def gen_result(target, source, env=env): |
| 20 | + target_file = target[0].abspath |
| 21 | + result_file = os.path.splitext(target_file)[0] + '.result' |
| 22 | + if sys.stdout.isatty(): |
| 23 | + env['RESULT']='\033[92mPASS\033[0m' |
| 24 | + else: |
| 25 | + env['RESULT']='PASS' |
| 26 | + |
| 27 | + with open(result_file, 'w+') as result: |
| 28 | + result.write('Result: {}\n'.format('pass')) |
| 29 | + |
17 | 30 | obj = env.Object(test, source if source is not None else test + '.cpp') |
| 31 | + env.AddPostAction(obj, Action(gen_result, cmdstr=None)) |
| 32 | + env.AddPostAction(obj, Action('@echo $RESULT')) |
18 | 33 | return obj |
19 | 34 |
|
20 | 35 | def BoostRun(env, prog, target, command = '$SOURCE'): |
@@ -77,8 +92,11 @@ def print_summary(target, source, **kw): |
77 | 92 | failures = [r for r in results |
78 | 93 | if r.get_path().endswith('.result') and not 'Result: pass' in r.get_contents()] |
79 | 94 | print('%s tests; %s pass; %s fails'%(len(results), len(results)-len(failures), len(failures))) |
| 95 | + if failures: |
| 96 | + print('For detailed failure reports, see:') |
80 | 97 | for f in failures: |
81 | | - print('%s\n%s'%(f.get_path(), f.get_contents())) |
| 98 | + print(f.get_path()) |
| 99 | + |
82 | 100 | testsumcomstr = env.get('TESTSUMCOMSTR') |
83 | 101 | if testsumcomstr: |
84 | 102 | run = env.Command('summary', tests, Action(print_summary, cmdstr=testsumcomstr)) |
|
0 commit comments