• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# Copyright 2012 the V8 project authors. All rights reserved.
2# Redistribution and use in source and binary forms, with or without
3# modification, are permitted provided that the following conditions are
4# met:
5#
6#     * Redistributions of source code must retain the above copyright
7#       notice, this list of conditions and the following disclaimer.
8#     * Redistributions in binary form must reproduce the above
9#       copyright notice, this list of conditions and the following
10#       disclaimer in the documentation and/or other materials provided
11#       with the distribution.
12#     * Neither the name of Google Inc. nor the names of its
13#       contributors may be used to endorse or promote products derived
14#       from this software without specific prior written permission.
15#
16# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
17# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
18# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
19# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
20# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
21# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
22# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27
28
29import sys
30import time
31
32from . import statusfile
33
34
35REPORT_TEMPLATE = (
36"""Total: %(total)i tests
37 * %(skipped)4d tests will be skipped
38 * %(timeout)4d tests are expected to timeout sometimes
39 * %(nocrash)4d tests are expected to be flaky but not crash
40 * %(pass)4d tests are expected to pass
41 * %(fail_ok)4d tests are expected to fail that we won't fix
42 * %(fail)4d tests are expected to fail that we should fix""")
43
44
45def PrintReport(tests):
46  total = len(tests)
47  skipped = timeout = nocrash = passes = fail_ok = fail = 0
48  for t in tests:
49    if "outcomes" not in dir(t) or not t.outcomes:
50      passes += 1
51      continue
52    o = t.outcomes
53    if statusfile.DoSkip(o):
54      skipped += 1
55      continue
56    if statusfile.TIMEOUT in o: timeout += 1
57    if statusfile.IsPassOrFail(o): nocrash += 1
58    if list(o) == [statusfile.PASS]: passes += 1
59    if statusfile.IsFailOk(o): fail_ok += 1
60    if list(o) == [statusfile.FAIL]: fail += 1
61  print REPORT_TEMPLATE % {
62    "total": total,
63    "skipped": skipped,
64    "timeout": timeout,
65    "nocrash": nocrash,
66    "pass": passes,
67    "fail_ok": fail_ok,
68    "fail": fail
69  }
70
71
72def PrintTestSource(tests):
73  for test in tests:
74    suite = test.suite
75    source = suite.GetSourceForTest(test).strip()
76    if len(source) > 0:
77      print "--- begin source: %s/%s ---" % (suite.name, test.path)
78      print source
79      print "--- end source: %s/%s ---" % (suite.name, test.path)
80
81
82def FormatTime(d):
83  millis = round(d * 1000) % 1000
84  return time.strftime("%M:%S.", time.gmtime(d)) + ("%03i" % millis)
85
86
87def PrintTestDurations(suites, overall_time):
88    # Write the times to stderr to make it easy to separate from the
89    # test output.
90    print
91    sys.stderr.write("--- Total time: %s ---\n" % FormatTime(overall_time))
92    timed_tests = [ t for s in suites for t in s.tests
93                    if t.duration is not None ]
94    timed_tests.sort(lambda a, b: cmp(b.duration, a.duration))
95    index = 1
96    for entry in timed_tests[:20]:
97      t = FormatTime(entry.duration)
98      sys.stderr.write("%4i (%s) %s\n" % (index, t, entry.GetLabel()))
99      index += 1
100