Fix flow parser when no test functions exist #21
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.
As a Clarinet test author, I want flow parsing to succeed even when a contract contains no test- functions, so I can run tooling against utility-only contracts without errors. This is needed because the parser currently assumes at least one flow test and can throw or emit empty-key results. This pull request adds an early return when no tests are found and includes a regression test/fixture.
Motivation for change
Prevent crashes and invalid output when parsing contracts without flow tests.
What was changed
Added a guard to return empty annotations/bodies when no test- functions exist.
Added a no-flow contract fixture and a test asserting empty results.
How does this impact application developers
No API changes; flow parsing becomes more robust for contracts that lack flow tests.
Link to relevant issues and documentation
N/A
Provide examples of use cases with code samples and applicable acceptance criteria
const [annotations, callInfos] = extractTestAnnotationsAndCalls(contractSource, simnet);
// Acceptance criteria:
annotations === {}
callInfos === {}
Type of Change
Bug fix
Does this introduce a breaking change?
No breaking changes.
Are documentation updates required?
Link to documentation updates: N/A
Testing information
Is testing required for this change?
Yes.
If it’s a bug fix, list steps to reproduce the bug
Run extractTestAnnotationsAndCalls on a contract with no test- functions; prior behavior could throw or yield invalid results.
Briefly mention affected code paths
extractTestAnnotationsAndCalls in clarity-parser-flow-tests.ts
List other affected projects if possible
None known.
Things to watch out for when testing
Ensure no-flow contracts return empty objects.
Existing flow tests still parse correctly.
Checklist
Code is commented where needed
Unit test coverage for new or modified code paths
npm run test passes
Changelog is updated
Tag 1 of @person1 or @Person2