From 3d96e5060fcbe365d485a5b86c8439b42ada4f72 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois=20Dausseur?= Date: Sun, 7 Jun 2026 18:42:43 +0200 Subject: [PATCH] fix: publish resolved python_bin/lua_bin into the global dict bins.ensure() now stores the resolved interpreter path under python_bin / lua_bin when the key is unset, so test scripts can use $(python_bin) / $(lua_bin) in GUI mode (no -d override). Restores the behaviour lost when bins.py centralised resolution. A user-provided value is left untouched. Co-Authored-By: Claude Opus 4.8 (1M context) --- DESIGN.md | 2 +- src/testium/interpreter/utils/bins.py | 10 ++++++++-- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/DESIGN.md b/DESIGN.md index 9a1bd26..1d66d17 100644 --- a/DESIGN.md +++ b/DESIGN.md @@ -124,7 +124,7 @@ To add a new API call usable from subprocesses: `src/testium/interpreter/utils/bins.py` — single source of truth for the paths to the external Python and Lua interpreters used by subprocesses. - `python_bin()` / `lua_bin()` : resolve and cache. The cache is keyed by `(name, override)` so that a later change to `gd[python_bin]` (typically when a `param.yaml` sets the key) triggers a re-resolution on the next lookup instead of returning the stale auto-discovered path. Falls back to discovery on PATH (candidates: `python3`/`python` and `lua`/`lua5.5`/`lua5.4`/`lua5.3`/`lua5.2`/`lua5.1`). -- `ensure(*names)` : called by `TestSet._validate_runtime_deps()` at test load. Always requires `python` (the eval engine always runs); requires `lua` only if a `lua_func` item is in the tree. Fails fast with a clear error citing tried candidates and override key. +- `ensure(*names)` : called by `TestSet._validate_runtime_deps()` at test load. Always requires `python` (the eval engine always runs); requires `lua` only if a `lua_func` item is in the tree. Fails fast with a clear error citing tried candidates and override key. Also **publishes** each resolved path into gd (`python_bin` / `lua_bin`) when the key is unset, so test scripts can reference `$(python_bin)` / `$(lua_bin)` regardless of launch mode (e.g. GUI, where no `-d` override is passed). A user-provided value is never overwritten. Engines (`PyProcessBase`, `LuaProcessBase`, `EvalExecEngine`) call `bins.python_bin()`/`bins.lua_bin()` themselves — call sites never pass an explicit binary path. diff --git a/src/testium/interpreter/utils/bins.py b/src/testium/interpreter/utils/bins.py index d358a9a..b08fd1c 100644 --- a/src/testium/interpreter/utils/bins.py +++ b/src/testium/interpreter/utils/bins.py @@ -388,12 +388,18 @@ def ensure(*names): """ missing = [] for n in names: - if not _resolve(n): - display, gd_key, candidates, _ = _SPECS[n] + path = _resolve(n) + display, gd_key, candidates, _ = _SPECS[n] + if not path: missing.append( f" - {display}: tried {candidates} on PATH, none usable. " f"Set '{gd_key}' in the YAML config to override." ) + elif not tm.gd(gd_key): + # Publish the resolved interpreter so test scripts can reference + # $(python_bin) / $(lua_bin) regardless of how testium was launched + # (e.g. GUI, where no -d override is passed). + tm.setgd(gd_key, path) if missing: raise ETUMRuntimeError( "Required external interpreter(s) not found:\n" + "\n".join(missing)