Skip to content

Defer ast parsing#8

Merged
rliebz merged 3 commits into
mainfrom
defer-ast-parsing
May 4, 2026
Merged

Defer ast parsing#8
rliebz merged 3 commits into
mainfrom
defer-ast-parsing

Conversation

@rliebz

@rliebz rliebz commented May 4, 2026

Copy link
Copy Markdown
Owner

No description provided.

rliebz added 3 commits May 4, 2026 09:35
While on an individual basis, assertions are relatively cheap, it turns
out to not be so cheap when you put a whole test suite together. This
delays building the error message, and in particular, performing AST
parsing, until someone actually attempts to print it. Which means a
passing test suite never pays the cost.

As future work in this vein, it might also make sense to cache parsed
files such that multiple failing calls in the same file don't parse the
file multiple times.

This includes a breaking change to `ghostlib` to allow lazily evaluating
arguments while still being roughly as easy to use.
This moves to a single `FileSet` and one call to `ParseFile` per file.
While this does add what should be a pretty small bit of overhead in
terms of global state, what this accomplishes is that if more than one
assertion needs to print information from the same file, we don't parse
the file from disk over and over again.
@rliebz rliebz merged commit 6d2b5bf into main May 4, 2026
5 checks passed
@rliebz rliebz deleted the defer-ast-parsing branch May 4, 2026 14:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant