|
| 1 | +"""The preflight accepts only cadence values supported by the owning CLI.""" |
| 2 | +from __future__ import annotations |
| 3 | + |
| 4 | +import subprocess |
| 5 | +import sys |
| 6 | + |
| 7 | +import pytest |
| 8 | + |
| 9 | +from benchmark.LHTB.scripts.preflight import cli_supports_replan_count |
| 10 | +from benchmark.runtime.codex import DEFAULT_REPLAN_AFTER_TURNS |
| 11 | + |
| 12 | + |
| 13 | +@pytest.mark.parametrize("help_text,option,count,expected", [ |
| 14 | + ("--execution-replan-after-turns {1,2,3,4,5,6}", "--execution-replan-after-turns", 6, True), |
| 15 | + ("--execution-replan-after-turns {1,2,3,4,5,6}", "--execution-replan-after-turns", 3, True), |
| 16 | + ("--execution-replan-after-turns {1,2,3,4,5}", "--execution-replan-after-turns", 6, False), |
| 17 | + ("--execution-replan-after-todos {1,2,3,4,5}", "--execution-replan-after-todos", 3, True), |
| 18 | + ("--execution-replan-after-todos {1,2,3,4,5}", "--execution-replan-after-todos", 6, False), |
| 19 | + ("--execution-replan-after-turns\n {1,2,3,4,5,6}", "--execution-replan-after-turns", 6, True), |
| 20 | + ("--execution-replan-after-turns-extra {1,2,3,4,5,6}", "--execution-replan-after-turns", 6, False), |
| 21 | + ("--execution-replan-after-turns {1,2,3,4,5,6}", "--execution-replan-after-todos", 3, False), |
| 22 | +]) |
| 23 | +def test_resolved_cadence_uses_its_own_cli_choices(help_text, option, count, expected): |
| 24 | + assert cli_supports_replan_count(help_text, option, count) is expected |
| 25 | + |
| 26 | + |
| 27 | +def test_current_cli_accepts_the_benchmark_default(): |
| 28 | + help_result = subprocess.run( |
| 29 | + [sys.executable, "-m", "loopx.cli", "configure-goal", "--help"], |
| 30 | + capture_output=True, text=True, check=True, timeout=30, |
| 31 | + ) |
| 32 | + assert cli_supports_replan_count( |
| 33 | + help_result.stdout, "--execution-replan-after-turns", DEFAULT_REPLAN_AFTER_TURNS, |
| 34 | + ) |
0 commit comments