Mercurial > public > mercurial-scm > hg
changeset 52716:e465689fa74d
test-local: error in case of --local without the corresponding venv
author | Pierre Augier <pierre.augier@univ-grenoble-alpes.fr> |
---|---|
date | Sat, 25 Jan 2025 23:49:24 +0100 |
parents | 7aa46c5f56e7 |
children | f071b18e1382 |
files | tests/run-tests.py |
diffstat | 1 files changed, 20 insertions(+), 3 deletions(-) [+] |
line wrap: on
line diff
--- a/tests/run-tests.py Fri Jan 24 23:14:54 2025 +0100 +++ b/tests/run-tests.py Sat Jan 25 23:49:24 2025 +0100 @@ -54,6 +54,7 @@ import json import multiprocessing import os +import pathlib import platform import queue import random @@ -72,7 +73,6 @@ import uuid import xml.dom.minidom as minidom - # Don't compare sys.version_info directly, to prevent pyupgrade from dropping # the conditional. sys_version_info = sys.version_info @@ -760,8 +760,25 @@ ) path_local_hg = os.path.join(reporootdir, venv_local, BINDIRNAME, b"hg") if not os.path.exists(path_local_hg): - # no local environment but we can still use ./hg to please test-run-tests.t - path_local_hg = os.path.join(reporootdir, b"hg") + if "HGTEST_REAL_HG" in os.environ: + # this file is run from a test (typically test-run-tests.t) + # no local environment but we can still use ./hg to please test-run-tests.t + path_local_hg = os.path.join(reporootdir, b"hg") + else: + message = ( + f"run-tests.py called with --local but {_bytes2sys(venv_local)} does not exist.\n" + f'To create it, run \nmake local PYTHON="{sys.executable}"' + ) + paths_venv = sorted( + pathlib.Path(_bytes2sys(reporootdir)).glob(".venv_*") + ) + if paths_venv: + message += ( + "\nAlternatively, call run-tests.py with a Python " + f"corresponding to {[p.name for p in paths_venv]}." + ) + print(message, file=sys.stderr) + sys.exit(1) pathandattrs = [(path_local_hg, 'with_hg')] if options.chg: