Skip to content

Commit

Permalink
Verify that Runic's output is parseable (#69)
Browse files Browse the repository at this point in the history
This doesn't cost much (5 % perf hit for some large files) and can catch
some errors. Note that it isn't possible/trivial to compare the trees
since the formatter make changes to it.
  • Loading branch information
fredrikekre authored Oct 18, 2024
1 parent 5500f9b commit fcc4611
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/Runic.jl
Original file line number Diff line number Diff line change
Expand Up @@ -496,6 +496,13 @@ function format_tree!(ctx::Context)
end
# Truncate the output at the root span
truncate(ctx.fmt_io, span(root′))
# Check that the output is parseable
try
fmt_str = String(read(seekstart(ctx.fmt_io)))
JuliaSyntax.parseall(JuliaSyntax.GreenNode, fmt_str; ignore_warnings = true, version = v"2-")
catch
throw(AssertionError("re-parsing the formatted output failed"))
end
# Set the final tree
ctx.fmt_tree = root′
return nothing
Expand Down

2 comments on commit fcc4611

@fredrikekre
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JuliaRegistrator
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Registration pull request updated: JuliaRegistries/General/117521

Tip: Release Notes

Did you know you can add release notes too? Just add markdown formatted text underneath the comment after the text
"Release notes:" and it will be added to the registry PR, and if TagBot is installed it will also be added to the
release that TagBot creates. i.e.

@JuliaRegistrator register

Release notes:

## Breaking changes

- blah

To add them here just re-invoke and the PR will be updated.

Tagging

After the above pull request is merged, it is recommended that a tag is created on this repository for the registered package version.

This will be done automatically if the Julia TagBot GitHub Action is installed, or can be done manually through the github interface, or via:

git tag -a v1.0.0 -m "<description of version>" fcc46113893ae619906258919e765765ce65a2c6
git push origin v1.0.0

Please sign in to comment.