##// END OF EJS Templates
run-tests: obtain replacements inside Test._runcommand...
Gregory Szorc -
r24516:62fb03e0 default
parent child Browse files
Show More
@@ -543,14 +543,13 b' class Test(unittest.TestCase):'
543
543
544 This will return a tuple describing the result of the test.
544 This will return a tuple describing the result of the test.
545 """
545 """
546 replacements = self._getreplacements()
547 env = self._getenv()
546 env = self._getenv()
548 self._daemonpids.append(env['DAEMON_PIDS'])
547 self._daemonpids.append(env['DAEMON_PIDS'])
549 self._createhgrc(env['HGRCPATH'])
548 self._createhgrc(env['HGRCPATH'])
550
549
551 vlog('# Test', self.name)
550 vlog('# Test', self.name)
552
551
553 ret, out = self._run(replacements, env)
552 ret, out = self._run(env)
554 self._finished = True
553 self._finished = True
555 self._ret = ret
554 self._ret = ret
556 self._out = out
555 self._out = out
@@ -623,7 +622,7 b' class Test(unittest.TestCase):'
623
622
624 vlog("# Ret was:", self._ret)
623 vlog("# Ret was:", self._ret)
625
624
626 def _run(self, replacements, env):
625 def _run(self, env):
627 # This should be implemented in child classes to run tests.
626 # This should be implemented in child classes to run tests.
628 raise SkipTest('unknown test type')
627 raise SkipTest('unknown test type')
629
628
@@ -722,7 +721,7 b' class Test(unittest.TestCase):'
722 # Failed is denoted by AssertionError (by default at least).
721 # Failed is denoted by AssertionError (by default at least).
723 raise AssertionError(msg)
722 raise AssertionError(msg)
724
723
725 def _runcommand(self, cmd, replacements, env, normalizenewlines=False):
724 def _runcommand(self, cmd, env, normalizenewlines=False):
726 """Run command in a sub-process, capturing the output (stdout and
725 """Run command in a sub-process, capturing the output (stdout and
727 stderr).
726 stderr).
728
727
@@ -763,7 +762,7 b' class Test(unittest.TestCase):'
763 if ret:
762 if ret:
764 killdaemons(env['DAEMON_PIDS'])
763 killdaemons(env['DAEMON_PIDS'])
765
764
766 for s, r in replacements:
765 for s, r in self._getreplacements():
767 output = re.sub(s, r, output)
766 output = re.sub(s, r, output)
768
767
769 if normalizenewlines:
768 if normalizenewlines:
@@ -778,12 +777,12 b' class PythonTest(Test):'
778 def refpath(self):
777 def refpath(self):
779 return os.path.join(self._testdir, '%s.out' % self.name)
778 return os.path.join(self._testdir, '%s.out' % self.name)
780
779
781 def _run(self, replacements, env):
780 def _run(self, env):
782 py3kswitch = self._py3kwarnings and ' -3' or ''
781 py3kswitch = self._py3kwarnings and ' -3' or ''
783 cmd = '%s%s "%s"' % (PYTHON, py3kswitch, self.path)
782 cmd = '%s%s "%s"' % (PYTHON, py3kswitch, self.path)
784 vlog("# Running", cmd)
783 vlog("# Running", cmd)
785 normalizenewlines = os.name == 'nt'
784 normalizenewlines = os.name == 'nt'
786 result = self._runcommand(cmd, replacements, env,
785 result = self._runcommand(cmd, env,
787 normalizenewlines=normalizenewlines)
786 normalizenewlines=normalizenewlines)
788 if self._aborted:
787 if self._aborted:
789 raise KeyboardInterrupt()
788 raise KeyboardInterrupt()
@@ -814,7 +813,7 b' class TTest(Test):'
814 def refpath(self):
813 def refpath(self):
815 return os.path.join(self._testdir, self.name)
814 return os.path.join(self._testdir, self.name)
816
815
817 def _run(self, replacements, env):
816 def _run(self, env):
818 f = open(self.path, 'rb')
817 f = open(self.path, 'rb')
819 lines = f.readlines()
818 lines = f.readlines()
820 f.close()
819 f.close()
@@ -831,7 +830,7 b' class TTest(Test):'
831 cmd = '%s "%s"' % (self._shell, fname)
830 cmd = '%s "%s"' % (self._shell, fname)
832 vlog("# Running", cmd)
831 vlog("# Running", cmd)
833
832
834 exitcode, output = self._runcommand(cmd, replacements, env)
833 exitcode, output = self._runcommand(cmd, env)
835
834
836 if self._aborted:
835 if self._aborted:
837 raise KeyboardInterrupt()
836 raise KeyboardInterrupt()
General Comments 0
You need to be logged in to leave comments. Login now