diff --git a/IPython/testing/__init__.py b/IPython/testing/__init__.py index 64cf23c..16601c0 100644 --- a/IPython/testing/__init__.py +++ b/IPython/testing/__init__.py @@ -13,7 +13,7 @@ #----------------------------------------------------------------------------- # User-level entry point for testing -def test(): +def test(all=False): """Run the entire IPython test suite. For fine-grained control, you should use the :file:`iptest` script supplied @@ -22,7 +22,7 @@ def test(): # Do the import internally, so that this function doesn't increase total # import time from iptest import run_iptestall - run_iptestall() + run_iptestall(inc_slow=all) # So nose doesn't try to run this as a test itself and we end up with an # infinite test loop diff --git a/IPython/testing/iptest.py b/IPython/testing/iptest.py index 593a713..fd305cc 100644 --- a/IPython/testing/iptest.py +++ b/IPython/testing/iptest.py @@ -420,7 +420,7 @@ class IPTester(object): print('... failed. Manual cleanup may be required.' % subp.pid) -def make_runners(): +def make_runners(inc_slow=False): """Define the top-level packages that need to be tested. """ @@ -430,7 +430,8 @@ def make_runners(): if have['zmq']: nose_pkg_names.append('zmq') - nose_pkg_names.append('parallel') + if inc_slow: + nose_pkg_names.append('parallel') # For debugging this code, only load quick stuff #nose_pkg_names = ['core', 'extensions'] # dbg @@ -492,16 +493,23 @@ def run_iptest(): TestProgram(argv=argv, addplugins=plugins) -def run_iptestall(): +def run_iptestall(inc_slow=False): """Run the entire IPython test suite by calling nose and trial. This function constructs :class:`IPTester` instances for all IPython modules and package and then runs each of them. This causes the modules and packages of IPython to be tested each in their own subprocess using nose. + + Parameters + ---------- + + inc_slow : bool, optional + Include slow tests, like IPython.parallel. By default, these tests aren't + run. """ - runners = make_runners() + runners = make_runners(inc_slow=inc_slow) # Run the test runners in a temporary dir so we can nuke it when finished # to clean up any junk files left over by accident. This also makes it @@ -558,8 +566,13 @@ def main(): # This is in-process run_iptest() else: + if "--all" in sys.argv: + sys.argv.remove("--all") + inc_slow = True + else: + inc_slow = False # This starts subprocesses - run_iptestall() + run_iptestall(inc_slow=inc_slow) if __name__ == '__main__': diff --git a/tools/test_pr.py b/tools/test_pr.py index 4ee9717..fd56370 100755 --- a/tools/test_pr.py +++ b/tools/test_pr.py @@ -41,10 +41,11 @@ def get_missing_libraries(log): return m.group(1) class TestRun(object): - def __init__(self, pr_num): + def __init__(self, pr_num, extra_args): self.unavailable_pythons = [] self.venvs = [] self.pr_num = pr_num + self.extra_args = extra_args self.pr = gh_api.get_pull_request(gh_project, pr_num) @@ -131,8 +132,10 @@ class TestRun(object): "Platform: " + sys.platform, ""] + \ [format_result(r) for r in self.results] + \ - ["", - "Not available for testing: " + ", ".join(self.unavailable_pythons)] + [""] + if self.extra_args: + lines.append("Extra args: %r" % self.extra_args), + lines.append("Not available for testing: " + ", ".join(self.unavailable_pythons)) return "\n".join(lines) def post_results_comment(self): @@ -156,6 +159,9 @@ class TestRun(object): print(" Test log:", result.get('log_url') or result.log_file) if result.missing_libraries: print(" Libraries not available:", result.missing_libraries) + + if self.extra_args: + print("Extra args:", self.extra_args) print("Not available for testing:", ", ".join(self.unavailable_pythons)) def dump_results(self): @@ -187,7 +193,7 @@ class TestRun(object): def run(self): for py, venv in self.venvs: tic = time.time() - passed, log = run_tests(venv) + passed, log = run_tests(venv, self.extra_args) elapsed = int(time.time() - tic) print("Ran tests with %s in %is" % (py, elapsed)) missing_libraries = get_missing_libraries(log) @@ -200,7 +206,7 @@ class TestRun(object): ) -def run_tests(venv): +def run_tests(venv, extra_args): py = os.path.join(basedir, venv, 'bin', 'python') print(py) os.chdir(repodir) @@ -226,8 +232,8 @@ def run_tests(venv): ipython_file = check_output([py, '-c', 'import IPython; print (IPython.__file__)']) ipython_file = ipython_file.strip().decode('utf-8') if not ipython_file.startswith(os.path.join(basedir, venv)): - msg = u"IPython does not appear to be in the venv: %s" % ipython_file - msg += u"\nDo you use setupegg.py develop?" + msg = "IPython does not appear to be in the venv: %s" % ipython_file + msg += "\nDo you use setupegg.py develop?" print(msg, file=sys.stderr) return False, msg @@ -237,7 +243,7 @@ def run_tests(venv): print("\nRunning tests, this typically takes a few minutes...") try: - return True, check_output([iptest], stderr=STDOUT).decode('utf-8') + return True, check_output([iptest] + extra_args, stderr=STDOUT).decode('utf-8') except CalledProcessError as e: return False, e.output.decode('utf-8') finally: @@ -245,13 +251,13 @@ def run_tests(venv): os.environ["PATH"] = orig_path -def test_pr(num, post_results=True): +def test_pr(num, post_results=True, extra_args=None): # Get Github authorisation first, so that the user is prompted straight away # if their login is needed. if post_results: gh_api.get_auth_token() - testrun = TestRun(num) + testrun = TestRun(num, extra_args or []) testrun.get_branch() @@ -278,5 +284,5 @@ if __name__ == '__main__': help="Publish the results to Github") parser.add_argument('number', type=int, help="The pull request number") - args = parser.parse_args() - test_pr(args.number, post_results=args.publish) + args, extra_args = parser.parse_known_args() + test_pr(args.number, post_results=args.publish, extra_args=extra_args)