##// END OF EJS Templates
Robustness fixes in test suite machinery....
Fernando Perez -
Show More
@@ -13,7 +13,7 b' class C(object):'
13 13
14 14 def __del__(self):
15 15 print 'tclass.py: deleting object:',self.name
16
16 sys.stdout.flush()
17 17
18 18 try:
19 19 name = sys.argv[1]
@@ -28,3 +28,4 b' else:'
28 28 # This next print statement is NOT debugging, we're making the check on a
29 29 # completely separate process so we verify by capturing stdout:
30 30 print 'ARGV 1-:', sys.argv[1:]
31 sys.stdout.flush()
@@ -57,6 +57,18 b' from IPython.testing.plugin.ipdoctest import IPythonDoctest'
57 57
58 58 pjoin = path.join
59 59
60
61 #-----------------------------------------------------------------------------
62 # Globals
63 #-----------------------------------------------------------------------------
64
65 # By default, we assume IPython has been installed. But if the test suite is
66 # being run from a source tree that has NOT been installed yet, this flag can
67 # be set to False by the entry point scripts, to let us know that we must call
68 # the source tree versions of the scripts which manipulate sys.path instead of
69 # assuming that things exist system-wide.
70 INSTALLED = True
71
60 72 #-----------------------------------------------------------------------------
61 73 # Warnings control
62 74 #-----------------------------------------------------------------------------
@@ -88,7 +100,6 b' def test_for(mod):'
88 100 else:
89 101 return True
90 102
91
92 103 have_curses = test_for('_curses')
93 104 have_wx = test_for('wx')
94 105 have_wx_aui = test_for('wx.aui')
@@ -100,6 +111,9 b" have_pexpect = test_for('pexpect')"
100 111 have_gtk = test_for('gtk')
101 112 have_gobject = test_for('gobject')
102 113
114 #-----------------------------------------------------------------------------
115 # Functions and classes
116 #-----------------------------------------------------------------------------
103 117
104 118 def make_exclude():
105 119 """Make patterns of modules and packages to exclude from testing.
@@ -190,10 +204,6 b' def make_exclude():'
190 204 return exclusions
191 205
192 206
193 #-----------------------------------------------------------------------------
194 # Functions and classes
195 #-----------------------------------------------------------------------------
196
197 207 class IPTester(object):
198 208 """Call that calls iptest or trial in a subprocess.
199 209 """
@@ -208,14 +218,22 b' class IPTester(object):'
208 218
209 219 def __init__(self, runner='iptest', params=None):
210 220 """Create new test runner."""
221 p = os.path
211 222 if runner == 'iptest':
212 # Find our own 'iptest' script OS-level entry point. Don't look
213 # system-wide, so we are sure we pick up *this one*. And pass
214 # through to subprocess call our own sys.argv
215 self.runner = tools.cmd2argv(os.path.abspath(__file__)) + \
216 sys.argv[1:]
223 if INSTALLED:
224 self.runner = tools.cmd2argv(
225 p.abspath(find_cmd('iptest'))) + sys.argv[1:]
226 else:
227 # Find our own 'iptest' script OS-level entry point. Don't
228 # look system-wide, so we are sure we pick up *this one*. And
229 # pass through to subprocess call our own sys.argv
230 ippath = p.abspath(p.join(p.dirname(__file__),'..','..'))
231 script = p.join(ippath, 'iptest.py')
232 self.runner = tools.cmd2argv(script) + sys.argv[1:]
233
217 234 else:
218 self.runner = tools.cmd2argv(os.path.abspath(find_cmd('trial')))
235 # For trial, it needs to be installed system-wide
236 self.runner = tools.cmd2argv(p.abspath(find_cmd('trial')))
219 237 if params is None:
220 238 params = []
221 239 if isinstance(params, str):
@@ -296,7 +314,7 b' def make_runners():'
296 314 trial_pkg_names.append('kernel')
297 315
298 316 # For debugging this code, only load quick stuff
299 #nose_pkg_names = ['core'] # dbg
317 #nose_pkg_names = ['core', 'extensions'] # dbg
300 318 #trial_pkg_names = [] # dbg
301 319
302 320 # Make fully qualified package names prepending 'IPython.' to our name lists
@@ -322,19 +340,7 b' def run_iptest():'
322 340 'This will be removed soon. Use IPython.testing.util instead')
323 341
324 342 argv = sys.argv + [ '--detailed-errors', # extra info in tracebacks
325
326 # I don't fully understand why we need this one, but
327 # depending on what directory the test suite is run
328 # from, if we don't give it, 0 tests get run.
329 # Specifically, if the test suite is run from the
330 # source dir with an argument (like 'iptest.py
331 # IPython.core', 0 tests are run, even if the same call
332 # done in this directory works fine). It appears that
333 # if the requested package is in the current dir,
334 # nose bails early by default. Since it's otherwise
335 # harmless, leave it in by default.
336 '--traverse-namespace',
337
343
338 344 # Loading ipdoctest causes problems with Twisted, but
339 345 # our test suite runner now separates things and runs
340 346 # all Twisted tests with trial.
@@ -350,6 +356,16 b' def run_iptest():'
350 356 '--exe',
351 357 ]
352 358
359 if nose.__version__ >= '0.11':
360 # I don't fully understand why we need this one, but depending on what
361 # directory the test suite is run from, if we don't give it, 0 tests
362 # get run. Specifically, if the test suite is run from the source dir
363 # with an argument (like 'iptest.py IPython.core', 0 tests are run,
364 # even if the same call done in this directory works fine). It appears
365 # that if the requested package is in the current dir, nose bails early
366 # by default. Since it's otherwise harmless, leave it in by default
367 # for nose >= 0.11, though unfortunately nose 0.10 doesn't support it.
368 argv.append('--traverse-namespace')
353 369
354 370 # Construct list of plugins, omitting the existing doctest plugin, which
355 371 # ours replaces (and extends).
@@ -49,6 +49,13 b' from . import decorators as dec'
49 49 # Globals
50 50 #-----------------------------------------------------------------------------
51 51
52 # By default, we assume IPython has been installed. But if the test suite is
53 # being run from a source tree that has NOT been installed yet, this flag can
54 # be set to False by the entry point scripts, to let us know that we must call
55 # the source tree versions of the scripts which manipulate sys.path instead of
56 # assuming that things exist system-wide.
57 INSTALLED = True
58
52 59 # Make a bunch of nose.tools assert wrappers that can be used in test
53 60 # generators. This will expose an assert* function for each one in nose.tools.
54 61
@@ -248,16 +255,20 b' def ipexec(fname, options=None):'
248 255 # Find the ipython script from the package we're using, so that the test
249 256 # suite can be run from the source tree without an installed IPython
250 257 p = os.path
251 ippath = p.abspath(p.join(p.dirname(__file__),'..','..'))
252 ipython_script = p.join(ippath, 'ipython.py')
253 ipython_cmd = 'python "%s"' % ipython_script
258 if INSTALLED:
259 ipython_cmd = platutils.find_cmd('ipython')
260 else:
261 ippath = p.abspath(p.join(p.dirname(__file__),'..','..'))
262 ipython_script = p.join(ippath, 'ipython.py')
263 ipython_cmd = 'python "%s"' % ipython_script
254 264 # Absolute path for filename
255 265 full_fname = p.join(test_dir, fname)
256 full_cmd = '%s %s "%s"' % (ipython_cmd, cmdargs, full_fname)
266 full_cmd = '%s %s %s' % (ipython_cmd, cmdargs, full_fname)
267 #print >> sys.stderr, 'FULL CMD:', full_cmd # dbg
257 268 return genutils.getoutputerror(full_cmd)
258 269
259 270
260 def ipexec_validate(fname, expected_out, expected_err=None,
271 def ipexec_validate(fname, expected_out, expected_err='',
261 272 options=None):
262 273 """Utility to call 'ipython filename' and validate output/error.
263 274
@@ -287,9 +298,18 b' def ipexec_validate(fname, expected_out, expected_err=None,'
287 298 import nose.tools as nt
288 299
289 300 out, err = ipexec(fname)
301 #print 'OUT', out # dbg
302 #print 'ERR', err # dbg
303 # If there are any errors, we must check those befor stdout, as they may be
304 # more informative than simply having an empty stdout.
305 if err:
306 if expected_err:
307 nt.assert_equals(err.strip(), expected_err.strip())
308 else:
309 raise ValueError('Running file %r produced error: %r' %
310 (fname, err))
311 # If no errors or output on stderr was expected, match stdout
290 312 nt.assert_equals(out.strip(), expected_out.strip())
291 if expected_err:
292 nt.assert_equals(err.strip(), expected_err.strip())
293 313
294 314
295 315 class TempFileMixin(object):
@@ -17,5 +17,10 b' import os, sys'
17 17 this_dir = os.path.dirname(os.path.abspath(__file__))
18 18 sys.path.insert(0, this_dir)
19 19
20 import IPython.testing.tools as t
21 import IPython.testing.iptest as ipt
22 t.INSTALLED = False
23 ipt.INSTALLED = False
24
20 25 # Now proceed with execution
21 26 execfile(os.path.join(this_dir, 'IPython', 'scripts', 'iptest'))
General Comments 0
You need to be logged in to leave comments. Login now