Skip to content

[move] Add test-ony coverage gathering and differential test coverage #22007

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged

Conversation

tzakian
Copy link
Contributor

@tzakian tzakian commented Apr 29, 2025

Description

This builds on top of the LCOV support for Move in the PR below this to add two new commands:

  • --only-test <test-name> where test-name is the name of the test (can be either the function name or module_name::function_name of the test).
  • --differential-test <test-name> this computes the "differential coverage" as inspired by this article. Basically for a test T
    • If the code is hit only by T then it will show as "covered"
    • If the code is hit by both T and other tests than it will show as "uncovered"
    • If the code is either not hit at all, or only by other tests, then it will not show up as covered/uncovered at all.

Test plan

Added tests to the Move CLI for this.

Some examples of the output

move coverage lcov 

Screenshot 2025-04-29 at 1 49 15 PM

move coverage lcov --only-test f21

Screenshot 2025-04-29 at 1 50 30 PM

move coverage lcov --differential-test f21

Screenshot 2025-04-29 at 1 49 46 PM


Release notes

Check each box that your changes affect. If none of the boxes relate to your changes, release notes aren't required.

For each box you select, include information after the relevant heading that describes the impact of your changes that a user might notice and any actions they must take to implement updates.

  • Protocol:
  • Nodes (Validators and Full nodes):
  • gRPC:
  • JSON-RPC:
  • GraphQL:
  • CLI: Adds support for more advanced LCOV-based Move coverage information -- both individual and differential test summary information is now supported.
  • Rust SDK:

@tzakian tzakian requested review from amnn, awelc and a team April 29, 2025 21:21
Copy link

vercel bot commented Apr 29, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
sui-docs ✅ Ready (Inspect) Visit Preview 💬 Add feedback May 2, 2025 10:53pm
2 Skipped Deployments
Name Status Preview Comments Updated (UTC)
multisig-toolkit ⬜️ Ignored (Inspect) Visit Preview May 2, 2025 10:53pm
sui-kiosk ⬜️ Ignored (Inspect) Visit Preview May 2, 2025 10:53pm

@tzakian tzakian temporarily deployed to sui-typescript-aws-kms-test-env April 29, 2025 21:21 — with GitHub Actions Inactive
@tzakian tzakian force-pushed the tzakian/move-lcov-differential-coverage branch from b97a62a to 75ac6e4 Compare April 29, 2025 21:28
@tzakian tzakian temporarily deployed to sui-typescript-aws-kms-test-env April 29, 2025 21:28 — with GitHub Actions Inactive
@tzakian tzakian force-pushed the tzakian/move-lcov-differential-coverage branch from 75ac6e4 to 24c03da Compare April 29, 2025 22:42
@tzakian tzakian temporarily deployed to sui-typescript-aws-kms-test-env April 29, 2025 22:42 — with GitHub Actions Inactive
@tzakian tzakian force-pushed the tzakian/move-lcov-differential-coverage branch from 24c03da to 378924b Compare April 29, 2025 22:57
@tzakian tzakian temporarily deployed to sui-typescript-aws-kms-test-env April 29, 2025 22:57 — with GitHub Actions Inactive
Comment on lines +53 to +56
differential: Option<String>,
/// Compute coverage for the provided test name. Only this test will contribute to the
/// coverage calculation.
#[clap(long = "only-test", conflicts_with = "differential")]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this be an enum? Or is that more trouble than it is worth?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I looked into it and it's possible, but I'd classify it as more trouble than it's worth and leads to a (IMHO) slightly weird command texture where differential and only-test become subcommands as opposed to args/flags.

@tzakian tzakian force-pushed the tzakian/move-lcov-support branch from 2b75801 to 9adaf27 Compare May 2, 2025 18:29
@tzakian tzakian force-pushed the tzakian/move-lcov-differential-coverage branch from 378924b to a082257 Compare May 2, 2025 18:29
@tzakian tzakian temporarily deployed to sui-typescript-aws-kms-test-env May 2, 2025 18:29 — with GitHub Actions Inactive
@tzakian tzakian force-pushed the tzakian/move-lcov-support branch from 9adaf27 to f2d7eca Compare May 2, 2025 22:50
@tzakian tzakian force-pushed the tzakian/move-lcov-differential-coverage branch from a082257 to bad1f36 Compare May 2, 2025 22:50
@tzakian tzakian temporarily deployed to sui-typescript-aws-kms-test-env May 2, 2025 22:50 — with GitHub Actions Inactive
@tzakian tzakian merged commit 15e210f into tzakian/move-lcov-support May 12, 2025
46 of 48 checks passed
@tzakian tzakian deleted the tzakian/move-lcov-differential-coverage branch May 12, 2025 17:43
tzakian added a commit that referenced this pull request May 12, 2025
…#22007)

## Description 

This builds on top of the LCOV support for Move in the PR below this to
add two new commands:
* `--only-test <test-name>` where `test-name` is the name of the test
(can be either the function name or `module_name::function_name` of the
test).
* `--differential-test <test-name>` this computes the "differential
coverage" as inspired by [this
article](https://research.swtch.com/diffcover). Basically for a test `T`
    - If the code is hit only by `T` then it will show as "covered"
- If the code is hit by both `T` and other tests than it will show as
"uncovered"
- If the code is either not hit at all, or only by other tests, then it
will not show up as covered/uncovered at all.

## Test plan 

Added tests to the Move CLI for this.

Some examples of the output

```
move coverage lcov 
```

![Screenshot 2025-04-29 at 1 49
15 PM](https://github.com/user-attachments/assets/5004d86b-3ee7-4ef4-a88f-3feacddfbf43)


```
move coverage lcov --only-test f21
```

![Screenshot 2025-04-29 at 1 50
30 PM](https://github.com/user-attachments/assets/007426d1-4bad-4780-bdf2-135cbd3356ab)


```
move coverage lcov --differential-test f21
```

![Screenshot 2025-04-29 at 1 49
46 PM](https://github.com/user-attachments/assets/f46b49b5-4dd3-4287-af3b-370e11e73239)


---

## Release notes

Check each box that your changes affect. If none of the boxes relate to
your changes, release notes aren't required.

For each box you select, include information after the relevant heading
that describes the impact of your changes that a user might notice and
any actions they must take to implement updates.

- [ ] Protocol: 
- [ ] Nodes (Validators and Full nodes): 
- [ ] gRPC:
- [ ] JSON-RPC: 
- [ ] GraphQL: 
- [X] CLI: Adds support for more advanced LCOV-based Move coverage
information -- both individual and differential test summary information
is now supported.
- [ ] Rust SDK:
tzakian pushed a commit that referenced this pull request May 12, 2025
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.

2 participants