Skip to content

Conversation

@Sukanto01899
Copy link

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

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