|
|
|
|
@ -36,6 +36,7 @@ import subprocess
|
|
|
|
|
import tempfile
|
|
|
|
|
import time
|
|
|
|
|
import warnings
|
|
|
|
|
import multiprocessing.pool
|
|
|
|
|
|
|
|
|
|
# Now, proceed to import nose itself
|
|
|
|
|
import nose.plugins.builtin
|
|
|
|
|
@ -336,6 +337,7 @@ class IPTester(object):
|
|
|
|
|
processes = None
|
|
|
|
|
#: str, coverage xml output file
|
|
|
|
|
coverage_xml = None
|
|
|
|
|
buffer_output = False
|
|
|
|
|
|
|
|
|
|
def __init__(self, runner='iptest', params=None):
|
|
|
|
|
"""Create new test runner."""
|
|
|
|
|
@ -382,13 +384,17 @@ class IPTester(object):
|
|
|
|
|
env = os.environ.copy()
|
|
|
|
|
env['IPYTHONDIR'] = IPYTHONDIR
|
|
|
|
|
# print >> sys.stderr, '*** CMD:', ' '.join(self.call_args) # dbg
|
|
|
|
|
subp = subprocess.Popen(self.call_args, env=env)
|
|
|
|
|
output = subprocess.PIPE if self.buffer_output else None
|
|
|
|
|
subp = subprocess.Popen(self.call_args, stdout=output,
|
|
|
|
|
stderr=output, env=env)
|
|
|
|
|
self.processes.append(subp)
|
|
|
|
|
# If this fails, the process will be left in self.processes and
|
|
|
|
|
# cleaned up later, but if the wait call succeeds, then we can
|
|
|
|
|
# clear the stored process.
|
|
|
|
|
retcode = subp.wait()
|
|
|
|
|
self.processes.pop()
|
|
|
|
|
self.stdout = subp.stdout
|
|
|
|
|
self.stderr = subp.stderr
|
|
|
|
|
return retcode
|
|
|
|
|
|
|
|
|
|
def run(self):
|
|
|
|
|
@ -450,10 +456,10 @@ def make_runners(inc_slow=False):
|
|
|
|
|
nose_pkg_names.append('html')
|
|
|
|
|
|
|
|
|
|
if have['zmq']:
|
|
|
|
|
nose_pkg_names.append('kernel')
|
|
|
|
|
nose_pkg_names.append('kernel.inprocess')
|
|
|
|
|
nose_pkg_names.insert(0, 'kernel')
|
|
|
|
|
nose_pkg_names.insert(1, 'kernel.inprocess')
|
|
|
|
|
if inc_slow:
|
|
|
|
|
nose_pkg_names.append('parallel')
|
|
|
|
|
nose_pkg_names.insert(0, 'parallel')
|
|
|
|
|
|
|
|
|
|
if all((have['pygments'], have['jinja2'], have['sphinx'])):
|
|
|
|
|
nose_pkg_names.append('nbconvert')
|
|
|
|
|
@ -538,8 +544,12 @@ def run_iptest():
|
|
|
|
|
# Now nose can run
|
|
|
|
|
TestProgram(argv=argv, addplugins=plugins)
|
|
|
|
|
|
|
|
|
|
def do_run(x):
|
|
|
|
|
print('IPython test group:',x[0])
|
|
|
|
|
ret = x[1].run()
|
|
|
|
|
return ret
|
|
|
|
|
|
|
|
|
|
def run_iptestall(inc_slow=False):
|
|
|
|
|
def run_iptestall(inc_slow=False, fast=False):
|
|
|
|
|
"""Run the entire IPython test suite by calling nose and trial.
|
|
|
|
|
|
|
|
|
|
This function constructs :class:`IPTester` instances for all IPython
|
|
|
|
|
@ -553,7 +563,15 @@ def run_iptestall(inc_slow=False):
|
|
|
|
|
inc_slow : bool, optional
|
|
|
|
|
Include slow tests, like IPython.parallel. By default, these tests aren't
|
|
|
|
|
run.
|
|
|
|
|
|
|
|
|
|
fast : bool, option
|
|
|
|
|
Run the test suite in parallel, if True, using as many threads as there
|
|
|
|
|
are processors
|
|
|
|
|
"""
|
|
|
|
|
if fast:
|
|
|
|
|
p = multiprocessing.pool.ThreadPool()
|
|
|
|
|
else:
|
|
|
|
|
p = multiprocessing.pool.ThreadPool(1)
|
|
|
|
|
|
|
|
|
|
runners = make_runners(inc_slow=inc_slow)
|
|
|
|
|
|
|
|
|
|
@ -568,11 +586,15 @@ def run_iptestall(inc_slow=False):
|
|
|
|
|
# Run all test runners, tracking execution time
|
|
|
|
|
failed = []
|
|
|
|
|
t_start = time.time()
|
|
|
|
|
|
|
|
|
|
try:
|
|
|
|
|
for (name, runner) in runners:
|
|
|
|
|
print('*'*70)
|
|
|
|
|
print('IPython test group:',name)
|
|
|
|
|
res = runner.run()
|
|
|
|
|
all_res = p.map(do_run, runners)
|
|
|
|
|
print('*'*70)
|
|
|
|
|
for ((name, runner), res) in zip(runners, all_res):
|
|
|
|
|
tgroup = 'IPython test group: ' + name
|
|
|
|
|
res_string = 'OK' if res == 0 else 'FAILED'
|
|
|
|
|
res_string = res_string.rjust(70 - len(tgroup), '.')
|
|
|
|
|
print(tgroup + res_string)
|
|
|
|
|
if res:
|
|
|
|
|
failed.append( (name, runner) )
|
|
|
|
|
if res == -signal.SIGINT:
|
|
|
|
|
@ -615,13 +637,17 @@ def main():
|
|
|
|
|
# This is in-process
|
|
|
|
|
run_iptest()
|
|
|
|
|
else:
|
|
|
|
|
if "--all" in sys.argv:
|
|
|
|
|
inc_slow = "--all" in sys.argv
|
|
|
|
|
if inc_slow:
|
|
|
|
|
sys.argv.remove("--all")
|
|
|
|
|
inc_slow = True
|
|
|
|
|
else:
|
|
|
|
|
inc_slow = False
|
|
|
|
|
|
|
|
|
|
fast = "--fast" in sys.argv
|
|
|
|
|
if fast:
|
|
|
|
|
sys.argv.remove("--fast")
|
|
|
|
|
IPTester.buffer_output = True
|
|
|
|
|
|
|
|
|
|
# This starts subprocesses
|
|
|
|
|
run_iptestall(inc_slow=inc_slow)
|
|
|
|
|
run_iptestall(inc_slow=inc_slow, fast=fast)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if __name__ == '__main__':
|
|
|
|
|
|