[Bug][Tests][Curriculum] CurriculumSmokeTests picks whatever python3 is first on PATH — macOS system Python 3.9 fails the match-statement lessons (21300/21301) with a raw SyntaxError
#591
Reference in New Issue
Block a user
Found while running the full
SpikerSoft.Business.Testssuite during #574. Fails on a cleanmaster(verified by stashing the branch and re-running), so filing separately rather than folding it into an unrelated PR.The failure — 2 of 93
CurriculumSmokeTests:Same for lesson 21300 (
match event:).Root cause.
matchis structural pattern matching — Python 3.10+. The harness resolves its interpreter as:On macOS,
python3on PATH is/usr/bin/python3= Python 3.9.6 (the system interpreter). Lessons 21300/21301 exist precisely to teachmatch, so they cannot parse. Python 3.11 and 3.13 are both installed on this machine — they're just not what barepython3resolves to.This is not a curriculum bug and not a product bug. The codebase already knows the floor:
CodeExecutionConfiguration.MinimumPythonVersion = "3.10", andPythonInterpreterProbeHostedServicewarns at startup with a message that literally cites "matchstatements, Python 3.10+". Production's coderunner Dockerfile installs a currentpython3. The test harness is the only place that doesn't apply the floor — it runs whatever the OS hands it.Two things are wrong, and the second is the one that matters:
SyntaxErroron line 3 of a temp file — which reads exactly like "the lesson's reference solution is broken". It cost real time to work out that the curriculum was fine and the interpreter was stale. A version mismatch must say so.Fix shape: resolve a Python that meets
MinimumPythonVersion(probepython3, thenpython3.13/3.12/3.11/3.10, take the first that satisfies the floor —PythonVersionGate.ParseVersion/MeetsMinimumalready exist and are already unit-tested). HonourSPIKERSOFT_PYTHONwhen set, but validate it and fail loudly if it's below the floor. If no adequate interpreter exists, fail with an actionable message naming the found version and the required one — never a bareSyntaxError, and never a silent skip (a skip would hide genuine curriculum breakage, which is the whole point of these tests).Resolved in spikersoft-backend PR #287 (merged to
master).Root cause was neither the curriculum nor the product code: the test harness invoked bare
python3, which on macOS resolves to the system Python 3.9. Lessons 21300/21301 teach structural pattern matching (match), which is 3.10+. The reference solutions were correct all along — the interpreter running them was too old.CurriculumPythonInterpreternow probespython3,python3.13/3.12/3.11/3.10and selects the first that satisfies the product's ownCodeExecutionConfiguration.MinimumPythonVersion(3.10) via the existingPythonVersionGate, so the tests validate against the same floor production enforces rather than a second, hardcoded opinion.SPIKERSOFT_PYTHONis honoured but validated — if it points below the floor it throws with an actionable message.Deliberately not a
Skip: a skip here would have quietly stopped testing thematchlessons on every dev machine, which is how this stayed invisible.SpikerSoft.Business.Testsis now 7511 passed, 0 failed.Closing.