From 0ae7e58fb012d4b12f8409f8580d3fddf2d6de9a Mon Sep 17 00:00:00 2001 From: NiJingzhe <1448976235@qq.com> Date: Thu, 29 Oct 2026 22:40:40 +0800 Subject: [PATCH] fix(tests): the reference interpreter is never this repository ref.py defaulted to /SimpleCADAPI/.venv; in a CI checkout (/SimpleCADAPI/SimpleCADAPI) that is the repository itself, so the SDK under test became its own 2.2.6 reference and test_the_reference_sdk_accepts_our_snapshot failed on every Python version. The default is now absent in that case (the test skips), as before. Co-Authored-By: Claude Sonnet 5.5 --- src/cpp/tests/python/ref.py | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/src/cpp/tests/python/ref.py b/src/cpp/tests/python/ref.py index 9b42b6a6..e3b17b6c 100644 --- a/src/cpp/tests/python/ref.py +++ b/src/cpp/tests/python/ref.py @@ -28,10 +28,13 @@ import pytest GOLDEN_DIR = Path(__file__).resolve().parents[1] / "golden" # The reference interpreter runs the 2.2.6 SDK. SCAD_REF_PYTHON names it; without it the checkout next to this one -# (../SimpleCADAPI/.venv) is tried, and the tests that need a reference are skipped when it is not there. -REF_PYTHON = os.environ.get( - "SCAD_REF_PYTHON", str(Path(__file__).resolve().parents[5] / "SimpleCADAPI" / ".venv" / "bin" / "python") -) +# (../SimpleCADAPI/.venv) is tried - unless that path is this very repository (a CI checkout is +# /SimpleCADAPI/SimpleCADAPI), which would make the SDK under test its own reference. The tests that need a +# reference are skipped when there is none. +_REPO = Path(__file__).resolve().parents[4] +_NEIGHBOUR = _REPO.parent / "SimpleCADAPI" +_DEFAULT = None if _NEIGHBOUR.resolve() == _REPO else str(_NEIGHBOUR / ".venv" / "bin" / "python") +REF_PYTHON = os.environ.get("SCAD_REF_PYTHON", _DEFAULT) _PRELUDE = """ import json, sys @@ -44,7 +47,7 @@ json.dump(result, sys.stdout, default=float) def reference_available() -> bool: - return Path(REF_PYTHON).exists() + return REF_PYTHON is not None and Path(REF_PYTHON).exists() def ref_eval(snippet: str, timeout: float = 120.0) -> Any: