forked from scipy/scipy
-
Notifications
You must be signed in to change notification settings - Fork 0
/
validate_runtests_log.py
executable file
·76 lines (64 loc) · 2.46 KB
/
validate_runtests_log.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
#!/usr/bin/env python
"""
Take the test runner log output from the stdin, looking for
the magic line nose runner prints when the test run was successful.
In an ideal world, this should be done directly in runtests.py using the
nose API, some failure modes are fooling nose to terminate the python process
with zero exit code, see, eg, https://github.com/scipy/scipy/issues/4736
In short, lapack's xerbla can terminate the process with a fortran level STOP
command, which (i) aborts the py process so that runtests.py does not finish,
and (ii) the exit code is implementation-defined.
Also check that the number of tests run is larger than some baseline number
(taken from the state of the master branch at some random point in time.)
This probably could/should be made less brittle.
"""
from __future__ import print_function
import sys
import re
if __name__ == "__main__":
# full or fast test suite?
try:
testmode = sys.argv[1]
if testmode not in ('fast', 'full'):
raise IndexError
except IndexError:
raise ValueError("Usage: validate.py {full|fast} < logfile.")
# fetch the expected number of tests
# these numbers are for 10d5dfe8b7
# XXX: this should probably track the commit hash or commit date
expected_size = {'full': 11000,
'fast': 10000}
# read in the log, parse for the pytest printout
r1 = re.compile("(?P<num_failed>\d+) failed, (?P<num_passed>\d+) passed,.* in (?P<time>\d+\S+)")
r2 = re.compile("(?P<num_passed>\d+) passed,.* in (?P<time>\d+\S+)")
found_it = False
while True:
line = sys.stdin.readline()
if not line:
break
m = r1.search(line)
if not m:
m = r2.search(line)
if m:
found_it = True
break
if found_it:
passed = int(m.group('num_passed'))
try:
failed = int(m.group('num_failed'))
except IndexError:
failed = 0
if failed:
print("*** Looks like some tests failed.")
sys.exit(-1)
# now check that the number of tests run is reasonable
expected = expected_size[testmode]
actual = passed + failed
if actual < expected:
print("*** Too few tests: expected %s, run %s" % (expected, actual))
sys.exit(1)
else:
sys.exit(0)
else:
print('*** Test runner validation errored: did the run really finish?')
sys.exit(-1)