7 import pysqlite2.dbapi2 as sqlite3
13 argv = re.search('^===ARGV=(.*?)$', s, re.M).group(1)
20 if argv[0] == '--hub':
24 elif argv[0] == '--reactor':
30 if reactor is not None:
31 hub += '/%s' % reactor
34 unittest_delim = '----------------------------------------------------------------------'
37 def parse_unittest_output(s):
38 s = s[s.rindex(unittest_delim) + len(unittest_delim):]
39 num = int(re.search('^Ran (\d+) test.*?$', s, re.M).group(1))
40 ok = re.search('^OK$', s, re.M)
41 error, fail, timeout = 0, 0, 0
42 failed_match = re.search(r'^FAILED \((?:failures=(?P<f>\d+))?,? ?(?:errors=(?P<e>\d+))?\)$', s, re.M)
43 ok_match = re.search('^OK$', s, re.M)
45 assert not ok_match, (ok_match, s)
46 fail = failed_match.group('f')
47 error = failed_match.group('e')
48 fail = int(fail or '0')
49 error = int(error or '0')
51 assert ok_match, repr(s)
52 timeout_match = re.search('^===disabled because of timeout: (\d+)$', s, re.M)
54 timeout = int(timeout_match.group(1))
55 return num, error, fail, timeout
59 c = sqlite3.connect(db)
60 c.execute('''create table if not exists parsed_command_record
61 (id integer not null unique,
70 timeout_names text)''')
75 SQL = ('select command_record.id, command, stdout, exitcode from command_record '
76 'where not exists (select * from parsed_command_record where '
77 'parsed_command_record.id=command_record.id)')
78 for row in c.execute(SQL).fetchall():
79 id, command, stdout, exitcode = row
81 testname, hub = parse_stdout(stdout)
82 if unittest_delim in stdout:
83 runs, errors, fails, timeouts = parse_unittest_output(stdout)
86 runs, errors, fails, timeouts = 1, 0, 0, 0
88 runs, errors, fails, timeouts = 0, 0, 0, 1
90 runs, errors, fails, timeouts = 1, 1, 0, 0
93 sys.stderr.write('Failed to parse id=%s\n' % id)
97 print(id, hub, testname, runs, errors, fails, timeouts)
98 c.execute('insert into parsed_command_record '
99 '(id, testname, hub, runs, errors, fails, timeouts) '
100 'values (?, ?, ?, ?, ?, ?, ?)',
101 (id, testname, hub, runs, errors, fails, timeouts))
104 if __name__ == '__main__':
106 latest_db = sorted(glob.glob('results.*.db'), key=lambda f: os.stat(f).st_mtime)[-1]
108 sys.argv.append(latest_db)
109 for db in sys.argv[1:]:
111 execfile('generate_report.py')