[K9VULN-1925] fix: improve unsound test by testing the production code path #587
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.
What problem are you trying to solve?
In #555 we added support for timing out tree-sitter query executions, as this was necessary to prevent the analyzing spinning forever in case a query suffered from combinatorial explosion. However, with that change, the test added to verify this actually works used the
shorthand_execute_rule_internal
function, when it should have usedshorthand_execute_rule
instead because the former does not test the production code path, so any changes toJsRuntime::execute_rule
that affect the query timeout will not be caught by the test, unless the corresponding internal function is updated as well.What is your solution?
Instead of using
shorthand_execute_rule_internal
, we should be usingshorthand_execute_rule
to test the production code path, which this PR does.Alternatives considered
What the reviewer should know
shorthand_execute_rule
takes in an optionalExecuteOptions
struct. All tests that use this function, though, pass inNone
for this argument, and as such, never suffered from the fact that the fields of this struct are private, and there's no method on this struct to create an instance of it. As such, I've marked the fields aspub(crate)
so that I can create this struct with a timeout and pass it intoshorthand_execute_rule
.