]> git.lizzy.rs Git - rust.git/blob - src/etc/check-summary.py
auto merge of #12114 : brson/rust/faqs, r=cmr
[rust.git] / src / etc / check-summary.py
1 # Copyright 2012-2014 The Rust Project Developers. See the COPYRIGHT
2 # file at the top-level directory of this distribution and at
3 # http://rust-lang.org/COPYRIGHT.
4 #
5 # Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6 # http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7 # <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8 # option. This file may not be copied, modified, or distributed
9 # except according to those terms.
10
11 import glob
12 import sys
13
14 if __name__ == '__main__':
15     summaries = []
16     def summarise(fname):
17         summary = {}
18         with open(fname) as fd:
19             for line in fd:
20                 splitline = line.strip().split(' ')
21                 if len(splitline) == 1:
22                     continue
23                 status = splitline[0]
24                 test = splitline[-1]
25                 # track bench runs
26                 if splitline[1] == 'ns/iter':
27                     status = 'bench'
28                 if not summary.has_key(status):
29                     summary[status] = []
30                 summary[status].append(test)
31             summaries.append((fname, summary))
32     def count(t):
33         return sum(map(lambda (f, s): len(s.get(t, [])), summaries))
34     logfiles = sys.argv[1:]
35     for files in map(glob.glob, logfiles):
36         map(summarise, files)
37     ok = count('ok')
38     failed = count('failed')
39     ignored = count('ignored')
40     measured = count('bench')
41     print "summary of %d test runs: %d passed; %d failed; %d ignored; %d measured" % \
42             (len(logfiles), ok, failed, ignored, measured)
43     print ""
44     if failed > 0:
45         print "failed tests:"
46         for f, s in summaries:
47             failures = s.get('failed', [])
48             if len(failures) > 0:
49                 print "  %s:" % (f)
50             for test in failures:
51                 print "    %s" % (test)