6 def __init__(self
, elts
=()):
11 def __getitem__(self
, item
):
12 return self
.data
[item
]
13 def __setitem__(self
, key
, value
):
15 self
.data
[key
].append(value
)
17 self
.data
[key
] = [value
]
19 return self
.data
.items()
21 return self
.data
.values()
23 return self
.data
.keys()
27 kDiagnosticRE
= re
.compile(': (error|warning): (.*)')
28 kAssertionRE
= re
.compile('Assertion failed: (.*, function .*, file .*, line [0-9]+\\.)')
30 def readInfo(path
, opts
):
31 lastProgress
= [-100,0]
33 pct
= (100. * pos
) / (size
* 2)
34 if (pct
- lastProgress
[0]) >= 10:
36 print '%d/%d = %.2f%%' % (pos
, size
*2, pct
)
42 if opts
.truncate
!= -1:
43 data
= data
[:opts
.truncate
]
46 warnings
= multidict()
48 for m
in kDiagnosticRE
.finditer(data
):
50 if m
.group(1) == 'error':
55 warnings
= warnings
.items()
56 errors
= errors
.items()
57 assertions
= multidict()
58 for m
in kAssertionRE
.finditer(data
):
59 print '%d/%d = %.2f%%' % (size
+ m
.end(), size
, (float(m
.end()) / (size
*2)) * 100.)
60 assertions
[m
.group(1)] = m
61 assertions
= assertions
.items()
63 # Manual scan for stack traces
67 lnIter
= iter(data
.split('\n'))
69 m
= kStackDumpLineRE
.match(ln
)
73 m
= kStackDumpLineRE
.match(ln
)
76 stack
.append(m
.group(2))
77 if prevLine
is None or not kAssertionRE
.match(prevLine
):
78 aborts
[tuple(stack
)] = stack
82 (warnings
, 'Warnings'),
84 (assertions
, 'Assertions'),
85 (aborts
.items(), 'Aborts'),
91 for l
,title
in sections
:
92 l
.sort(key
= lambda (a
,b
): -len(b
))
94 print '-- %d %s (%d kinds) --' % (sum([len(b
) for a
,b
in l
]), title
, len(l
))
96 print '%5d:' % len(elts
), name
100 from optparse
import OptionParser
101 parser
= OptionParser("usage: %prog [options] {inputs}")
102 parser
.add_option("", "--ascending", dest
="ascending",
103 help="Print output in ascending order of severity.",
104 action
="store_true", default
=False)
105 parser
.add_option("", "--truncate", dest
="truncate",
106 help="Truncate input file (for testing).",
107 type=int, action
="store", default
=-1)
108 (opts
, args
) = parser
.parse_args()
111 parser
.error('No inputs specified')
116 if __name__
=='__main__':