Mercurial > hg > mercurial-crew
comparison tests/run-tests.py @ 21499:d22f4e72dcd5
run-tests: factor options out of run()
We were only utilizing 2 parts of options. These have been converted to
named arguments.
author | Gregory Szorc <gregory.szorc@gmail.com> |
---|---|
date | Sun, 20 Apr 2014 18:20:24 -0700 |
parents | 798c81e32b5e |
children | 130cc0d7bfde |
comparison
equal
deleted
inserted
replaced
21498:6b8daeea638a | 21499:d22f4e72dcd5 |
---|---|
676 py3kswitch = self._options.py3k_warnings and ' -3' or '' | 676 py3kswitch = self._options.py3k_warnings and ' -3' or '' |
677 cmd = '%s%s "%s"' % (PYTHON, py3kswitch, self._path) | 677 cmd = '%s%s "%s"' % (PYTHON, py3kswitch, self._path) |
678 vlog("# Running", cmd) | 678 vlog("# Running", cmd) |
679 if os.name == 'nt': | 679 if os.name == 'nt': |
680 replacements.append((r'\r\n', '\n')) | 680 replacements.append((r'\r\n', '\n')) |
681 return run(cmd, self._testtmp, self._options, replacements, env, | 681 return run(cmd, self._testtmp, replacements, env, self._runner.abort, |
682 self._runner.abort) | 682 debug=self._options.debug, timeout=self._options.timeout) |
683 | 683 |
684 class TTest(Test): | 684 class TTest(Test): |
685 """A "t test" is a test backed by a .t file.""" | 685 """A "t test" is a test backed by a .t file.""" |
686 | 686 |
687 SKIPPED_PREFIX = 'skipped: ' | 687 SKIPPED_PREFIX = 'skipped: ' |
707 f.close() | 707 f.close() |
708 | 708 |
709 cmd = '%s "%s"' % (self._options.shell, fname) | 709 cmd = '%s "%s"' % (self._options.shell, fname) |
710 vlog("# Running", cmd) | 710 vlog("# Running", cmd) |
711 | 711 |
712 exitcode, output = run(cmd, self._testtmp, self._options, replacements, | 712 exitcode, output = run(cmd, self._testtmp, replacements, env, |
713 env, self._runner.abort) | 713 self._runner.abort, debug=self._options.debug, |
714 timeout=self._options.timeout) | |
714 # Do not merge output if skipped. Return hghave message instead. | 715 # Do not merge output if skipped. Return hghave message instead. |
715 # Similarly, with --debug, output is None. | 716 # Similarly, with --debug, output is None. |
716 if exitcode == self.SKIPPED_STATUS or output is None: | 717 if exitcode == self.SKIPPED_STATUS or output is None: |
717 return exitcode, output | 718 return exitcode, output |
718 | 719 |
985 def _stringescape(s): | 986 def _stringescape(s): |
986 return TTest.ESCAPESUB(TTest._escapef, s) | 987 return TTest.ESCAPESUB(TTest._escapef, s) |
987 | 988 |
988 | 989 |
989 wifexited = getattr(os, "WIFEXITED", lambda x: False) | 990 wifexited = getattr(os, "WIFEXITED", lambda x: False) |
990 def run(cmd, wd, options, replacements, env, abort): | 991 def run(cmd, wd, replacements, env, abort, debug=False, timeout=None): |
991 """Run command in a sub-process, capturing the output (stdout and stderr). | 992 """Run command in a sub-process, capturing the output (stdout and stderr). |
992 Return a tuple (exitcode, output). output is None in debug mode.""" | 993 Return a tuple (exitcode, output). output is None in debug mode.""" |
993 # TODO: Use subprocess.Popen if we're running on Python 2.4 | 994 if debug: |
994 if options.debug: | |
995 proc = subprocess.Popen(cmd, shell=True, cwd=wd, env=env) | 995 proc = subprocess.Popen(cmd, shell=True, cwd=wd, env=env) |
996 ret = proc.wait() | 996 ret = proc.wait() |
997 return (ret, None) | 997 return (ret, None) |
998 | 998 |
999 proc = Popen4(cmd, wd, options.timeout, env) | 999 proc = Popen4(cmd, wd, timeout, env) |
1000 def cleanup(): | 1000 def cleanup(): |
1001 terminate(proc) | 1001 terminate(proc) |
1002 ret = proc.wait() | 1002 ret = proc.wait() |
1003 if ret == 0: | 1003 if ret == 0: |
1004 ret = signal.SIGTERM << 8 | 1004 ret = signal.SIGTERM << 8 |