Mercurial > hg
comparison tests/run-tests.py @ 24509:27092bb70293
run-tests: remove arguments from Test._runcommand
Now that runcommand is part of the Test class, arguments that were
previously coming from Test attributes can now be switched to
lookups inline.
author | Gregory Szorc <gregory.szorc@gmail.com> |
---|---|
date | Sat, 28 Mar 2015 14:12:57 -0700 |
parents | fbe2fb71a6e6 |
children | 8d6fd0b8f622 |
comparison
equal
deleted
inserted
replaced
24508:fbe2fb71a6e6 | 24509:27092bb70293 |
---|---|
720 def fail(self, msg): | 720 def fail(self, msg): |
721 # unittest differentiates between errored and failed. | 721 # unittest differentiates between errored and failed. |
722 # Failed is denoted by AssertionError (by default at least). | 722 # Failed is denoted by AssertionError (by default at least). |
723 raise AssertionError(msg) | 723 raise AssertionError(msg) |
724 | 724 |
725 def _runcommand(self, cmd, wd, replacements, env, debug=False, | 725 def _runcommand(self, cmd, replacements, env): |
726 timeout=None): | |
727 """Run command in a sub-process, capturing the output (stdout and | 726 """Run command in a sub-process, capturing the output (stdout and |
728 stderr). | 727 stderr). |
729 | 728 |
730 Return a tuple (exitcode, output). output is None in debug mode. | 729 Return a tuple (exitcode, output). output is None in debug mode. |
731 """ | 730 """ |
732 if debug: | 731 if self._debug: |
733 proc = subprocess.Popen(cmd, shell=True, cwd=wd, env=env) | 732 proc = subprocess.Popen(cmd, shell=True, cwd=self._testtmp, |
733 env=env) | |
734 ret = proc.wait() | 734 ret = proc.wait() |
735 return (ret, None) | 735 return (ret, None) |
736 | 736 |
737 proc = Popen4(cmd, wd, timeout, env) | 737 proc = Popen4(cmd, self._testtmp, self._timeout, env) |
738 def cleanup(): | 738 def cleanup(): |
739 terminate(proc) | 739 terminate(proc) |
740 ret = proc.wait() | 740 ret = proc.wait() |
741 if ret == 0: | 741 if ret == 0: |
742 ret = signal.SIGTERM << 8 | 742 ret = signal.SIGTERM << 8 |
778 py3kswitch = self._py3kwarnings and ' -3' or '' | 778 py3kswitch = self._py3kwarnings and ' -3' or '' |
779 cmd = '%s%s "%s"' % (PYTHON, py3kswitch, self.path) | 779 cmd = '%s%s "%s"' % (PYTHON, py3kswitch, self.path) |
780 vlog("# Running", cmd) | 780 vlog("# Running", cmd) |
781 if os.name == 'nt': | 781 if os.name == 'nt': |
782 replacements.append((r'\r\n', '\n')) | 782 replacements.append((r'\r\n', '\n')) |
783 result = self._runcommand(cmd, self._testtmp, replacements, env, | 783 result = self._runcommand(cmd, replacements, env) |
784 debug=self._debug, timeout=self._timeout) | |
785 if self._aborted: | 784 if self._aborted: |
786 raise KeyboardInterrupt() | 785 raise KeyboardInterrupt() |
787 | 786 |
788 return result | 787 return result |
789 | 788 |
826 f.close() | 825 f.close() |
827 | 826 |
828 cmd = '%s "%s"' % (self._shell, fname) | 827 cmd = '%s "%s"' % (self._shell, fname) |
829 vlog("# Running", cmd) | 828 vlog("# Running", cmd) |
830 | 829 |
831 exitcode, output = self._runcommand(cmd, self._testtmp, replacements, | 830 exitcode, output = self._runcommand(cmd, replacements, env) |
832 env, debug=self._debug, | |
833 timeout=self._timeout) | |
834 | 831 |
835 if self._aborted: | 832 if self._aborted: |
836 raise KeyboardInterrupt() | 833 raise KeyboardInterrupt() |
837 | 834 |
838 # Do not merge output if skipped. Return hghave message instead. | 835 # Do not merge output if skipped. Return hghave message instead. |