Skip to content

fix(parsing): adding check for acceptance test heading#226

Merged
zanjonke merged 4 commits into
mainfrom
fix/acceptance-tests
Jun 29, 2026
Merged

fix(parsing): adding check for acceptance test heading#226
zanjonke merged 4 commits into
mainfrom
fix/acceptance-tests

Conversation

@zanjonke

@zanjonke zanjonke commented Jun 23, 2026

Copy link
Copy Markdown
Contributor

Summary

Improves handling of acceptance tests in .plain files:

  1. Placement validation — acceptance tests must be nested under a specific functional spec. They are now rejected both when they appear at the top level and when nested under any other section (definitions, implementation reqs, test reqs), raising a PlainSyntaxError with a clear message and line number.
  2. Conformance script warning — when acceptance tests are found but no conformance tests script is configured, a warning is logged. Acceptance tests are treated as conformance tests, so a conformance tests script is required to actually run them. The warning is emitted on both the normal render path and --dry-run, and covers the top module and all required modules in both cases.

Changes

  • plain_file.py:
    • Raise PlainSyntaxError when an acceptance tests heading appears at the top level instead of nested under a functional spec.
    • Add _find_acceptance_test_heading() to recursively search a section's token tree for an acceptance tests heading.
    • After parsing, scan the non-functional sections (definitions, implementation reqs, test reqs) and reject any nested acceptance tests heading.
  • plain_spec.py: add has_acceptance_tests() helper to detect whether a plain source defines acceptance tests.
  • plain2code.py:
    • Add warn_acceptance_tests_without_conformance_script() (core helper, takes module names) and warn_if_acceptance_tests_without_conformance_script() (module-based wrapper covering the top module and all required modules).
    • Call the module-based wrapper after the module is loaded in the render path.
    • In --dry-run, build a real PlainModule (recursively parses required modules, no API calls) and call the module-based wrapper so the warning covers required modules there too.

Tests

  • tests/test_plainfileparser.py: top-level rejection, nested-under-definitions/implementation reqs/test reqs rejection, and a regression guard that properly nested acceptance tests under a functional spec are allowed.
  • tests/test_plainspec.py: has_acceptance_tests() true/false/empty/no-functional-requirements cases.
  • tests/test_plain2code.py: warning emitted with no conformance script, suppressed when configured, suppressed without acceptance tests, emitted when acceptance tests live only in a required module, core-helper cases, and an integration test building a real PlainModule (main module without acceptance tests requiring a module that has them) asserting the required module is named in the warning.
  • tests/data/acceptance_tests_warning/: fixtures for the integration test.

@zanjonke zanjonke requested a review from VitjanZ June 23, 2026 09:49
@zanjonke zanjonke self-assigned this Jun 23, 2026
@zanjonke zanjonke added the bug Something isn't working label Jun 23, 2026
@zanjonke zanjonke force-pushed the fix/acceptance-tests branch 2 times, most recently from ae775bf to 2d8764a Compare June 23, 2026 12:45
…ests script

Acceptance tests are treated as conformance tests, so a conformance tests
script is required to run them. Emit a warning (covering the top module and
all required modules) on both the render and --dry-run paths when acceptance
tests are present but no conformance tests script is configured.
@zanjonke zanjonke force-pushed the fix/acceptance-tests branch from 2d8764a to 4682d44 Compare June 23, 2026 12:48
Previously the module was constructed in both the dry-run branch and inside
render(), and render() re-parsed the file again just to compute the render
range. Parse the plain file once in main() and pass the PlainModule into
render(), removing the duplicate construction and the redundant re-parse.
@zanjonke zanjonke merged commit 7f87eb2 into main Jun 29, 2026
10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants