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

test(cmd/gno): prevent nil deref in testMainCaseRun #3071

Merged
merged 2 commits into from
Nov 6, 2024

Conversation

n0izn0iz
Copy link
Contributor

@n0izn0iz n0izn0iz commented Nov 6, 2024

In gnovm/cmd/gno/main_test.go, when an error is expected but none happen, the test helper tries to dereference nil, causing a confusing test result

Before:

=== RUN   TestModApp/mod_tidy..~..~tests~integ~invalid_module_version1
    main_test.go:92: recover runtime error: invalid memory address or nil pointer dereference
    main_test.go:93: 
        	Error Trace:	/Users/norman/Code/gno/gnovm/cmd/gno/main_test.go:93
        	            				/Users/norman/go/pkg/mod/golang.org/[email protected]/src/runtime/panic.go:770
        	            				/Users/norman/go/pkg/mod/golang.org/[email protected]/src/runtime/panic.go:261
        	            				/Users/norman/go/pkg/mod/golang.org/[email protected]/src/runtime/signal_unix.go:881
        	            				/Users/norman/Code/gno/gnovm/cmd/gno/main_test.go:131
        	Error:      	Should be false
        	Test:       	TestModApp/mod_tidy..~..~tests~integ~invalid_module_version1
        	Messages:   	should not panic

After:

=== RUN   TestModApp/mod_tidy..~..~tests~integ~invalid_module_version1
    main_test.go:131: err <nil>
    main_test.go:132: 
        	Error Trace:	/Users/norman/Code/gno/gnovm/cmd/gno/main_test.go:132
        	Error:      	Expected value not to be nil.
        	Test:       	TestModApp/mod_tidy..~..~tests~integ~invalid_module_version1
        	Messages:   	err shouldn't be nil
Contributors' checklist...
  • Added new tests, or not needed, or not feasible
  • Provided an example (e.g. screenshot) to aid review or the PR is self-explanatory
  • Updated the official documentation or not needed
  • No breaking changes were made, or a BREAKING CHANGE: xxx message was included in the description
  • Added references to related issues and PRs
  • Provided any useful hints for running manual tests

@github-actions github-actions bot added the 📦 🤖 gnovm Issues or PRs gnovm related label Nov 6, 2024
Copy link

codecov bot commented Nov 6, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 63.33%. Comparing base (538ebff) to head (d9e93c3).
Report is 1 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #3071      +/-   ##
==========================================
- Coverage   63.33%   63.33%   -0.01%     
==========================================
  Files         548      548              
  Lines       78646    78646              
==========================================
- Hits        49809    49808       -1     
  Misses      25476    25476              
- Partials     3361     3362       +1     
Flag Coverage Δ
contribs/gnodev 61.11% <ø> (ø)
contribs/gnofaucet 15.77% <ø> (+0.94%) ⬆️
gno.land 67.18% <ø> (ø)
gnovm 67.88% <ø> (ø)
misc/genstd 79.72% <ø> (ø)
tm2 62.41% <ø> (-0.02%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@n0izn0iz n0izn0iz changed the title fix: prevent nil deref in main tests chore: prevent nil deref in main tests Nov 6, 2024
@n0izn0iz n0izn0iz marked this pull request as ready for review November 6, 2024 15:40
@thehowl thehowl changed the title chore: prevent nil deref in main tests test(cmd/gno): prevent nil deref in TestModApp test Nov 6, 2024
@thehowl thehowl changed the title test(cmd/gno): prevent nil deref in TestModApp test test(cmd/gno): prevent nil deref in testMainCaseRun Nov 6, 2024
@thehowl thehowl merged commit f2928f1 into gnolang:master Nov 6, 2024
136 checks passed
@n0izn0iz n0izn0iz deleted the main-test-nil-deref branch November 6, 2024 18:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
📦 🤖 gnovm Issues or PRs gnovm related
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

2 participants