##// END OF EJS Templates
Merge pull request #2238 from takluyver/fasttest...
Bussonnier Matthias -
r8131:ecae5d1b merge
parent child Browse files
Show More
@@ -13,7 +13,7 b''
13 13 #-----------------------------------------------------------------------------
14 14
15 15 # User-level entry point for testing
16 def test():
16 def test(all=False):
17 17 """Run the entire IPython test suite.
18 18
19 19 For fine-grained control, you should use the :file:`iptest` script supplied
@@ -22,7 +22,7 b' def test():'
22 22 # Do the import internally, so that this function doesn't increase total
23 23 # import time
24 24 from iptest import run_iptestall
25 run_iptestall()
25 run_iptestall(inc_slow=all)
26 26
27 27 # So nose doesn't try to run this as a test itself and we end up with an
28 28 # infinite test loop
@@ -420,7 +420,7 b' class IPTester(object):'
420 420 print('... failed. Manual cleanup may be required.'
421 421 % subp.pid)
422 422
423 def make_runners():
423 def make_runners(inc_slow=False):
424 424 """Define the top-level packages that need to be tested.
425 425 """
426 426
@@ -430,6 +430,7 b' def make_runners():'
430 430
431 431 if have['zmq']:
432 432 nose_pkg_names.append('zmq')
433 if inc_slow:
433 434 nose_pkg_names.append('parallel')
434 435
435 436 # For debugging this code, only load quick stuff
@@ -492,16 +493,23 b' def run_iptest():'
492 493 TestProgram(argv=argv, addplugins=plugins)
493 494
494 495
495 def run_iptestall():
496 def run_iptestall(inc_slow=False):
496 497 """Run the entire IPython test suite by calling nose and trial.
497 498
498 499 This function constructs :class:`IPTester` instances for all IPython
499 500 modules and package and then runs each of them. This causes the modules
500 501 and packages of IPython to be tested each in their own subprocess using
501 502 nose.
503
504 Parameters
505 ----------
506
507 inc_slow : bool, optional
508 Include slow tests, like IPython.parallel. By default, these tests aren't
509 run.
502 510 """
503 511
504 runners = make_runners()
512 runners = make_runners(inc_slow=inc_slow)
505 513
506 514 # Run the test runners in a temporary dir so we can nuke it when finished
507 515 # to clean up any junk files left over by accident. This also makes it
@@ -558,8 +566,13 b' def main():'
558 566 # This is in-process
559 567 run_iptest()
560 568 else:
569 if "--all" in sys.argv:
570 sys.argv.remove("--all")
571 inc_slow = True
572 else:
573 inc_slow = False
561 574 # This starts subprocesses
562 run_iptestall()
575 run_iptestall(inc_slow=inc_slow)
563 576
564 577
565 578 if __name__ == '__main__':
@@ -41,10 +41,11 b' def get_missing_libraries(log):'
41 41 return m.group(1)
42 42
43 43 class TestRun(object):
44 def __init__(self, pr_num):
44 def __init__(self, pr_num, extra_args):
45 45 self.unavailable_pythons = []
46 46 self.venvs = []
47 47 self.pr_num = pr_num
48 self.extra_args = extra_args
48 49
49 50 self.pr = gh_api.get_pull_request(gh_project, pr_num)
50 51
@@ -131,8 +132,10 b' class TestRun(object):'
131 132 "Platform: " + sys.platform,
132 133 ""] + \
133 134 [format_result(r) for r in self.results] + \
134 ["",
135 "Not available for testing: " + ", ".join(self.unavailable_pythons)]
135 [""]
136 if self.extra_args:
137 lines.append("Extra args: %r" % self.extra_args),
138 lines.append("Not available for testing: " + ", ".join(self.unavailable_pythons))
136 139 return "\n".join(lines)
137 140
138 141 def post_results_comment(self):
@@ -156,6 +159,9 b' class TestRun(object):'
156 159 print(" Test log:", result.get('log_url') or result.log_file)
157 160 if result.missing_libraries:
158 161 print(" Libraries not available:", result.missing_libraries)
162
163 if self.extra_args:
164 print("Extra args:", self.extra_args)
159 165 print("Not available for testing:", ", ".join(self.unavailable_pythons))
160 166
161 167 def dump_results(self):
@@ -187,7 +193,7 b' class TestRun(object):'
187 193 def run(self):
188 194 for py, venv in self.venvs:
189 195 tic = time.time()
190 passed, log = run_tests(venv)
196 passed, log = run_tests(venv, self.extra_args)
191 197 elapsed = int(time.time() - tic)
192 198 print("Ran tests with %s in %is" % (py, elapsed))
193 199 missing_libraries = get_missing_libraries(log)
@@ -200,7 +206,7 b' class TestRun(object):'
200 206 )
201 207
202 208
203 def run_tests(venv):
209 def run_tests(venv, extra_args):
204 210 py = os.path.join(basedir, venv, 'bin', 'python')
205 211 print(py)
206 212 os.chdir(repodir)
@@ -226,8 +232,8 b' def run_tests(venv):'
226 232 ipython_file = check_output([py, '-c', 'import IPython; print (IPython.__file__)'])
227 233 ipython_file = ipython_file.strip().decode('utf-8')
228 234 if not ipython_file.startswith(os.path.join(basedir, venv)):
229 msg = u"IPython does not appear to be in the venv: %s" % ipython_file
230 msg += u"\nDo you use setupegg.py develop?"
235 msg = "IPython does not appear to be in the venv: %s" % ipython_file
236 msg += "\nDo you use setupegg.py develop?"
231 237 print(msg, file=sys.stderr)
232 238 return False, msg
233 239
@@ -237,7 +243,7 b' def run_tests(venv):'
237 243
238 244 print("\nRunning tests, this typically takes a few minutes...")
239 245 try:
240 return True, check_output([iptest], stderr=STDOUT).decode('utf-8')
246 return True, check_output([iptest] + extra_args, stderr=STDOUT).decode('utf-8')
241 247 except CalledProcessError as e:
242 248 return False, e.output.decode('utf-8')
243 249 finally:
@@ -245,13 +251,13 b' def run_tests(venv):'
245 251 os.environ["PATH"] = orig_path
246 252
247 253
248 def test_pr(num, post_results=True):
254 def test_pr(num, post_results=True, extra_args=None):
249 255 # Get Github authorisation first, so that the user is prompted straight away
250 256 # if their login is needed.
251 257 if post_results:
252 258 gh_api.get_auth_token()
253 259
254 testrun = TestRun(num)
260 testrun = TestRun(num, extra_args or [])
255 261
256 262 testrun.get_branch()
257 263
@@ -278,5 +284,5 b" if __name__ == '__main__':"
278 284 help="Publish the results to Github")
279 285 parser.add_argument('number', type=int, help="The pull request number")
280 286
281 args = parser.parse_args()
282 test_pr(args.number, post_results=args.publish)
287 args, extra_args = parser.parse_known_args()
288 test_pr(args.number, post_results=args.publish, extra_args=extra_args)
General Comments 0
You need to be logged in to leave comments. Login now