Show More
@@ -28,7 +28,6 import subprocess | |||||
28 | import time |
|
28 | import time | |
29 |
|
29 | |||
30 | from .iptest import have, test_group_names, test_sections |
|
30 | from .iptest import have, test_group_names, test_sections | |
31 | from IPython.utils import py3compat |
|
|||
32 | from IPython.utils.sysinfo import sys_info |
|
31 | from IPython.utils.sysinfo import sys_info | |
33 | from IPython.utils.tempdir import TemporaryDirectory |
|
32 | from IPython.utils.tempdir import TemporaryDirectory | |
34 |
|
33 | |||
@@ -67,6 +66,10 class IPTestController(object): | |||||
67 | # This means we won't get odd effects from our own matplotlib config |
|
66 | # This means we won't get odd effects from our own matplotlib config | |
68 | self.env['MPLCONFIGDIR'] = workingdir.name |
|
67 | self.env['MPLCONFIGDIR'] = workingdir.name | |
69 |
|
68 | |||
|
69 | @property | |||
|
70 | def will_run(self): | |||
|
71 | return test_sections[self.section].will_run | |||
|
72 | ||||
70 | def add_xunit(self): |
|
73 | def add_xunit(self): | |
71 | xunit_file = os.path.abspath(self.section + '.xunit.xml') |
|
74 | xunit_file = os.path.abspath(self.section + '.xunit.xml') | |
72 | self.cmd.extend(['--with-xunit', '--xunit-file', xunit_file]) |
|
75 | self.cmd.extend(['--with-xunit', '--xunit-file', xunit_file]) | |
@@ -133,21 +136,23 class IPTestController(object): | |||||
133 |
|
136 | |||
134 | __del__ = cleanup |
|
137 | __del__ = cleanup | |
135 |
|
138 | |||
136 |
def test_controllers |
|
139 | def prepare_test_controllers(inc_slow=False, xunit=False, coverage=False): | |
137 | """Returns an ordered list of IPTestController instances to be run.""" |
|
140 | """Returns an ordered list of IPTestController instances to be run.""" | |
138 | res = [] |
|
141 | to_run, not_run = [], [] | |
139 | if not inc_slow: |
|
142 | if not inc_slow: | |
140 | test_sections['parallel'].enabled = False |
|
143 | test_sections['parallel'].enabled = False | |
141 |
|
144 | |||
142 | for name in test_group_names: |
|
145 | for name in test_group_names: | |
143 | if test_sections[name].will_run: |
|
146 | controller = IPTestController(name) | |
144 | controller = IPTestController(name) |
|
147 | if xunit: | |
145 |
|
|
148 | controller.add_xunit() | |
146 | controller.add_xunit() |
|
149 | if coverage: | |
147 |
|
|
150 | controller.add_coverage() | |
148 |
|
|
151 | if controller.will_run: | |
149 |
|
|
152 | to_run.append(controller) | |
150 | return res |
|
153 | else: | |
|
154 | not_run.append(controller) | |||
|
155 | return to_run, not_run | |||
151 |
|
156 | |||
152 | def do_run(controller): |
|
157 | def do_run(controller): | |
153 | try: |
|
158 | try: | |
@@ -214,16 +219,21 def run_iptestall(inc_slow=False, jobs=1, xunit_out=False, coverage_out=False): | |||||
214 | if jobs != 1: |
|
219 | if jobs != 1: | |
215 | IPTestController.buffer_output = True |
|
220 | IPTestController.buffer_output = True | |
216 |
|
221 | |||
217 |
|
|
222 | to_run, not_run = prepare_test_controllers(inc_slow=inc_slow, xunit=xunit_out, | |
218 | coverage=coverage_out) |
|
223 | coverage=coverage_out) | |
219 |
|
224 | |||
|
225 | def justify(ltext, rtext, width=70, fill='-'): | |||
|
226 | ltext += ' ' | |||
|
227 | rtext = (' ' + rtext).rjust(width - len(ltext), fill) | |||
|
228 | return ltext + rtext | |||
|
229 | ||||
220 | # Run all test runners, tracking execution time |
|
230 | # Run all test runners, tracking execution time | |
221 | failed = [] |
|
231 | failed = [] | |
222 | t_start = time.time() |
|
232 | t_start = time.time() | |
223 |
|
233 | |||
224 | print('*'*70) |
|
234 | print('*'*70) | |
225 | if jobs == 1: |
|
235 | if jobs == 1: | |
226 |
for controller in |
|
236 | for controller in to_run: | |
227 | print('IPython test group:', controller.section) |
|
237 | print('IPython test group:', controller.section) | |
228 | controller, res = do_run(controller) |
|
238 | controller, res = do_run(controller) | |
229 | if res: |
|
239 | if res: | |
@@ -236,11 +246,9 def run_iptestall(inc_slow=False, jobs=1, xunit_out=False, coverage_out=False): | |||||
236 | else: |
|
246 | else: | |
237 | try: |
|
247 | try: | |
238 | pool = multiprocessing.pool.ThreadPool(jobs) |
|
248 | pool = multiprocessing.pool.ThreadPool(jobs) | |
239 |
for (controller, res) in pool.imap_unordered(do_run, |
|
249 | for (controller, res) in pool.imap_unordered(do_run, to_run): | |
240 | tgroup = 'IPython test group: ' + controller.section + ' ' |
|
250 | res_string = 'OK' if res == 0 else 'FAILED' | |
241 | res_string = ' OK' if res == 0 else ' FAILED' |
|
251 | print(justify('IPython test group: ' + controller.section, res_string)) | |
242 | res_string = res_string.rjust(70 - len(tgroup), '.') |
|
|||
243 | print(tgroup + res_string) |
|
|||
244 | if res: |
|
252 | if res: | |
245 | print(controller.stdout) |
|
253 | print(controller.stdout) | |
246 | failed.append(controller) |
|
254 | failed.append(controller) | |
@@ -250,9 +258,12 def run_iptestall(inc_slow=False, jobs=1, xunit_out=False, coverage_out=False): | |||||
250 | except KeyboardInterrupt: |
|
258 | except KeyboardInterrupt: | |
251 | return |
|
259 | return | |
252 |
|
260 | |||
|
261 | for controller in not_run: | |||
|
262 | print(justify('IPython test group: ' + controller.section, 'NOT RUN')) | |||
|
263 | ||||
253 | t_end = time.time() |
|
264 | t_end = time.time() | |
254 | t_tests = t_end - t_start |
|
265 | t_tests = t_end - t_start | |
255 |
nrunners = len( |
|
266 | nrunners = len(to_run) | |
256 | nfail = len(failed) |
|
267 | nfail = len(failed) | |
257 | # summarize results |
|
268 | # summarize results | |
258 | print('*'*70) |
|
269 | print('*'*70) |
General Comments 0
You need to be logged in to leave comments.
Login now