##// END OF EJS Templates
run-tests: refactor the HGPORT handling code to use a constant for the max val...
Matt Harbison -
r53208:d49144a1 default
parent child Browse files
Show More
@@ -84,6 +84,8 MACOS = sys.platform == 'darwin'
84 84 WINDOWS = os.name == r'nt'
85 85 shellquote = shlex.quote
86 86
87 # The number of HGPORTx ports allocated to each test.
88 HGPORT_COUNT = 4
87 89
88 90 processlock = threading.Lock()
89 91
@@ -1401,16 +1403,16 class Test(unittest.TestCase):
1401 1403 output. This function defines how some of that normalization will
1402 1404 occur.
1403 1405 """
1404 r = [
1405 # This list should be parallel to defineport in _getenv
1406 self._portmap(0),
1407 self._portmap(1),
1408 self._portmap(2),
1409 self._portmap(3),
1410 (br'([^0-9])%s' % re.escape(self._localip()), br'\1$LOCALIP'),
1411 (br'\bHG_TXNID=TXN:[a-f0-9]{40}\b', br'HG_TXNID=TXN:$ID$'),
1412 ]
1413 r.append((self._escapepath(self._testtmp), b'$TESTTMP'))
1406 r = [self._portmap(port) for port in range(HGPORT_COUNT)]
1407
1408 r.extend(
1409 [
1410 (br'([^0-9])%s' % re.escape(self._localip()), br'\1$LOCALIP'),
1411 (br'\bHG_TXNID=TXN:[a-f0-9]{40}\b', br'HG_TXNID=TXN:$ID$'),
1412 (self._escapepath(self._testtmp), b'$TESTTMP'),
1413 ]
1414 )
1415
1414 1416 if WINDOWS:
1415 1417 # JSON output escapes backslashes in Windows paths, so also catch a
1416 1418 # double-escape.
@@ -1509,9 +1511,8 class Test(unittest.TestCase):
1509 1511 formated_timeout = _bytes2sys(b"%d" % default_defaults['timeout'][1])
1510 1512 env['HGTEST_TIMEOUT_DEFAULT'] = formated_timeout
1511 1513 env['HGTEST_TIMEOUT'] = _bytes2sys(b"%d" % self._timeout)
1512 # This number should match portneeded in _getport
1513 for port in range(4):
1514 # This list should be parallel to _portmap in _getreplacements
1514
1515 for port in range(HGPORT_COUNT):
1515 1516 defineport(port)
1516 1517 env["HGRCPATH"] = _bytes2sys(os.path.join(self._threadtmp, b'.hgrc'))
1517 1518 env["DAEMON_PIDS"] = _bytes2sys(
@@ -3727,7 +3728,7 class TestRunner:
3727 3728 def _getport(self, count):
3728 3729 port = self._ports.get(count) # do we have a cached entry?
3729 3730 if port is None:
3730 portneeded = 4
3731 portneeded = HGPORT_COUNT
3731 3732 # above 100 tries we just give up and let test reports failure
3732 3733 for tries in range(100):
3733 3734 allfree = True
General Comments 0
You need to be logged in to leave comments. Login now