Skip to content

Port Python CI test scripts to in-process Lean tests#5

Draft
joehendrix wants to merge 3 commits into
mainfrom
jhx/lean-ci
Draft

Port Python CI test scripts to in-process Lean tests#5
joehendrix wants to merge 3 commits into
mainfrom
jhx/lean-ci

Conversation

@joehendrix

Copy link
Copy Markdown
Contributor

Continues the CI work from #1 by moving Python-specific test scripts in-process as StrataPythonTestExtra Lean tests, following the CpythonDiffTest precedent. Each ports the per-case work to library calls (spawning strata_python.gen only where Python parsing is genuinely needed), and is run once in build_and_test_lean (excluded from the per-version build_python matrix).

Commits

  1. SARIF + regex ports + lakefile fix (9d25563)

    • run_py_analyze_sarif.py + validate_sarif.pySarifTest.lean: runs runPyAnalyzePipeline in-process and asserts on the typed SarifDocument (no JSON round-trip, no lake exe).
    • Regex/diff_test.pyRegexDiffTest.lean: runs Strata's SMT regex backend in-process; the Python re oracle stays a subprocess (regex_oracle.py, spawned once). Corpus moved to corpus.tsv. Counts identical to the original (468 agree / 0 bugs / 66 known gaps / 0 investigate).
    • lakefile: treat the PythonDialectIon input as binary (drop text = true).
  2. pyInterpret port (884b6cf)

    • run_py_interpret.shInterpretTest.lean: runs the interpreter pipeline in-process per tests/test_*.py, checked against expected_interpret/. Replaces 219 lake exe pyInterpret spawns (the shell version times out past 10 min locally).
    • Updated 4 expected files that matched only the generic CLI hint Run strata --help for additional help. to assert the actual interpreter error — strictly stronger checks.
  3. Remove orphaned Script exes (6bb4618)

    • Delete the Scripts/ exe wrappers + lean_exe targets for pyInterpret, pyAnalyzeToGoto, pyTranslateLaurel, pySpecToLaurel, pyResolveOverloads, pySpecs — none have a remaining caller. The underlying StrataPython.Cli.*Command defs are untouched (Strata-CLI wires them into its strata binary). Kept pyAnalyzeLaurel and pyAnalyzeLaurelToGoto (still used by run_py_analyze.sh / py_ion_to_cbmc.sh).

Migration status

Migrated to Lean: CPython (PR #1), SARIF, regex, pyInterpret. Remaining: run_py_analyze.sh (portable, not yet done) and run_py_cbmc_tests.sh (needs external cbmc, stays shell).

Validation

Each test verified locally (compiles + passes; counts cross-checked against the original scripts where applicable). lake build succeeds after the exe removal. Opening as draft to confirm GitHub CI is green.

🤖 Generated with Claude Code

joehendrix and others added 3 commits June 24, 2026 10:33
Move two CI test scripts in-process as StrataPythonTestExtra Lean tests,
following the CpythonDiffTest precedent, and fix a related lakefile bug.

SARIF (replaces run_py_analyze_sarif.py + validate_sarif.py):
StrataPythonTestExtra/SarifTest.lean spawns strata_python.gen to compile
each tests/test_*.py to Ion, runs StrataPython.Pipeline.runPyAnalyzePipeline
(the same path `pyAnalyzeLaurel --sarif` drives), builds the SARIF document
via Core.Sarif.vcResultsToSarif, and asserts on the typed SarifDocument
directly. Most of the Python validator's checks now hold by construction;
the per-test checks, tool name, and SKIP_TESTS set are ported. Drops a
`lake exe` subprocess and the JSON parse/re-validate round trip.

Regex (replaces Regex/diff_test.py):
StrataPythonTestExtra/RegexDiffTest.lean runs Strata's SMT regex backend
in-process (lifting checkMatch from DiffTestCore.lean) and compares against
Python's `re`, which has no in-process equivalent and stays a subprocess:
Regex/regex_oracle.py reads the corpus on stdin, spawned once. The 534-case
corpus moves to Regex/corpus.tsv. Verdict classification matches the Python
driver; counts are identical (468 agree, 0 bugs, 66 known gaps, 0 investigate).
The DiffTestCore executable is kept (it has a --log-dir debugging feature).

lakefile: treat the PythonDialectIon input_file as binary (drop `text = true`);
the dialect Ion file is binary and reading it as text is incorrect.

CI: build_and_test_lean runs both via `lake test -- <Test>`; the build_python
matrix excludes them (SMT-heavy and version-independent, run once not per
Python version).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Replace run_py_interpret.sh with StrataPythonTestExtra/InterpretTest.lean.
For each tests/test_*.py it spawns strata_python.gen to compile to Ion, then
runs the interpreter pipeline in-process — the same path Cli.lean's
pyInterpret drives (pythonAndSpecToLaurel -> translateCombinedLaurel ->
typeCheck -> core.run + runCall __main__) — and checks expected_interpret/:
no .expected/.skip means run to completion; a .expected means fail with
matching text; a .skip means skip. The committed patterns are escaped
literals, so the match reduces to substring containment after unescaping
\X -> X (no regex engine needed).

Running in-process replaces 219 `lake exe pyInterpret` subprocess spawns
(the shell version times out past 10 min locally).

Update 4 expected files (test_class_no_init_extra_args, test_is_non_none,
test_is_not_non_none, test_user_error_metadata): they matched only the
generic CLI hint "Run strata --help for additional help." — a Cli framework
artifact the in-process path doesn't emit — so they now assert the actual,
stable interpreter error for each, making the checks strictly stronger.

CI: build_and_test_lean runs it via `lake test -- InterpretTest`; the
build_python matrix excludes it alongside the other in-process suites.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Delete the Scripts/ executable wrappers and their lean_exe targets for
pyInterpret, pyAnalyzeToGoto, pyTranslateLaurel, pySpecToLaurel,
pyResolveOverloads, and pySpecs. None are invoked by any script, workflow,
or test: pyInterpret's only caller (run_py_interpret.sh) was ported to the
InterpretTest Lean test, and the other five had no caller.

The underlying StrataPython.Cli.*Command definitions are untouched — the
standalone Strata-CLI repo wires all of them into its unified `strata`
binary, so only the per-command standalone exes are removed here.

Kept: pyAnalyzeLaurel (used by run_py_analyze.sh) and pyAnalyzeLaurelToGoto
(used by py_ion_to_cbmc.sh).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant