From 9a0cd59320a1a0e91272170809d29be49f472552 Mon Sep 17 00:00:00 2001 From: said Date: Sun, 24 May 2026 10:59:19 +0100 Subject: [PATCH] codex: remove C parser golden update path from tests --- .../c_parser_implementation_checklist.md | 11 ++++----- docs/c_parser/c_parser_reference.md | 8 +++---- tests/parser/c/README.md | 18 +++------------ tests/parser/c/test_c_error_fixture_suite.py | 23 ------------------- tests/parser/c/test_c_fixture_suite.py | 11 --------- 5 files changed, 11 insertions(+), 60 deletions(-) diff --git a/docs/c_parser/c_parser_implementation_checklist.md b/docs/c_parser/c_parser_implementation_checklist.md index 3d6def3f3..e20409a16 100644 --- a/docs/c_parser/c_parser_implementation_checklist.md +++ b/docs/c_parser/c_parser_implementation_checklist.md @@ -36,7 +36,7 @@ stable. ## Progress Snapshot - Last updated: 2026-05-24 -- Checklist progress: 623/873 checked (71.4%). +- Checklist progress: 622/872 checked (71.3%). - Current parser status: partial C parser with raw directive metadata, top-level source splitting, simple declarations/variables/typedefs, prototype-style metadata, K&R diagnostics, simple function signatures, and start/end @@ -406,12 +406,9 @@ Scope: header to dependent header. - [x] Generate separate one-file project goldens for STB single-file library inputs. -- [x] Support updating all fixtures. -- [x] Support updating selected fixtures. -- [x] Add an environment variable update flow, for example - `C_PARSER_UPDATE_GOLDENS=1`. -- [x] Document whether C uses `C_PARSER_UPDATE_GOLDENS` or a generic - `X2PY_UPDATE_GOLDENS`. +- [x] Regenerate all fixtures with the standalone golden script. +- [x] Regenerate selected fixtures with the standalone golden script. +- [x] Keep golden regeneration out of the comparison tests. - [x] Create a C error golden generator. - [x] Store expected error type, message fragments, diagnostic fragments, and parser entrypoint metadata. diff --git a/docs/c_parser/c_parser_reference.md b/docs/c_parser/c_parser_reference.md index 3bb75398f..212c9bd51 100644 --- a/docs/c_parser/c_parser_reference.md +++ b/docs/c_parser/c_parser_reference.md @@ -572,10 +572,10 @@ relative to `tests/data/c/` by adding either member filename; any matching sibling is included automatically. Fatal diagnostic goldens are regenerated with `python -m tests.parser.c.errors.generate_c_parser_error_goldens`. -The active fixture tests also honor `C_PARSER_UPDATE_GOLDENS=1`; C does not -use a generic update environment variable. Until include-expanded parsing is -implemented, a paired project records the source-to-header include edge but -parses the `.c` and `.h` members separately. +The parser goldens are regenerated by the standalone scripts above, not by +the comparison tests. Until include-expanded parsing is implemented, a paired +project records the source-to-header include edge but parses the `.c` and +`.h` members separately. STB is treated as a family of independent single-file libraries: each top-level `.h` or `.c` input generates its own one-file project golden rather diff --git a/tests/parser/c/README.md b/tests/parser/c/README.md index b11d76c76..6303bd4b7 100644 --- a/tests/parser/c/README.md +++ b/tests/parser/c/README.md @@ -22,10 +22,6 @@ cJSON corpus roadmap and compiler-preprocessed `.i`/`#line` behavior, which are not implemented yet. CLI, public API, and current project-resolution coverage are active. -When `C_PARSER_UPDATE_GOLDENS=1` is set, golden inventory checks are skipped -while their corresponding comparison tests rewrite the expected output. Those -update-mode skips are workflow behavior, not unsupported parser input. - ## Parser Goldens Active parser goldens cover grouped projects from `tests/data/c/general/`, @@ -63,12 +59,6 @@ Regenerate selected projects by naming either input relative to python -m tests.parser.c.generate_c_parser_goldens general/math_api.c json/cJSON.h ``` -The fixture comparison test also supports the explicit update mode: - -```bash -C_PARSER_UPDATE_GOLDENS=1 python -m pytest -q tests/parser/c/test_c_fixture_suite.py -``` - ## Error Goldens Fatal diagnostic fixtures live in `tests/data/c/errors/parser/` and their @@ -78,8 +68,6 @@ expected metadata lives in `fixtures/errors/`. Regenerate them with: python -m tests.parser.c.errors.generate_c_parser_error_goldens ``` -or update through the active regression test: - -```bash -C_PARSER_UPDATE_GOLDENS=1 python -m pytest -q tests/parser/c/test_c_error_fixture_suite.py -``` +The comparison tests are read-only. Regenerate the expected files with the +standalone generator, then rerun the tests to compare against the checked-in +baselines. diff --git a/tests/parser/c/test_c_error_fixture_suite.py b/tests/parser/c/test_c_error_fixture_suite.py index ab6debf81..5dfcc9a81 100644 --- a/tests/parser/c/test_c_error_fixture_suite.py +++ b/tests/parser/c/test_c_error_fixture_suite.py @@ -2,7 +2,6 @@ """C parser error fixture and diagnostic golden regression tests.""" import json -import os from pathlib import Path import pytest @@ -28,9 +27,6 @@ def test_c_error_fixture_suite_has_fixtures(): def test_c_error_fixtures_have_matching_expected_json(): - if os.getenv("C_PARSER_UPDATE_GOLDENS", "0") == "1": - pytest.skip("Golden outputs are being updated by the diagnostic comparison test.") - fixture_outputs = { f"{path.name}.json" for path in _ERRORS_DIR.glob("*") @@ -45,31 +41,12 @@ def test_c_error_fixtures_have_matching_expected_json(): def test_c_error_fixture_suite_reports_expected_diagnostics(): from c_parser import CParseError, parse_c_file - update_mode = os.getenv("C_PARSER_UPDATE_GOLDENS", "0") == "1" - for fixture in sorted(_ERRORS_DIR.glob("*")): if fixture.suffix.lower() not in _SOURCE_SUFFIXES: continue expected_path = _expected_path_for_fixture(fixture) source = fixture.read_text(encoding="utf-8") - if update_mode: - with pytest.raises(CParseError) as exc_info: - parse_c_file(source, filename=fixture.name) - payload = { - "parser": "parse_c_file", - "error_type": "CParseError", - "message_contains": [exc_info.value.base_message], - "diagnostic_contains": [ - f"error[{exc_info.value.code}]", - exc_info.value.base_message, - exc_info.value.source_line.strip() if exc_info.value.source_line else "", - ], - } - expected_path.parent.mkdir(parents=True, exist_ok=True) - expected_path.write_text(json.dumps(payload, indent=2) + "\n", encoding="utf-8") - continue - expected = _load_expected_error(expected_path) assert expected["parser"] == "parse_c_file" assert expected["error_type"] == "CParseError" diff --git a/tests/parser/c/test_c_fixture_suite.py b/tests/parser/c/test_c_fixture_suite.py index 02b6a76c8..be550f0e6 100644 --- a/tests/parser/c/test_c_fixture_suite.py +++ b/tests/parser/c/test_c_fixture_suite.py @@ -2,7 +2,6 @@ """C parser grouped-project fixture/golden regression tests.""" import json -import os from pathlib import Path import pytest @@ -110,9 +109,6 @@ def test_c_fixture_golden_suite_has_inputs(data_subdir): @pytest.mark.parametrize("data_subdir", _FIXTURE_GROUPS) def test_c_parser_project_goldens_match_fixture_stems_one_to_one(data_subdir): - if os.getenv("C_PARSER_UPDATE_GOLDENS", "0") == "1": - pytest.skip("Golden outputs are being updated by the comparison test.") - data_root = _DATA_DIR / data_subdir fixture_root = _FIXTURES_DIR / data_subdir @@ -125,17 +121,10 @@ def test_c_parser_project_goldens_match_fixture_stems_one_to_one(data_subdir): @pytest.mark.parametrize("data_subdir", _FIXTURE_GROUPS) def test_c_fixture_golden_suite_compares_project_json(data_subdir): - update_mode = os.getenv("C_PARSER_UPDATE_GOLDENS", "0") == "1" - for project_key, fixtures in _project_groups(_DATA_DIR / data_subdir): expected_path = _expected_path_for_project(data_subdir, project_key) parsed = _serialize_project(fixtures) - if update_mode: - expected_path.parent.mkdir(parents=True, exist_ok=True) - expected_path.write_text(json.dumps(parsed, indent=2) + "\n", encoding="utf-8") - continue - expected = json.loads(expected_path.read_text(encoding="utf-8")) assert parsed == expected