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