Mercurial > hg
changeset 52315:d49144a1422f
run-tests: refactor the HGPORT handling code to use a constant for the max val
Simple enough, and then we don't need comments to cross-reference other areas of
code that need to be kept in sync. Since the `_getreplacements()` list is now
partially dynamically generated and needed to change anyway, also move the one
line that was being appended separately to the list for some reason, for clarity.
author | Matt Harbison <matt_harbison@yahoo.com> |
---|---|
date | Thu, 21 Nov 2024 01:07:47 -0500 |
parents | 33d8cb64e9da |
children | a820a7a1fce0 |
files | tests/run-tests.py |
diffstat | 1 files changed, 15 insertions(+), 14 deletions(-) [+] |
line wrap: on
line diff
--- a/tests/run-tests.py Mon Nov 18 15:42:09 2024 +0100 +++ b/tests/run-tests.py Thu Nov 21 01:07:47 2024 -0500 @@ -84,6 +84,8 @@ WINDOWS = os.name == r'nt' shellquote = shlex.quote +# The number of HGPORTx ports allocated to each test. +HGPORT_COUNT = 4 processlock = threading.Lock() @@ -1401,16 +1403,16 @@ output. This function defines how some of that normalization will occur. """ - r = [ - # This list should be parallel to defineport in _getenv - self._portmap(0), - self._portmap(1), - self._portmap(2), - self._portmap(3), - (br'([^0-9])%s' % re.escape(self._localip()), br'\1$LOCALIP'), - (br'\bHG_TXNID=TXN:[a-f0-9]{40}\b', br'HG_TXNID=TXN:$ID$'), - ] - r.append((self._escapepath(self._testtmp), b'$TESTTMP')) + r = [self._portmap(port) for port in range(HGPORT_COUNT)] + + r.extend( + [ + (br'([^0-9])%s' % re.escape(self._localip()), br'\1$LOCALIP'), + (br'\bHG_TXNID=TXN:[a-f0-9]{40}\b', br'HG_TXNID=TXN:$ID$'), + (self._escapepath(self._testtmp), b'$TESTTMP'), + ] + ) + if WINDOWS: # JSON output escapes backslashes in Windows paths, so also catch a # double-escape. @@ -1509,9 +1511,8 @@ formated_timeout = _bytes2sys(b"%d" % default_defaults['timeout'][1]) env['HGTEST_TIMEOUT_DEFAULT'] = formated_timeout env['HGTEST_TIMEOUT'] = _bytes2sys(b"%d" % self._timeout) - # This number should match portneeded in _getport - for port in range(4): - # This list should be parallel to _portmap in _getreplacements + + for port in range(HGPORT_COUNT): defineport(port) env["HGRCPATH"] = _bytes2sys(os.path.join(self._threadtmp, b'.hgrc')) env["DAEMON_PIDS"] = _bytes2sys( @@ -3727,7 +3728,7 @@ def _getport(self, count): port = self._ports.get(count) # do we have a cached entry? if port is None: - portneeded = 4 + portneeded = HGPORT_COUNT # above 100 tries we just give up and let test reports failure for tries in range(100): allfree = True