Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 4 additions & 7 deletions docs/c_parser/c_parser_implementation_checklist.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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.
Expand Down
8 changes: 4 additions & 4 deletions docs/c_parser/c_parser_reference.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
18 changes: 3 additions & 15 deletions tests/parser/c/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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/`,
Expand Down Expand Up @@ -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
Expand All @@ -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.
23 changes: 0 additions & 23 deletions tests/parser/c/test_c_error_fixture_suite.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
"""C parser error fixture and diagnostic golden regression tests."""

import json
import os
from pathlib import Path

import pytest
Expand All @@ -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("*")
Expand All @@ -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"
Expand Down
11 changes: 0 additions & 11 deletions tests/parser/c/test_c_fixture_suite.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
"""C parser grouped-project fixture/golden regression tests."""

import json
import os
from pathlib import Path

import pytest
Expand Down Expand Up @@ -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

Expand All @@ -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

Expand Down
Loading