Skip to content

Commit 6110192

Browse files
authored
Merge pull request #8327 from loopx-project/codex/freeze-cli-output-fixture-support-20261108
Use the frozen helper in both CLI budget probe checkouts
2 parents 15467f2 + 00fc80f commit 6110192

2 files changed

Lines changed: 53 additions & 2 deletions

File tree

‎examples/control_plane/cli-output-probe-runner.py‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -459,11 +459,13 @@ def main() -> int:
459459
)
460460
args = parser.parse_args()
461461
_install_pytest_import_stub()
462-
probe = _load_module("loopx_cli_output_probe_fixture", args.test_source)
462+
# Bind the frozen workload's helpers before it imports them. LoopX itself
463+
# still comes from the product checkout selected for this subprocess.
463464
fixture_support = _load_module(
464-
"loopx_cli_output_fixture_support",
465+
"tests.control_plane.cli_output_fixture",
465466
Path(__file__).with_name("cli_output_fixture.py"),
466467
)
468+
probe = _load_module("loopx_cli_output_probe_fixture", args.test_source)
467469
# Scenario helpers also call this owner; historical test modules must not
468470
# re-enter their old /tmp implementation from inside the shared outer root.
469471
probe._stable_budget_fixture_root = fixture_support.stable_budget_fixture_root

‎tests/control_plane/test_cli_output_probe_runner.py‎

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,12 @@
11
from __future__ import annotations
22

33
import json
4+
import os
45
import runpy
56
import re
67
import shlex
8+
import shutil
9+
import subprocess
710
import sys
811
from pathlib import Path
912
from types import SimpleNamespace
@@ -21,6 +24,52 @@
2124
)
2225

2326

27+
def test_runner_imports_frozen_support_with_an_older_checkout(tmp_path: Path) -> None:
28+
workload = tmp_path / "workload"
29+
workload.mkdir()
30+
runner = workload / RUNNER.name
31+
shutil.copyfile(RUNNER, runner)
32+
shutil.copyfile(cli_output_fixture.__file__, workload / "cli_output_fixture.py")
33+
34+
historical = tmp_path / "historical"
35+
legacy_tests = historical / "tests" / "control_plane"
36+
legacy_tests.mkdir(parents=True)
37+
for package in (legacy_tests, legacy_tests.parent):
38+
(package / "__init__.py").touch()
39+
(legacy_tests / "cli_output_fixture.py").write_text(
40+
"# Older checkout with no current observation helper.\n", encoding="utf-8"
41+
)
42+
probe_source = workload / "probe.py"
43+
probe_source.write_text(
44+
"from pathlib import Path\n"
45+
"from tests.control_plane.cli_output_fixture import measure_cli_context_for_oracle\n"
46+
"assert Path(measure_cli_context_for_oracle.__code__.co_filename) == "
47+
"Path(__file__).with_name('cli_output_fixture.py')\n"
48+
"print('frozen fixture support loaded')\n"
49+
"raise SystemExit(0)\n",
50+
encoding="utf-8",
51+
)
52+
53+
result = subprocess.run(
54+
[
55+
sys.executable, str(runner),
56+
"--test-source", str(probe_source),
57+
"--semantics-source", str(workload / "unused_semantics.py"),
58+
"--fixture-root", str(workload / "unused_fixture"),
59+
"--receipt", str(workload / "unused_receipt.json"),
60+
],
61+
cwd=workload,
62+
env={
63+
**os.environ,
64+
"PYTHONPATH": os.pathsep.join((str(historical), str(RUNNER.parents[2]))),
65+
"LOOPX_USAGE_PING": "0",
66+
},
67+
capture_output=True, text=True, encoding="utf-8", timeout=30, check=False,
68+
)
69+
assert result.returncode == 0, result.stderr
70+
assert result.stdout.strip() == "frozen fixture support loaded"
71+
72+
2473
@pytest.fixture
2574
def crowded_turn_probe(monkeypatch: pytest.MonkeyPatch):
2675
commands = probe._surface_commands

0 commit comments

Comments
 (0)