diff --git a/tests/run-tests.py b/tests/run-tests.py --- a/tests/run-tests.py +++ b/tests/run-tests.py @@ -3679,8 +3679,19 @@ def _use_correct_mercurial(self): target_exec = os.path.join(self._custom_bin_dir, b'hg') if self._hgcommand != b'hg': - # shutil.which only accept bytes from 3.8 - real_exec = which(self._hgcommand) + # _usecorrectpython() may have augmented PATH, so don't used `which` + # on the basename of the explicitly provided executable, since that + # may end up using another one. + # + # TODO: figure how why test-run-tests.t fails on Windows if we + # unconditionally join with bindir, and run with --local. Not + # using --local will run the *.t fine. + if self.options.with_hg: + real_exec = os.path.join(self._bindir, self._hgcommand) + else: + # shutil.which only accept bytes from 3.8 + real_exec = which(self._hgcommand) + if real_exec is None: raise ValueError('could not find exec path for "%s"', real_exec) if real_exec == target_exec: