feat(gnovm): implement coverage support with -covermode flag
git commit -m "feat(gnovm): implement coverage support with -covermode flag
- Add -cover flag to enable coverage analysis
- Add -covermode flag supporting set/count/atomic modes
- Add -coverprofile flag for generating coverage profiles
- Implement coverage tracking in GnoVM execution engine
- Add comprehensive test coverage and documentation
- Enable CI integration with coverage analysis
Fixes #1121, #2908
🛠 PR Checks Summary
🔴 Changes to 'docs' folder must be reviewed/authored by at least one devrel and one tech-staff 🔴 Pending initial approval by a review team member, or review from tech-staff
Manual Checks (for Reviewers):
- [ ] IGNORE the bot requirements for this PR (force green CI check)
- [ ] The pull request description provides enough details
Read More
🤖 This bot helps streamline PR reviews by verifying automated checks and providing guidance for contributors and reviewers.
✅ Automated Checks (for Contributors):
🟢 Maintainers must be able to edit this pull request (more info) 🔴 Changes to 'docs' folder must be reviewed/authored by at least one devrel and one tech-staff 🔴 Pending initial approval by a review team member, or review from tech-staff
☑️ Contributor Actions:
- Fix any issues flagged by automated checks.
- Follow the Contributor Checklist to ensure your PR is ready for review.
- Add new tests, or document why they are unnecessary.
- Provide clear examples/screenshots, if necessary.
- Update documentation, if required.
- Ensure no breaking changes, or include
BREAKING CHANGEnotes. - Link related issues/PRs, where applicable.
☑️ Reviewer Actions:
- Complete manual checks for the PR, including the guidelines and additional checks if applicable.
📚 Resources:
Debug
Automated Checks
Maintainers must be able to edit this pull request (more info)
If
🟢 Condition met └── 🟢 And ├── 🟢 The base branch matches this pattern: ^master$ └── 🟢 The pull request was created from a fork (head branch repo: sudhanshu112233shukla/gno)Then
🟢 Requirement satisfied └── 🟢 Maintainer can modify this pull requestChanges to 'docs' folder must be reviewed/authored by at least one devrel and one tech-staff
If
🟢 Condition met └── 🟢 And ├── 🟢 The base branch matches this pattern: ^master$ └── 🟢 A changed file matches this pattern: ^docs/ (filename: docs/resources/gno-coverage.md)Then
🔴 Requirement not satisfied └── 🔴 And ├── 🔴 Or │ ├── 🔴 Pull request author is a member of the team: tech-staff │ └── 🔴 At least 1 user(s) of the team tech-staff reviewed pull request(with state "APPROVED") └── 🔴 Or ├── 🔴 Pull request author is a member of the team: devrels └── 🔴 At least 1 user(s) of the team devrels reviewed pull request(with state "APPROVED")Pending initial approval by a review team member, or review from tech-staff
If
🟢 Condition met └── 🟢 And ├── 🟢 The base branch matches this pattern: ^master$ └── 🟢 Not (🔴 Pull request author is a member of the team: tech-staff)Then
🔴 Requirement not satisfied └── 🔴 If ├── 🔴 Condition │ └── 🔴 Or │ ├── 🔴 At least one of these user(s) reviewed the pull request: [jefft0 leohhhn n0izn0iz notJoon omarsy x1unix] (with state "APPROVED") │ ├── 🔴 At least 1 user(s) of the team tech-staff reviewed pull request │ └── 🔴 This pull request is a draft └── 🔴 Else └── 🔴 And ├── 🟢 This label is applied to pull request: review/triage-pending └── 🔴 On no pull requestManual Checks
**IGNORE** the bot requirements for this PR (force green CI check)
If
🟢 Condition met └── 🟢 On every pull requestCan be checked by
- Any user with comment edit permission
The pull request description provides enough details
If
🟢 Condition met └── 🟢 And ├── 🟢 Not (🔴 Pull request author is a member of the team: core-contributors) └── 🟢 Not (🔴 Pull request author is user: dependabot[bot])Can be checked by
- team core-contributors
I took the liberty of renaming the PR to make it more representable of the changes in it.
I took the liberty of renaming the PR to make it more representable of the changes in it.
@leohhhn sure sir , Just wanted to let you know that you can move forward with the next steps whenever you're ready. If you need anything from my side clarifications, feedback, or additional input feel free to reach out anytime.
i have made some changes to PR can you just look and confirm that everything is fine , (deleted some unwanted things)
do this PR @leohhhn need any more changes or it perfect with its changes ?
is this PR eligible for bounty ?
@leohhhn ??
Hey @sudhanshu112233shukla
Sorry for the late turnaround. We're going to have one of our engineers take a look at this soon; we've been a bit busy lately 🙏
@leohhhn no worries .
Hey @sudhanshu112233shukla Could you solve the conflicts on the PR I would like to start reviewing thanks
Hey @sudhanshu112233shukla Could you solve the conflicts on the PR I would like to start reviewing thanks
sure i will do it
is this PR only needs to resolve the conflicts or any thing else ?
is this PR only needs to resolve the conflicts or any thing else ?
I will make some tests on the PR and continue reviewing on my side. For now I think solving the conflicts would be great
@Villaquiranm resolved the conflicts done
Hello @sudhanshu112233shukla So I did some tests on your PR:
// cover.gno
package cover
func IsEven(a int) bool{
if a%2 == 0 {
return true
}
return false
}
// cover_test.gno
package cover
import (
"testing"
)
func TestIsEven(t *testing.T){
if !IsEven(2){
t.Error("should be even")
}
if !IsEven(4){
t.Error("should be even")
}
if !IsEven(6){
t.Error("should be even")
}
if IsEven(3){
t.Error("should not be even")
}
if IsEven(3){
t.Error("should not be even")
}
}
you can use these two files as input.
when doing gno test -covermode=atomic -coverprofile gnout.txt
I'll expect to have:
cover.gno:3.25,4.14 1 5. // function called 5 times
cover.gno:4.14,6.3 1 3 // (Is even 3 times)
cover.gno:8.2,8.14 1 2 // (Not even 2 times)
But instead I'm getting
mode: atomic
testing.gno:359.9,359.20 1 1
Edit: you can ignore the comments on the expect, it is just informative
@Villaquiranm ok soo , what test have you performed can you explain me more .
@Villaquiranm ok soo , what test have you performed can you explain me more .
Hello these are the files and the command I run, The expected values are also mentioned on my comment :)
Hello @sudhanshu112233shukla So I did some tests on your PR:
// cover.gno package cover func IsEven(a int) bool{ if a%2 == 0 { return true } return false } // cover_test.gno package cover import ( "testing" ) func TestIsEven(t *testing.T){ if !IsEven(2){ t.Error("should be even") } if !IsEven(4){ t.Error("should be even") } if !IsEven(6){ t.Error("should be even") } if IsEven(3){ t.Error("should not be even") } if IsEven(3){ t.Error("should not be even") } }you can use these two files as input. when doing
gno test -covermode=atomic -coverprofile gnout.txtI'll expect to have:
cover.gno:3.25,4.14 1 5. function called 5 times cover.gno:4.14,6.3 1 3 (Is even 3 times) cover.gno:8.2,8.14 1 2 (Not even 2 times)But instead I'm getting
mode: atomic testing.gno:359.9,359.20 1 1
@Villaquiranm ok i will check this , thank you for your response
@Villaquiranm see the update , tell me if you see any more fixes
??
is there anyone who can tell me is fine or , what further changes it need so i can fix that , review it as well
is there anyone who can tell me is fine or , what further changes it need so i can fix that , review it as well
Hey @sudhanshu112233shukla sorry I had many tasks these last days, also I think the core team is very busy. I'll take another look of your PR during the next 2-3 days
is there anyone who can tell me is fine or , what further changes it need so i can fix that , review it as well
Hey @sudhanshu112233shukla sorry I had many tasks these last days, also I think the core team is very busy. I'll take another look of your PR during the next 2-3 days
sure take your time
Hi @sudhanshu112233shukla . Are you able to resolve the conflicts with master?
Hi @sudhanshu112233shukla . Are you able to resolve the conflicts with master?
i just saw it i will resolve it very soon
is there anyone who can tell me is fine or , what further changes it need so i can fix that , review it as well
I did again this test and I'm still having only one line from testing.gno so 0 information on the file we're measuring the coverage, I suggest you compare your results with
go test -covermode=atomic -coverprofile gout.txt (having the same file but with .go extension)
see the comment: https://github.com/gnolang/gno/pull/4570#issuecomment-3241334452 putting as a link to avoid spam.
currently on gno: mode: atomic. testing.gno:359.9,359.20 1 1. -> this file belongs to the testing package itself so, we actually have 0 coverage info on the file we want.
on Go: mode: atomic github.com/gnolang/gno/examples/gno.land/p/samcrew/coverage/cover.go:3.25,4.14 1 5 github.com/gnolang/gno/examples/gno.land/p/samcrew/coverage/cover.go:4.14,6.3 1 3 github.com/gnolang/gno/examples/gno.land/p/samcrew/coverage/cover.go:8.2,8.14 1 2
I am in the final verification stage. I have implemented the fixes to prevent duplicate coverage blocks and ensure correct file paths. I am currently rebuilding the Gno tool to run the final verification test. It should be done very soon.
Soon I will update the things...
please review the new changes it has ....
@Villaquiranm please do have a look on this..