Support post-procesed inline expectations for query predicates in unit tests #19211
+68
−33
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.
This adds a low-friction way to add inline expectations to a unit test.
Any
.ql
file in a test folder can now use inline expectations without doing the dance of importing and instantiating a parameterised module.Example
Suppose we have a file
test.ql
with this content:We can now add a
test.qlref
in the same folder with the contents:And now the test will run with inline expectation checking. For example the test file might look like this:
Details
string
, becomes the value. This column may be omitted.test.ql
file must have no query kind for this to take effect. Queries of kindproblem
orpath-problem
are already supported in their own way.This PR ports a single test to use this in order to keep the PR small while ensuring the behaviour is exercised.
Thanks to @hmakholm for some corresponding fixes in the CLI, to ensure the same-named
.ql
and.qlref
files can coexist in the same folder without fighting over the same.actual
and.expected
file.