lawsynth/tests/test_scientific.py
caelum0x c44ed79ea2 feat(ci): add release-build workflow and fix nightly-science test collection
- release-build.yml: new workflow_dispatch-independent job triggered on v*
  tags, building the lawsynth CLI on a macos-latest/ubuntu-latest matrix
  (same cargo build --release --locked -p lawsynth-cli command release.yml's
  verification job already runs) and uploading the packaged binaries as
  GitHub Release assets via softprops/action-gh-release. Does not modify
  release.yml, which stays verify-only and workflow_dispatch-triggered.
- nightly-science.yml: was running `pytest tests/scientific tests/conformance`
  directly, which collects zero tests (exit code 5) because those directories
  hold declarative run.py fixtures, not test_*.py files. Added a Rust
  toolchain + CLI build step and a new tests/test_scientific.py pytest
  wrapper (mirroring the existing tests/test_conformance.py pattern) that
  parametrizes one test per case and runs each case's own run.py via
  runpy.run_path against the native engine, then pointed the job at the two
  real wrapper modules.

Verified locally: cargo fmt --check, cargo clippy --workspace --all-targets
-- -D warnings, and cargo test --workspace all clean; actionlint clean on
release-build.yml, nightly-science.yml, and (unchanged) release.yml;
`pytest tests/test_scientific.py tests/test_conformance.py` passes (22/22)
against the compiled CLI.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
2026-10-15 20:00:13 +03:00

30 lines
1.1 KiB
Python

"""Scientific suite: execute each case's declared ``run.py`` as a real test.
Each case under ``tests/scientific`` ships a standalone, directly-executable
``run.py`` (see the per-case ``README.md`` and ``case.toml``'s
``[execution] runner = "python3 run.py"``) that drives the compiled native
engine against a declarative fixture and asserts the result in
``_support.py``. Pointing a bare ``pytest`` invocation at the
``tests/scientific`` directory collects zero tests, because none of these
files match pytest's ``test_*.py`` discovery pattern. This module runs each
case's ``run.py`` exactly as its own ``if __name__ == "__main__":`` guard
intends, parametrized one case per test, so the suite is both collectible by
pytest and faithful to the fixtures' own declared execution contract.
"""
from __future__ import annotations
import runpy
from pathlib import Path
import pytest
from conftest import discover_cases
_CASES = discover_cases("scientific")
@pytest.mark.parametrize("case_dir", _CASES, ids=[case.name for case in _CASES])
def test_scientific_case(case_dir: Path) -> None:
runpy.run_path(str(case_dir / "run.py"), run_name="__main__")