Write parser output only after successful generation - #807
Open
ydah wants to merge 1 commit into
Open
Conversation
There was a problem hiding this comment.
🟢 Approval recommended
The change directly addresses the reported failure mode and includes targeted regression tests that cover both %expect mismatches and render exceptions without introducing obvious behavioral regressions.
Pull request overview
This pull request ensures Lrama only writes the generated parser output file after the computed states have been successfully validated, preventing build tools from treating an invalidated parser as up to date. It also adds regression coverage to confirm that %expect mismatches and rendering failures do not clobber parser outputs.
Changes:
- Reorders the command workflow to validate computed states before rendering/writing the parser output.
- Buffers rendered parser output in-memory and writes the output file only after rendering completes successfully.
- Adds command-level specs covering
%expectmismatch behavior (no output file created) and render exceptions preserving existing output.
File summaries
| File | Description |
|---|---|
| spec/lrama/command_spec.rb | Adds regression tests ensuring no output is written on %expect mismatch and existing output is preserved on render failure. |
| lib/lrama/command.rb | Validates states before rendering and buffers output in StringIO before writing to the target file. |
Review details
- Files reviewed: 2/2 changed files
- Comments generated: 0
- Review effort level: Lite
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
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.
Commandrendered the parser output before validating the computed states. When%expectdid not match the actual conflict count, Lrama exited with status 1 only after writing a complete output file, allowing build tools to treat an unvalidated parser as up to date.Validate the states before rendering the parser output. Render into an in-memory buffer and write the target file only after rendering completes, preserving an existing output file when rendering raises an exception.
Add command-level regression coverage for
%expectmismatches producing no parser output and rendering failures preserving existing output.