Mercurial > hg-stable
comparison tests/run-tests.py @ 43309:b4b1131187c4 stable
py3: decode bytes before logging in run-tests.py
Avoids messages like "Found prerequisite b'diff' at b'/usr/bin/diff'"
under Python 3.
author | Denis Laxalde <denis@laxalde.org> |
---|---|
date | Mon, 21 Oct 2019 11:26:41 +0200 |
parents | 96eb9ef777a8 |
children | 6ada8a274b9c |
comparison
equal
deleted
inserted
replaced
43308:dcf396551305 | 43309:b4b1131187c4 |
---|---|
1502 | 1502 |
1503 def _run(self, env): | 1503 def _run(self, env): |
1504 py3switch = self._py3warnings and b' -3' or b'' | 1504 py3switch = self._py3warnings and b' -3' or b'' |
1505 # Quote the python(3) executable for Windows | 1505 # Quote the python(3) executable for Windows |
1506 cmd = b'"%s"%s "%s"' % (PYTHON, py3switch, self.path) | 1506 cmd = b'"%s"%s "%s"' % (PYTHON, py3switch, self.path) |
1507 vlog("# Running", cmd) | 1507 vlog("# Running", cmd.decode("utf-8")) |
1508 normalizenewlines = os.name == 'nt' | 1508 normalizenewlines = os.name == 'nt' |
1509 result = self._runcommand(cmd, env, normalizenewlines=normalizenewlines) | 1509 result = self._runcommand(cmd, env, normalizenewlines=normalizenewlines) |
1510 if self._aborted: | 1510 if self._aborted: |
1511 raise KeyboardInterrupt() | 1511 raise KeyboardInterrupt() |
1512 | 1512 |
1587 with open(fname, 'wb') as f: | 1587 with open(fname, 'wb') as f: |
1588 for l in script: | 1588 for l in script: |
1589 f.write(l) | 1589 f.write(l) |
1590 | 1590 |
1591 cmd = b'%s "%s"' % (self._shell, fname) | 1591 cmd = b'%s "%s"' % (self._shell, fname) |
1592 vlog("# Running", cmd) | 1592 vlog("# Running", cmd.decode("utf-8")) |
1593 | 1593 |
1594 exitcode, output = self._runcommand(cmd, env) | 1594 exitcode, output = self._runcommand(cmd, env) |
1595 | 1595 |
1596 if self._aborted: | 1596 if self._aborted: |
1597 raise KeyboardInterrupt() | 1597 raise KeyboardInterrupt() |
3109 logexceptions = os.path.join(self._testdir, b'logexceptions.py') | 3109 logexceptions = os.path.join(self._testdir, b'logexceptions.py') |
3110 self.options.extra_config_opt.append( | 3110 self.options.extra_config_opt.append( |
3111 'extensions.logexceptions=%s' % logexceptions.decode('utf-8') | 3111 'extensions.logexceptions=%s' % logexceptions.decode('utf-8') |
3112 ) | 3112 ) |
3113 | 3113 |
3114 vlog("# Using TESTDIR", self._testdir) | 3114 vlog("# Using TESTDIR", _strpath(self._testdir)) |
3115 vlog("# Using RUNTESTDIR", osenvironb[b'RUNTESTDIR']) | 3115 vlog("# Using RUNTESTDIR", _strpath(osenvironb[b'RUNTESTDIR'])) |
3116 vlog("# Using HGTMP", self._hgtmp) | 3116 vlog("# Using HGTMP", _strpath(self._hgtmp)) |
3117 vlog("# Using PATH", os.environ["PATH"]) | 3117 vlog("# Using PATH", os.environ["PATH"]) |
3118 vlog("# Using", IMPL_PATH, osenvironb[IMPL_PATH]) | 3118 vlog( |
3119 vlog("# Writing to directory", self._outputdir) | 3119 "# Using", |
3120 _strpath(IMPL_PATH), | |
3121 _strpath(osenvironb[IMPL_PATH]), | |
3122 ) | |
3123 vlog("# Writing to directory", _strpath(self._outputdir)) | |
3120 | 3124 |
3121 try: | 3125 try: |
3122 return self._runtests(testdescs) or 0 | 3126 return self._runtests(testdescs) or 0 |
3123 finally: | 3127 finally: |
3124 time.sleep(0.1) | 3128 time.sleep(0.1) |
3355 def _cleanup(self): | 3359 def _cleanup(self): |
3356 """Clean up state from this test invocation.""" | 3360 """Clean up state from this test invocation.""" |
3357 if self.options.keep_tmpdir: | 3361 if self.options.keep_tmpdir: |
3358 return | 3362 return |
3359 | 3363 |
3360 vlog("# Cleaning up HGTMP", self._hgtmp) | 3364 vlog("# Cleaning up HGTMP", _strpath(self._hgtmp)) |
3361 shutil.rmtree(self._hgtmp, True) | 3365 shutil.rmtree(self._hgtmp, True) |
3362 for f in self._createdfiles: | 3366 for f in self._createdfiles: |
3363 try: | 3367 try: |
3364 os.remove(f) | 3368 os.remove(f) |
3365 except OSError: | 3369 except OSError: |
3466 raise | 3470 raise |
3467 | 3471 |
3468 makedirs(self._pythondir) | 3472 makedirs(self._pythondir) |
3469 makedirs(self._bindir) | 3473 makedirs(self._bindir) |
3470 | 3474 |
3471 vlog("# Running", cmd) | 3475 vlog("# Running", cmd.decode("utf-8")) |
3472 if subprocess.call(_strpath(cmd), shell=True) == 0: | 3476 if subprocess.call(_strpath(cmd), shell=True) == 0: |
3473 if not self.options.verbose: | 3477 if not self.options.verbose: |
3474 try: | 3478 try: |
3475 os.remove(installerrs) | 3479 os.remove(installerrs) |
3476 except OSError as e: | 3480 except OSError as e: |
3641 """Ensure tools required to run tests are present.""" | 3645 """Ensure tools required to run tests are present.""" |
3642 for p in self.REQUIREDTOOLS: | 3646 for p in self.REQUIREDTOOLS: |
3643 if os.name == 'nt' and not p.endswith(b'.exe'): | 3647 if os.name == 'nt' and not p.endswith(b'.exe'): |
3644 p += b'.exe' | 3648 p += b'.exe' |
3645 found = self._findprogram(p) | 3649 found = self._findprogram(p) |
3650 p = p.decode("utf-8") | |
3646 if found: | 3651 if found: |
3647 vlog("# Found prerequisite", p, "at", found) | 3652 vlog("# Found prerequisite", p, "at", _strpath(found)) |
3648 else: | 3653 else: |
3649 print( | 3654 print("WARNING: Did not find prerequisite tool: %s " % p) |
3650 "WARNING: Did not find prerequisite tool: %s " | |
3651 % p.decode("utf-8") | |
3652 ) | |
3653 | 3655 |
3654 | 3656 |
3655 def aggregateexceptions(path): | 3657 def aggregateexceptions(path): |
3656 exceptioncounts = collections.Counter() | 3658 exceptioncounts = collections.Counter() |
3657 testsbyfailure = collections.defaultdict(set) | 3659 testsbyfailure = collections.defaultdict(set) |