Bug 6361 - run-tests.py on python3 links python too eagerly in usecorrectpython
Summary: run-tests.py on python3 links python too eagerly in usecorrectpython
Status: RESOLVED FIXED
Alias: None
Product: Mercurial
Classification: Unclassified
Component: Mercurial (show other bugs)
Version: stable branch
Hardware: PC Mac OS
: wish feature
Assignee: Bugzilla
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2020-06-30 07:04 UTC by Axel Hecht
Modified: 2020-07-10 00:00 UTC (History)
2 users (show)

See Also:
Python Version: ---


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Axel Hecht 2020-06-30 07:04 UTC
In usecorrectpython, run-tests calls into self._findprogram, https://www.mercurial-scm.org/repo/hg-committed/file/5.4.1/tests/run-tests.py#l3441.

On python 3, that returns bytes, while sysexecutable is a string, and that check always fails.

Glancing at the callers of _findprogram, that could probably return a proper string?
Comment 1 Manuel Jacob 2020-06-30 10:08 UTC
Do you have a reproducable test case where this gives undesirable behavior?

Mercurial prefers to do everything with bytes. However, this is only partially the case in run-tests.py, so changing `_findprogram` to return str is maybe a viable option.

Will you send a patch?
Comment 2 Axel Hecht 2020-06-30 10:22 UTC
I"m using `path/to/hg/tests/run-test.py --with-hg=venv/bin/hg tests/test-*.t` to run tests in another project, inside a virtualenv.

The result is that python gets linked, and then the packages in my virtualenv aren't found.

It's been a while since I tried to get patches in, but I can give it a shot.
Comment 3 Axel Hecht 2020-07-01 09:50 UTC
Created https://phab.mercurial-scm.org/D8674
Comment 4 HG Bot 2020-07-02 08:10 UTC
Fixed by https://mercurial-scm.org/repo/hg/rev/383005aa9cdc
Axel Hecht <axel@pike.org>
run-tests: find python binary on Python 3 (issue6361)

Return strings from _findprogram as all callers expect
unicode strings.
Previously the check in _usecorrectpython agains sysexecutable
was always false on Python 3.

Differential Revision: https://phab.mercurial-scm.org/D8674

(please test the fix)
Comment 5 Axel Hecht 2020-07-02 08:44 UTC
Thanks, updated my local clone and reran my tests, and they're all cheers now.
Comment 6 Bugzilla 2020-07-10 00:00 UTC
Bug was set to TESTING for 7 days, resolving