Debian Codegraph @

testrunner/filetimes.py

raw symbols SCIP
1 from lxml.etree import parse
2 from collections import defaultdict
3 from os.path import join, exists
4 import argparse
5 parser = argparse.ArgumentParser()
6 parser.add_argument('junitxml')
7 parser.add_argument('fileroot')
8
9 opts = parser.parse_args()
10
11 xml = parse(opts.junitxml)
12 root = xml.getroot()
13
14
15 bugstarts = 'interpreter', 'tool', 'module'
16 def findfile(root, classname):
17 if not classname:
18 return
19 parts = classname.split('.')
20
21 #pytest bug workaround
22 first = parts[0]
23 for start in bugstarts:
24 if first.startswith(start) and \
25 first != start and \
26 first[len(start)] != '.':
27 parts[0] = start
28 parts.insert(1, 'py'+first[len(start):])
29
30 while parts:
31 path = join(root, *parts) + '.py'
32 if exists(path):
33 return join(*parts) + '.py'
34 parts.pop()
35
36 accum = defaultdict(list)
37 garbageitems = []
38
39 for item in root:
40 filename = findfile(opts.fileroot, item.attrib['classname'])
41 accum[filename].append(float(item.attrib['time']))
42 if filename is None:
43 garbageitems.append(item)
44
45
46
47
48 garbage = accum.pop(None, [])
49 if garbage:
50 print 'garbage', sum(garbage), len(garbage)
51
52 for key in sorted(accum):
53 value = accum[key]
54 print key, sum(value), len(value)
55
56 print '-'*30
57
58 for item in garbageitems:
59 print item.attrib