Skip to content

Commit

Permalink
test(gnovm): print unexpected error in filetests (gnolang#2213)
Browse files Browse the repository at this point in the history
If an error occurred in a filetest, this was not printed unless a
specific `// Error:` directive was added. This adds printing for errors
anytime that it doesn't match the expected value in the directive.

<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
- [ ] Added new benchmarks to [generated
graphs](https://gnoland.github.io/benchmarks), if any. More info
[here](https://github.com/gnolang/gno/blob/master/.benchmarks/README.md).
</details>
  • Loading branch information
thehowl authored and omarsy committed Jun 3, 2024
1 parent 5ce53ca commit cf19bb8
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions gnovm/tests/file.go
Original file line number Diff line number Diff line change
Expand Up @@ -136,14 +136,13 @@ func RunFileTest(rootDir string, path string, opts ...RunFileTestOption) error {
defer func() {
if r := recover(); r != nil {
// print output.
fmt.Println("OUTPUT:\n", stdout.String())
// print stack if unexpected error.
fmt.Printf("OUTPUT:\n%s\n", stdout.String())
pnc = r
if errWanted == "" {
rtdb.PrintStack()
}
err := strings.TrimSpace(fmt.Sprintf("%v", pnc))
if !strings.Contains(err, errWanted) {
// print stack if unexpected error.
if errWanted == "" ||
!strings.Contains(err, errWanted) {
fmt.Printf("ERROR:\n%s\n", err)
// error didn't match: print stack
// NOTE: will fail testcase later.
rtdb.PrintStack()
Expand Down

0 comments on commit cf19bb8

Please sign in to comment.