Skip to content
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

feat(gnovm): enable debugger for gno test #3380

Merged
merged 8 commits into from
Feb 20, 2025

Conversation

mvertes
Copy link
Contributor

@mvertes mvertes commented Dec 19, 2024

This change brings interactive debugging to gno tests, using -debug flag.

New debugger commands have also been added:

  • next, to step over the next source line
  • stepout, to step out of the current function

Usage example, from the clone root dir:

$ go run ./gnovm/cmd/gno test -v -debug  ./examples/gno.land/p/demo/diff -run TestMyersDiff/Case_sensitivity
Welcome to the Gnovm debugger. Type 'help' for list of commands.
dbg> break gno.land/p/demo/diff/diff.gno:60
Breakpoint 0 at gno.land/p/demo/diff gno.land/p/demo/diff/diff.gno:60:0
dbg> c
=== RUN   TestMyersDiff
=== RUN   TestMyersDiff/Case_sensitivity
> diff.MyersDiff() gno.land/p/demo/diff/diff.gno:60:10
     55: //
     56: // Returns:
     57: //   - A slice of Edit operations representing the minimum difference between the two strings.
     58: func MyersDiff(old, new string) []Edit {
     59: 	oldRunes, newRunes := []rune(old), []rune(new)
=>   60: 	n, m := len(oldRunes), len(newRunes)
     61: 
     62: 	if n == 0 && m == 0 {
     63: 		return []Edit{}
     64: 	}
dbg> p oldRunes
(slice[(97 int32),(98 int32),(99 int32)] []int32)
dbg> stack
0	in gno.land/p/demo/diff.MyersDiff
	at gno.land/p/demo/diff/diff.gno:60:10
1	in gno.land/p/demo/diff.
	at gno.land/p/demo/diff/diff_test.gno:176:4
2	in testing.tRunner
	at testing/testing.gno:364:2
3	in testing.(*testing.T).Run
	at testing/testing.gno:171:2
4	in gno.land/p/demo/diff.TestMyersDiff
	at gno.land/p/demo/diff/diff_test.gno:175:3
5	in testing.tRunner
	at testing/testing.gno:364:2
6	in testing.RunTest
	at testing/testing.gno:298:2
dbg>

This change brings interactive debugging to gno tests, using -debug
flag.
@mvertes mvertes added 🌱 feature New update to Gno 📦 🤖 gnovm Issues or PRs gnovm related in focus labels Dec 19, 2024
@mvertes mvertes self-assigned this Dec 19, 2024
@Gno2D2
Copy link
Collaborator

Gno2D2 commented Dec 19, 2024

🛠 PR Checks Summary

All Automated Checks passed. ✅

Manual Checks (for Reviewers):
  • IGNORE the bot requirements for this PR (force green CI check)
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)

☑️ Contributor Actions:
  1. Fix any issues flagged by automated checks.
  2. 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 CHANGE notes.
    • Link related issues/PRs, where applicable.
☑️ Reviewer Actions:
  1. 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: mvertes/gno)

Then

🟢 Requirement satisfied
└── 🟢 Maintainer can modify this pull request

Manual Checks
**IGNORE** the bot requirements for this PR (force green CI check)

If

🟢 Condition met
└── 🟢 On every pull request

Can be checked by

  • Any user with comment edit permission

Copy link

codecov bot commented Dec 19, 2024

Codecov Report

Attention: Patch coverage is 69.51220% with 25 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
gnovm/pkg/test/test.go 26.31% 13 Missing and 1 partial ⚠️
gnovm/pkg/gnolang/debugger.go 77.27% 9 Missing and 1 partial ⚠️
gnovm/pkg/repl/repl.go 0.00% 1 Missing ⚠️

📢 Thoughts on this report? Let us know!

@github-actions github-actions bot added 🧾 package/realm Tag used for new Realms or Packages. 📦 🌐 tendermint v2 Issues or PRs tm2 related 📦 ⛰️ gno.land Issues or PRs gno.land package related labels Jan 16, 2025
@Kouteki Kouteki removed the in focus label Feb 3, 2025
@mvertes mvertes marked this pull request as ready for review February 7, 2025 12:17
@leohhhn leohhhn requested review from gfanton and thehowl February 7, 2025 12:20
@leohhhn
Copy link
Contributor

leohhhn commented Feb 8, 2025

Can we also make this work for filetests somehow?

@mvertes
Copy link
Contributor Author

mvertes commented Feb 11, 2025

Can we also make this work for filetests somehow?

If it is about debugging txtar files, that would be achieved by client side remote debugging to be added in gnodev or gnokey, as discussed per #2683.

@aeddi aeddi self-requested a review February 17, 2025 10:43
@thehowl
Copy link
Member

thehowl commented Feb 18, 2025

If it is about debugging txtar files, that would be achieved by client side remote debugging to be added in gnodev or gnokey, as discussed per #2683.

No, Leon was asking about usage in _filetest.gno files.

@thehowl thehowl merged commit 0fb25b5 into gnolang:master Feb 20, 2025
61 of 62 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
📦 🌐 tendermint v2 Issues or PRs tm2 related 📦 ⛰️ gno.land Issues or PRs gno.land package related 📦 🤖 gnovm Issues or PRs gnovm related 🧾 package/realm Tag used for new Realms or Packages. 🌱 feature New update to Gno
Projects
Development

Successfully merging this pull request may close these issues.

5 participants