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(
43 r'^FAILED \((?:failures=(?P<f>\d+))?,? ?(?:errors=(?P<e>\d+))?\)$', s, re.M)
44 ok_match = re.search('^OK$', s, re.M)
46 assert not ok_match, (ok_match, s)
47 fail = failed_match.group('f')
48 error = failed_match.group('e')
49 fail = int(fail or '0')
50 error = int(error or '0')
52 assert ok_match, repr(s)
53 timeout_match = re.search('^===disabled because of timeout: (\d+)$', s, re.M)
55 timeout = int(timeout_match.group(1))
56 return num, error, fail, timeout
60 c = sqlite3.connect(db)
61 c.execute('''create table if not exists parsed_command_record
62 (id integer not null unique,
71 timeout_names text)''')
76 SQL = ('select command_record.id, command, stdout, exitcode from command_record '
77 'where not exists (select * from parsed_command_record where '
78 'parsed_command_record.id=command_record.id)')
79 for row in c.execute(SQL).fetchall():
80 id, command, stdout, exitcode = row
82 testname, hub = parse_stdout(stdout)
83 if unittest_delim in stdout:
84 runs, errors, fails, timeouts = parse_unittest_output(stdout)
87 runs, errors, fails, timeouts = 1, 0, 0, 0
89 runs, errors, fails, timeouts = 0, 0, 0, 1
91 runs, errors, fails, timeouts = 1, 1, 0, 0
94 sys.stderr.write('Failed to parse id=%s\n' % id)
98 print(id, hub, testname, runs, errors, fails, timeouts)
99 c.execute('insert into parsed_command_record '
100 '(id, testname, hub, runs, errors, fails, timeouts) '
101 'values (?, ?, ?, ?, ?, ?, ?)',
102 (id, testname, hub, runs, errors, fails, timeouts))
105 if __name__ == '__main__':
107 latest_db = sorted(glob.glob('results.*.db'), key=lambda f: os.stat(f).st_mtime)[-1]
109 sys.argv.append(latest_db)
110 for db in sys.argv[1:]:
112 execfile('generate_report.py')