Repository navigation
Split test_language_standards_strict.py into per-language files - #1057
Merged
Merged
Conversation
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]>
Contributor
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]>
5 of 6 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
tests/extraction/was already restructured (epic #813) intotests/extraction/languages/test_<lang>.py, one file per language, sharing an_extraction_harness.pyhelper.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.pyfor the ReDoS-testing helpers (mirrors_extraction_harness.py's role)._strict-suffixed so the basenames don't collide withtests/extraction/languages/'s owntest_<lang>.pyfiles under pytest's default import mode (this repo has notests/__init__.pyanywhere).tests/core_engine/test_language_standards_strict.pynow 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).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=importlibinpyproject.toml. CI'sfull-suitejob 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 amultiprocessingsubprocess 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
tests/core_engine/+tests/extraction/unchanged: 5210 before and after.tests/core_engine/languages/+ residual file).tests/collection unaffected: 5463/5464 (1 golden_crucible deselected).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.pytest(notpython -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).🤖 Generated with Claude Code