Show More
@@ -0,0 +1,101 b'' | |||||
|
1 | #!/usr/bin/env python | |||
|
2 | """Master test runner for IPython - EXPERIMENTAL CODE!!! | |||
|
3 | ||||
|
4 | This tries | |||
|
5 | ||||
|
6 | XXX - Big limitation right now: we don't summarize the total test counts. That | |||
|
7 | would require parsing the output of the subprocesses. | |||
|
8 | """ | |||
|
9 | import os.path as path | |||
|
10 | import subprocess as subp | |||
|
11 | import time | |||
|
12 | ||||
|
13 | class IPTester(object): | |||
|
14 | """Object to call iptest with specific parameters. | |||
|
15 | """ | |||
|
16 | def __init__(self,runner='iptest',params=None): | |||
|
17 | """ """ | |||
|
18 | if runner == 'iptest': | |||
|
19 | self.runner = ['iptest','-v'] | |||
|
20 | else: | |||
|
21 | self.runner = ['trial'] | |||
|
22 | if params is None: | |||
|
23 | params = [] | |||
|
24 | if isinstance(params,str): | |||
|
25 | params = [params] | |||
|
26 | self.params = params | |||
|
27 | ||||
|
28 | # Assemble call | |||
|
29 | self.call_args = self.runner+self.params | |||
|
30 | ||||
|
31 | def run(self): | |||
|
32 | """Run the stored commands""" | |||
|
33 | return subp.call(self.call_args) | |||
|
34 | ||||
|
35 | ||||
|
36 | def make_runners(): | |||
|
37 | top_mod = \ | |||
|
38 | ['background_jobs.py', 'ColorANSI.py', 'completer.py', 'ConfigLoader.py', | |||
|
39 | 'CrashHandler.py', 'Debugger.py', 'deep_reload.py', 'demo.py', | |||
|
40 | 'DPyGetOpt.py', 'dtutils.py', 'excolors.py', 'FakeModule.py', | |||
|
41 | 'generics.py', 'genutils.py', 'Gnuplot2.py', 'GnuplotInteractive.py', | |||
|
42 | 'GnuplotRuntime.py', 'history.py', 'hooks.py', 'ipapi.py', | |||
|
43 | 'iplib.py', 'ipmaker.py', 'ipstruct.py', 'irunner.py', 'Itpl.py', | |||
|
44 | 'Logger.py', 'macro.py', 'Magic.py', 'numutils.py', 'OInspect.py', | |||
|
45 | 'OutputTrap.py', 'platutils_dummy.py', 'platutils_posix.py', | |||
|
46 | 'platutils.py', 'platutils_win32.py', 'prefilter.py', 'Prompts.py', | |||
|
47 | 'PyColorize.py', 'Release.py', 'rlineimpl.py', 'shadowns.py', | |||
|
48 | 'shellglobals.py', 'Shell.py', 'strdispatch.py', 'twshell.py', | |||
|
49 | 'ultraTB.py', 'upgrade_dir.py', 'usage.py', 'wildcard.py', | |||
|
50 | 'winconsole.py'] | |||
|
51 | ||||
|
52 | top_pack = ['config','Extensions','frontend','gui','kernel', | |||
|
53 | 'testing','tests','tools','UserConfig'] | |||
|
54 | ||||
|
55 | modules = ['IPython.%s' % m for m in top_mod ] | |||
|
56 | packages = ['IPython.%s' % m for m in top_pack ] | |||
|
57 | ||||
|
58 | # Make runners | |||
|
59 | runners = dict(zip(top_pack, [IPTester(params=v) for v in packages])) | |||
|
60 | runners['trial'] = IPTester('trial',['IPython']) | |||
|
61 | ||||
|
62 | return runners | |||
|
63 | ||||
|
64 | ||||
|
65 | def main(): | |||
|
66 | runners = make_runners() | |||
|
67 | # Run all test runners, tracking execution time | |||
|
68 | failed = {} | |||
|
69 | t_start = time.time() | |||
|
70 | for name,runner in runners.iteritems(): | |||
|
71 | print '*'*77 | |||
|
72 | print 'IPython test set:',name | |||
|
73 | res = runner.run() | |||
|
74 | if res: | |||
|
75 | failed[name] = res | |||
|
76 | t_end = time.time() | |||
|
77 | t_tests = t_end - t_start | |||
|
78 | nrunners = len(runners) | |||
|
79 | nfail = len(failed) | |||
|
80 | # summarize results | |||
|
81 | ||||
|
82 | print '*'*77 | |||
|
83 | print 'Ran %s test sets in %.3fs' % (nrunners, t_tests) | |||
|
84 | ||||
|
85 | if not failed: | |||
|
86 | print 'OK' | |||
|
87 | else: | |||
|
88 | # If anything went wrong, point out what command to rerun manually to | |||
|
89 | # see the actual errors and individual summary | |||
|
90 | print 'ERROR - %s out of %s test sets failed.' % (nfail, nrunners) | |||
|
91 | for name in failed: | |||
|
92 | failed_runner = runners[name] | |||
|
93 | print '-'*40 | |||
|
94 | print 'Runner failed:',name | |||
|
95 | print 'You may wish to rerun this one individually, with:' | |||
|
96 | print ' '.join(failed_runner.call_args) | |||
|
97 | ||||
|
98 | ||||
|
99 | ||||
|
100 | if __name__ == '__main__': | |||
|
101 | main() |
General Comments 0
You need to be logged in to leave comments.
Login now