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