Skip to content

Split test_language_standards_strict.py into per-language files - #1057

Merged
squid-protocol merged 2 commits into
mainfrom
split-strict-tests
Aug 5, 2026
Merged

squid-protocol merged 2 commits into
mainfrom
split-strict-tests

Conversation

@squid-protocol

@squid-protocol squid-protocol commented Aug 5, 2026 •

Copy link
Copy Markdown
Owner

Summary

tests/extraction/ was already restructured (epic #813) into tests/extraction/languages/test_<lang>.py, one file per language, sharing an _extraction_harness.py helper. tests/core_engine/test_language_standards_strict.py — the strict structural-signature suite — never got the same treatment: a single 14,664-line, 621-test file. This splits it the same way.

  • tests/core_engine/languages/test_<lang>_strict.py — one file per language (45 total), sharing _strict_harness.py for the ReDoS-testing helpers (mirrors _extraction_harness.py's role). _strict-suffixed so the basenames don't collide with tests/extraction/languages/'s own test_<lang>.py files under pytest's default import mode (this repo has no tests/__init__.py anywhere).
  • tests/core_engine/test_language_standards_strict.py now holds only the 5 genuinely global/cross-language tests (registry-wide sanity checks, the harness's own self-tests, and the one test issue spec_exposure's unbounded [^\]]* ReDoS is copy-pasted across 28 languages, including already-merged yacc #713 explicitly wrote as a single parametrized cross-language test rather than duplicated per language).
  • Verified via AST parsing that every one of the 621 test functions and 93 shared module-level constants attributes unambiguously to exactly one language before generating the split.
  • Updated every doc/comment that pointed at the old monolithic file by name or hardcoded its path in a pytest invocation (CLAUDE.md, tests/README.md, tests/core_engine/readme.md, how_to_add_a_language.md, how_to_harden_extraction.md, LESSONS_LEARNED.md, scripts/update_golden_masters.sh, and two cross-file test/production-code comments) so the repo stays internally consistent.

No regex/parsing logic changed — this is a pure test-file reorganization plus doc updates.

Note on iteration: the first version of this PR fixed the basename collision globally via --import-mode=importlib in pyproject.toml. CI's full-suite job caught that this broke an unrelated, pre-existing test (test_supply_chain_firewall.py::test_absolute_path_does_not_infinite_loop_in_alias_resolution) that spawns a multiprocessing subprocess to pickle a module-level function reference — under importlib mode, that module gets a dotted name (tests.security_auditing.test_supply_chain_firewall) that isn't a real importable package (no __init__.py), so the spawned child can't re-import it. Reverted that and fixed the actual collision narrowly instead (renaming the new files), which doesn't touch global pytest import behavior at all.

Test plan

  • Collected test count for tests/core_engine/ + tests/extraction/ unchanged: 5210 before and after.
  • All 2,536 tests in the strict-signature suite pass (tests/core_engine/languages/ + residual file).
  • Full tests/ collection unaffected: 5463/5464 (1 golden_crucible deselected).
  • Full repo-wide pytest tests/ run: 5447 passed, 2 skipped, 1 deselected, 11 xfailed, 3 xpassed — identical to the pre-split baseline, confirming the earlier multiprocessing regression is gone.
  • Bare pytest (not python -m pytest) invocation from an unrelated cwd, confirming the sys.path bootstrap works under CI's actual invocation style.
  • python tests/tools/audit_check.py — clean (ruff/mypy/dead-key baselines unaffected; the file-move's findings were recognized as relocated, not new).
  • CI green (crucible-audit, full-suite, ruff/mypy/dead-key audits, smoke-test matrix, CodeQL, etc.) after the fix commit.

🤖 Generated with Claude Code

The 14,664-line, 621-test strict structural-signature suite never got the
same per-language treatment as tests/extraction/languages/ (epic #813).
Split it the same way: tests/core_engine/languages/test_<lang>.py, one file
per language, sharing a _strict_harness.py ReDoS-testing helper module
(mirroring _extraction_harness.py). test_language_standards_strict.py now
holds only the 5 genuinely global/cross-language tests plus the harness
import.

Verified via AST parsing that every one of the 621 test functions and 93
shared module-level constants attributes unambiguously to exactly one
language before generating the split, and that all 2,536 tests in this
suite still pass afterward (collected count unchanged).

Also required --import-mode=importlib in pyproject.toml: this repo has no
tests/__init__.py anywhere, so once tests/core_engine/languages/ and
tests/extraction/languages/ both contain same-named files (test_python.py,
test_php.py, ...), pytest's default "prepend" import mode collides on
basename. importlib mode keys modules by full path instead, with no
__init__.py needed.

Updated every doc/comment that pointed at the old monolithic file by name
or hardcoded its path in a pytest invocation (CLAUDE.md, tests/README.md,
tests/core_engine/readme.md, how_to_add_a_language.md,
how_to_harden_extraction.md, LESSONS_LEARNED.md,
scripts/update_golden_masters.sh, and two cross-file test/production-code
comments) so the repo stays internally consistent.

Co-Authored-By: Claude Sonnet 5 <[email protected]>
@github-actions

github-actions Bot commented Aug 5, 2026

Copy link
Copy Markdown
Contributor

🐦‍⬛ Muninn Security Scan

✅ No security issues found.

🐦‍⬛ Powered by Muninn · Skald Lab

The previous commit resolved tests/core_engine/languages/ vs
tests/extraction/languages/ sharing basenames (test_python.py, test_php.py,
...) by adding --import-mode=importlib to pyproject.toml's pytest addopts.
That's a global behavior change, and it broke an unrelated, pre-existing
test: tests/security_auditing/test_supply_chain_firewall.py::
test_absolute_path_does_not_infinite_loop_in_alias_resolution spawns a
multiprocessing subprocess to pickle a reference to a module-level helper
function. Under importlib mode (this pytest version), the module gets
registered under a dotted name like tests.security_auditing.test_supply_
chain_firewall -- but there's no tests/__init__.py anywhere in this repo, so
the spawned child can't re-import that dotted path: ModuleNotFoundError: No
module named 'tests'. Caught by this repo's own CI (crucible-audit's
full-suite job), not locally, since that specific test wasn't part of the
core_engine/extraction slice I'd been verifying against.

Reverted the addopts change. Fixed the actual collision the narrow way
instead: renamed tests/core_engine/languages/test_<lang>.py to
test_<lang>_strict.py, so basenames no longer collide with
tests/extraction/languages/test_<lang>.py under pytest's default "prepend"
import mode. Updated the doc references accordingly.

Full repo-wide `pytest tests/` re-verified clean: 5447 passed, 2 skipped,
1 deselected, 11 xfailed, 3 xpassed -- identical to the pre-split baseline.

Co-Authored-By: Claude Sonnet 5 <[email protected]>
@squid-protocol
squid-protocol merged commit d6d2e6f into main Aug 5, 2026
28 checks passed
@squid-protocol
squid-protocol deleted the split-strict-tests branch August 5, 2026 16:56
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