35 log = Common.get_logger()
36
37 parser = argparse.ArgumentParser(usage='%(prog)s PATH [PATH] ...')
38 parser.add_argument('paths',
39 metavar='PATH',
40 nargs='+',
41 help='Path containing test python scripts to test')
42 args = parser.parse_args()
43
44 n_failed = 0
45 for p in args.paths:
46 if not os.path.exists(p):
47 log.error('Path %s does not exist', p)
48 return 1
49 tests = [f for f in os.listdir(p) if f.startswith('test_') and f.endswith('.py')]
50 log.info('Testing %d test scripts from path %s', len(tests), p)
51 for test in tests:
52 cmd = 'TRIGVALSTEERING_DRY_RUN=1 {:s}'.format(p+'/'+test)
53 log_file = '{:s}.unitTest.log'.format(test)
54 cmd += ' >{:s} 2>&1'.format(log_file)
55 ret_code = subprocess.call(cmd, shell=True)
56 failed = False
57 status_str = 'OK'
58 if ret_code != 0:
59 failed = True
60 status_str = 'FAILED WITH CODE {:d}'.format(ret_code)
61 errors = grep_errors(log_file)
62 if len(errors) > 0:
63 failed = True
64 status_str = 'ERROR IN LOG {:s}:'.format(log_file)
65 log.info('---- %s ---- %s', test, status_str)
66
67 if failed:
68 n_failed += 1
69 if len(errors) > 0:
70 for msg in errors:
72 else:
73 log.error('Test failed but no ERROR messages found, printing full log below')
74 with open(log_file) as f:
75 for msg in f:
77
78 return n_failed
79
80
void print(char *figname, TCanvas *c1)