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