##// END OF EJS Templates
run test in parallel (FASTER)
Paul Ivanov -
Show More
@@ -36,6 +36,7 b' import subprocess'
36 import tempfile
36 import tempfile
37 import time
37 import time
38 import warnings
38 import warnings
39 import multiprocessing.pool
39
40
40 # Now, proceed to import nose itself
41 # Now, proceed to import nose itself
41 import nose.plugins.builtin
42 import nose.plugins.builtin
@@ -382,19 +383,25 b' class IPTester(object):'
382 env = os.environ.copy()
383 env = os.environ.copy()
383 env['IPYTHONDIR'] = IPYTHONDIR
384 env['IPYTHONDIR'] = IPYTHONDIR
384 # print >> sys.stderr, '*** CMD:', ' '.join(self.call_args) # dbg
385 # print >> sys.stderr, '*** CMD:', ' '.join(self.call_args) # dbg
385 subp = subprocess.Popen(self.call_args, env=env)
386 subp = subprocess.Popen(self.call_args, stdout=subprocess.PIPE,
387 stderr=subprocess.PIPE, env=env)
386 self.processes.append(subp)
388 self.processes.append(subp)
387 # If this fails, the process will be left in self.processes and
389 # If this fails, the process will be left in self.processes and
388 # cleaned up later, but if the wait call succeeds, then we can
390 # cleaned up later, but if the wait call succeeds, then we can
389 # clear the stored process.
391 # clear the stored process.
390 retcode = subp.wait()
392 retcode = subp.wait()
391 self.processes.pop()
393 self.processes.pop()
394 self.stdout = subp.stdout
395 self.stderr = subp.stderr
392 return retcode
396 return retcode
393
397
394 def run(self):
398 def run(self):
395 """Run the stored commands"""
399 """Run the stored commands"""
396 try:
400 try:
397 retcode = self._run_cmd()
401 retcode = self._run_cmd()
402 #print(self.stdout.read())
403 #print("std err")
404 #print(self.stderr.read())
398 except KeyboardInterrupt:
405 except KeyboardInterrupt:
399 return -signal.SIGINT
406 return -signal.SIGINT
400 except:
407 except:
@@ -450,8 +457,8 b' def make_runners(inc_slow=False):'
450 nose_pkg_names.append('html')
457 nose_pkg_names.append('html')
451
458
452 if have['zmq']:
459 if have['zmq']:
453 nose_pkg_names.append('kernel')
460 nose_pkg_names.insert(0, 'kernel')
454 nose_pkg_names.append('kernel.inprocess')
461 nose_pkg_names.insert(1, 'kernel.inprocess')
455 if inc_slow:
462 if inc_slow:
456 nose_pkg_names.append('parallel')
463 nose_pkg_names.append('parallel')
457
464
@@ -538,6 +545,15 b' def run_iptest():'
538 # Now nose can run
545 # Now nose can run
539 TestProgram(argv=argv, addplugins=plugins)
546 TestProgram(argv=argv, addplugins=plugins)
540
547
548 def do_run(x):
549 print('IPython test group:',x[0])
550 #if x[0] == 'IPython.kernel':
551 # import os
552 # os.environ['NOSE_PROCESS_TIMEOUT'] = '20'
553 # os.environ['NOSE_PROCESSES'] = '2'
554 ret = x[1].run()
555 print('finished test group:',x[0])
556 return ret
541
557
542 def run_iptestall(inc_slow=False):
558 def run_iptestall(inc_slow=False):
543 """Run the entire IPython test suite by calling nose and trial.
559 """Run the entire IPython test suite by calling nose and trial.
@@ -554,6 +570,7 b' def run_iptestall(inc_slow=False):'
554 Include slow tests, like IPython.parallel. By default, these tests aren't
570 Include slow tests, like IPython.parallel. By default, these tests aren't
555 run.
571 run.
556 """
572 """
573 p = multiprocessing.pool.ThreadPool()
557
574
558 runners = make_runners(inc_slow=inc_slow)
575 runners = make_runners(inc_slow=inc_slow)
559
576
@@ -568,11 +585,18 b' def run_iptestall(inc_slow=False):'
568 # Run all test runners, tracking execution time
585 # Run all test runners, tracking execution time
569 failed = []
586 failed = []
570 t_start = time.time()
587 t_start = time.time()
588
589 #runners = runners[::-1]
590
591 print([r[0] for r in runners])
592
571 try:
593 try:
572 for (name, runner) in runners:
594
595 print(len(runners))
596 all_res = p.map(do_run, runners)
597 for ((name, runner), res) in zip(runners, all_res):
573 print('*'*70)
598 print('*'*70)
574 print('IPython test group:',name)
599 print('IPython test group:',name)
575 res = runner.run()
576 if res:
600 if res:
577 failed.append( (name, runner) )
601 failed.append( (name, runner) )
578 if res == -signal.SIGINT:
602 if res == -signal.SIGINT:
General Comments 0
You need to be logged in to leave comments. Login now