Show More
@@ -16,8 +16,6 b' For now, this script requires that both nose and twisted are installed. This' | |||||
16 | will change in the future. |
|
16 | will change in the future. | |
17 | """ |
|
17 | """ | |
18 |
|
18 | |||
19 | from __future__ import absolute_import |
|
|||
20 |
|
||||
21 | #----------------------------------------------------------------------------- |
|
19 | #----------------------------------------------------------------------------- | |
22 | # Module imports |
|
20 | # Module imports | |
23 | #----------------------------------------------------------------------------- |
|
21 | #----------------------------------------------------------------------------- | |
@@ -36,7 +34,7 b' import warnings' | |||||
36 | # We need to monkeypatch a small problem in nose itself first, before importing |
|
34 | # We need to monkeypatch a small problem in nose itself first, before importing | |
37 | # it for actual use. This should get into nose upstream, but its release cycle |
|
35 | # it for actual use. This should get into nose upstream, but its release cycle | |
38 | # is slow and we need it for our parametric tests to work correctly. |
|
36 | # is slow and we need it for our parametric tests to work correctly. | |
39 | from . import nosepatch |
|
37 | from IPython.testing import nosepatch | |
40 | # Now, proceed to import nose itself |
|
38 | # Now, proceed to import nose itself | |
41 | import nose.plugins.builtin |
|
39 | import nose.plugins.builtin | |
42 | from nose.core import TestProgram |
|
40 | from nose.core import TestProgram | |
@@ -44,9 +42,9 b' from nose.core import TestProgram' | |||||
44 | # Our own imports |
|
42 | # Our own imports | |
45 | from IPython.utils import genutils |
|
43 | from IPython.utils import genutils | |
46 | from IPython.utils.platutils import find_cmd, FindCmdError |
|
44 | from IPython.utils.platutils import find_cmd, FindCmdError | |
47 | from . import globalipapp |
|
45 | from IPython.testing import globalipapp | |
48 | from . import tools |
|
46 | from IPython.testing import tools | |
49 | from .plugin.ipdoctest import IPythonDoctest |
|
47 | from IPython.testing.plugin.ipdoctest import IPythonDoctest | |
50 |
|
48 | |||
51 | pjoin = path.join |
|
49 | pjoin = path.join | |
52 |
|
50 | |||
@@ -192,16 +190,10 b' class IPTester(object):' | |||||
192 | def __init__(self,runner='iptest',params=None): |
|
190 | def __init__(self, runner='iptest', params=None): | |
193 | """Create new test runner.""" |
|
191 | """Create new test runner.""" | |
194 | if runner == 'iptest': |
|
192 | if runner == 'iptest': | |
195 | # Find our own 'iptest' script OS-level entry point |
|
193 | # Find our own 'iptest' script OS-level entry point. Don't look | |
196 | try: |
|
194 | # system-wide, so we are sure we pick up *this one*. And pass | |
197 | iptest_path = os.path.abspath(find_cmd('iptest')) |
|
195 | # through to subprocess call our own sys.argv | |
198 | except FindCmdError: |
|
196 | self.runner = tools.cmd2argv(__file__) + sys.argv[1:] | |
199 | # Script not installed (may be the case for testing situations |
|
|||
200 | # that are running from a source tree only), pull from internal |
|
|||
201 | # path: |
|
|||
202 | pak_dir = os.path.abspath(genutils.get_ipython_package_dir()) |
|
|||
203 | iptest_path = pjoin(pak_dir, 'scripts', 'iptest') |
|
|||
204 | self.runner = tools.cmd2argv(iptest_path) + ['-v'] |
|
|||
205 | else: |
|
197 | else: | |
206 | self.runner = tools.cmd2argv(os.path.abspath(find_cmd('trial'))) |
|
198 | self.runner = tools.cmd2argv(os.path.abspath(find_cmd('trial'))) | |
207 | if params is None: |
|
199 | if params is None: | |
@@ -272,12 +264,13 b' def make_runners():' | |||||
272 | # is twisted-based, because nose picks up doctests that |
|
264 | # is twisted-based, because nose picks up doctests that | |
273 | # twisted doesn't. |
|
265 | # twisted doesn't. | |
274 | 'kernel'] |
|
266 | 'kernel'] | |
|
267 | # The machinery in kernel needs twisted for real testing | |||
275 | trial_packages = ['kernel'] |
|
268 | trial_packages = ['kernel'] | |
276 |
|
269 | |||
277 | if have_wx: |
|
270 | if have_wx: | |
278 | nose_packages.append('gui') |
|
271 | nose_packages.append('gui') | |
279 |
|
272 | |||
280 |
#nose_packages = ['co |
|
273 | #nose_packages = ['config', 'utils'] # dbg | |
281 | #trial_packages = [] # dbg |
|
274 | #trial_packages = [] # dbg | |
282 |
|
275 | |||
283 | nose_packages = ['IPython.%s' % m for m in nose_packages ] |
|
276 | nose_packages = ['IPython.%s' % m for m in nose_packages ] | |
@@ -285,11 +278,12 b' def make_runners():' | |||||
285 |
|
278 | |||
286 | # Make runners, most with nose |
|
279 | # Make runners, most with nose | |
287 | nose_testers = [IPTester(params=v) for v in nose_packages] |
|
280 | nose_testers = [IPTester(params=v) for v in nose_packages] | |
288 |
runners = |
|
281 | runners = zip(nose_packages, nose_testers) | |
|
282 | ||||
289 | # And add twisted ones if conditions are met |
|
283 | # And add twisted ones if conditions are met | |
290 | if have_zi and have_twisted and have_foolscap: |
|
284 | if have_zi and have_twisted and have_foolscap: | |
291 | trial_testers = [IPTester('trial',params=v) for v in trial_packages] |
|
285 | trial_testers = [IPTester('trial', params=v) for v in trial_packages] | |
292 |
runners. |
|
286 | runners.extend(zip(trial_packages, trial_testers)) | |
293 |
|
287 | |||
294 | return runners |
|
288 | return runners | |
295 |
|
289 | |||
@@ -312,8 +306,6 b' def run_iptest():' | |||||
312 | '--with-ipdoctest', |
|
306 | '--with-ipdoctest', | |
313 | '--ipdoctest-tests','--ipdoctest-extension=txt', |
|
307 | '--ipdoctest-tests','--ipdoctest-extension=txt', | |
314 |
|
308 | |||
315 | #'-x','-s', # dbg |
|
|||
316 |
|
||||
317 | # We add --exe because of setuptools' imbecility (it |
|
309 | # We add --exe because of setuptools' imbecility (it | |
318 | # blindly does chmod +x on ALL files). Nose does the |
|
310 | # blindly does chmod +x on ALL files). Nose does the | |
319 | # right thing and it tries to avoid executables, |
|
311 | # right thing and it tries to avoid executables, | |
@@ -323,21 +315,9 b' def run_iptest():' | |||||
323 | '--exe', |
|
315 | '--exe', | |
324 | ] |
|
316 | ] | |
325 |
|
317 | |||
326 | # Detect if any tests were required by explicitly calling an IPython |
|
318 | ||
327 | # submodule or giving a specific path |
|
319 | # Construct list of plugins, omitting the existing doctest plugin, which | |
328 | has_tests = False |
|
320 | # ours replaces (and extends). | |
329 | for arg in sys.argv: |
|
|||
330 | if 'IPython' in arg or arg.endswith('.py') or \ |
|
|||
331 | (':' in arg and '.py' in arg): |
|
|||
332 | has_tests = True |
|
|||
333 | break |
|
|||
334 |
|
||||
335 | # If nothing was specifically requested, test full IPython |
|
|||
336 | if not has_tests: |
|
|||
337 | argv.append('IPython') |
|
|||
338 |
|
||||
339 | ## # Construct list of plugins, omitting the existing doctest plugin, which |
|
|||
340 | ## # ours replaces (and extends). |
|
|||
341 | plugins = [IPythonDoctest(make_exclude())] |
|
321 | plugins = [IPythonDoctest(make_exclude())] | |
342 | for p in nose.plugins.builtin.plugins: |
|
322 | for p in nose.plugins.builtin.plugins: | |
343 | plug = p() |
|
323 | plug = p() | |
@@ -371,15 +351,15 b' def run_iptestall():' | |||||
371 | os.chdir(testdir) |
|
351 | os.chdir(testdir) | |
372 |
|
352 | |||
373 | # Run all test runners, tracking execution time |
|
353 | # Run all test runners, tracking execution time | |
374 |
failed = |
|
354 | failed = [] | |
375 | t_start = time.time() |
|
355 | t_start = time.time() | |
376 | try: |
|
356 | try: | |
377 |
for name,runner in runners |
|
357 | for (name, runner) in runners: | |
378 |
print '*'*7 |
|
358 | print '*'*70 | |
379 | print 'IPython test group:',name |
|
359 | print 'IPython test group:',name | |
380 | res = runner.run() |
|
360 | res = runner.run() | |
381 | if res: |
|
361 | if res: | |
382 |
failed |
|
362 | failed.append( (name, runner) ) | |
383 | finally: |
|
363 | finally: | |
384 | os.chdir(curdir) |
|
364 | os.chdir(curdir) | |
385 | t_end = time.time() |
|
365 | t_end = time.time() | |
@@ -388,7 +368,7 b' def run_iptestall():' | |||||
388 | nfail = len(failed) |
|
368 | nfail = len(failed) | |
389 | # summarize results |
|
369 | # summarize results | |
390 |
|
370 | |||
391 |
print '*'*7 |
|
371 | print '*'*70 | |
392 | print 'Ran %s test groups in %.3fs' % (nrunners, t_tests) |
|
372 | print 'Ran %s test groups in %.3fs' % (nrunners, t_tests) | |
393 |
|
373 | |||
394 | if not failed: |
|
374 | if not failed: | |
@@ -397,8 +377,7 b' def run_iptestall():' | |||||
397 | # If anything went wrong, point out what command to rerun manually to |
|
377 | # If anything went wrong, point out what command to rerun manually to | |
398 | # see the actual errors and individual summary |
|
378 | # see the actual errors and individual summary | |
399 | print 'ERROR - %s out of %s test groups failed.' % (nfail, nrunners) |
|
379 | print 'ERROR - %s out of %s test groups failed.' % (nfail, nrunners) | |
400 | for name in failed: |
|
380 | for name, failed_runner in failed: | |
401 | failed_runner = runners[name] |
|
|||
402 | print '-'*40 |
|
381 | print '-'*40 | |
403 | print 'Runner failed:',name |
|
382 | print 'Runner failed:',name | |
404 | print 'You may wish to rerun this one individually, with:' |
|
383 | print 'You may wish to rerun this one individually, with:' | |
@@ -407,13 +386,11 b' def run_iptestall():' | |||||
407 |
|
386 | |||
408 |
|
387 | |||
409 | def main(): |
|
388 | def main(): | |
410 | if len(sys.argv) == 1: |
|
389 | for arg in sys.argv[1:]: | |
411 | run_iptestall() |
|
390 | if arg.startswith('IPython'): | |
|
391 | run_iptest() | |||
412 | else: |
|
392 | else: | |
413 | if sys.argv[1] == 'all': |
|
|||
414 |
|
|
393 | run_iptestall() | |
415 | else: |
|
|||
416 | run_iptest() |
|
|||
417 |
|
394 | |||
418 |
|
395 | |||
419 | if __name__ == '__main__': |
|
396 | if __name__ == '__main__': |
General Comments 0
You need to be logged in to leave comments.
Login now