##// END OF EJS Templates
run-tests: refactor port allocation into functions...
timeless -
r28169:1b07331f default
parent child Browse files
Show More
@@ -720,6 +720,10 b' class Test(unittest.TestCase):'
720 720 """Terminate execution of this test."""
721 721 self._aborted = True
722 722
723 def _portmap(self, i):
724 offset = '' if i == 0 else '%s' % i
725 return (br':%d\b' % (self._startport + i), b':$HGPORT%s' % offset)
726
723 727 def _getreplacements(self):
724 728 """Obtain a mapping of text replacements to apply to test output.
725 729
@@ -728,11 +732,12 b' class Test(unittest.TestCase):'
728 732 occur.
729 733 """
730 734 r = [
731 (br':%d\b' % self._startport, b':$HGPORT'),
732 (br':%d\b' % (self._startport + 1), b':$HGPORT1'),
733 (br':%d\b' % (self._startport + 2), b':$HGPORT2'),
734 (br':%d\b' % (self._startport + 2), b':$HGPORT3'),
735 (br':%d\b' % (self._startport + 2), b':$HGPORT4'),
735 # This list should be parallel to defineport in _getenv
736 self._portmap(0),
737 self._portmap(1),
738 self._portmap(2),
739 self._portmap(3),
740 self._portmap(4),
736 741 (br'(?m)^(saved backup bundle to .*\.hg)( \(glob\))?$',
737 742 br'\1 (glob)'),
738 743 ]
@@ -752,14 +757,18 b' class Test(unittest.TestCase):'
752 757
753 758 def _getenv(self):
754 759 """Obtain environment variables to use during test execution."""
760 def defineport(i):
761 offset = '' if i == 0 else '%s' % i
762 env["HGPORT%s" % offset] = '%s' % (self._startport + i)
755 763 env = os.environ.copy()
756 764 env['TESTTMP'] = self._testtmp
757 765 env['HOME'] = self._testtmp
758 env["HGPORT"] = str(self._startport)
759 env["HGPORT1"] = str(self._startport + 1)
760 env["HGPORT2"] = str(self._startport + 2)
761 env["HGPORT3"] = str(self._startport + 3)
762 env["HGPORT4"] = str(self._startport + 4)
766 # This number should match portneeded in _getport
767 # XXX currently it does not, this is a bug that will be fixed
768 # in the next commit.
769 for port in xrange(5):
770 # This list should be parallel to _portmap in _getreplacements
771 defineport(port)
763 772 env["HGRCPATH"] = os.path.join(self._threadtmp, b'.hgrc')
764 773 env["DAEMON_PIDS"] = os.path.join(self._threadtmp, b'daemon.pids')
765 774 env["HGEDITOR"] = ('"' + sys.executable + '"'
General Comments 0
You need to be logged in to leave comments. Login now