Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test(cmd/gno): prevent nil deref in testMainCaseRun (#3071)
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 ``` <details><summary>Contributors' checklist...</summary> - [ ] 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 </details> Signed-off-by: Norman Meier <[email protected]>
- Loading branch information