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