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

chore: improve output on vm tests #775

Merged
merged 2 commits into from
May 18, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 22 additions & 2 deletions gnovm/tests/file.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ import (
"strconv"
"strings"

"github.com/pmezard/go-difflib/difflib"

gno "github.com/gnolang/gno/gnovm/pkg/gnolang"
"github.com/gnolang/gno/gnovm/stdlibs"
"github.com/gnolang/gno/tm2/pkg/crypto"
Expand Down Expand Up @@ -297,7 +299,16 @@ func RunFileTest(rootDir string, path string, opts ...RunFileTestOption) error {
if resWanted == "" {
panic(fmt.Sprintf("fail on %s: got unexpected output: %s", path, res))
} else {
panic(fmt.Sprintf("fail on %s: got:\n%s\n\nwant:\n%s\n", path, res, resWanted))
diff, _ := difflib.GetUnifiedDiffString(difflib.UnifiedDiff{
A: difflib.SplitLines(resWanted),
B: difflib.SplitLines(res),
FromFile: "Expected",
FromDate: "",
ToFile: "Actual",
ToDate: "",
Context: 1,
})
panic(fmt.Sprintf("fail on %s: diff:\n%s\n", path, diff))
}
}
}
Expand All @@ -318,7 +329,16 @@ func RunFileTest(rootDir string, path string, opts ...RunFileTestOption) error {
// write output to file.
replaceWantedInPlace(path, "Realm", rops2)
} else {
panic(fmt.Sprintf("fail on %s: got:\n%s\n\nwant:\n%s\n", path, rops2, rops))
diff, _ := difflib.GetUnifiedDiffString(difflib.UnifiedDiff{
A: difflib.SplitLines(rops),
B: difflib.SplitLines(rops2),
FromFile: "Expected",
FromDate: "",
ToFile: "Actual",
ToDate: "",
Context: 1,
})
panic(fmt.Sprintf("fail on %s: diff:\n%s\n", path, diff))
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ require (
github.com/mattn/go-runewidth v0.0.14
github.com/pelletier/go-toml v1.9.5
github.com/peterbourgon/ff/v3 v3.3.0
github.com/pmezard/go-difflib v1.0.0
github.com/stretchr/testify v1.8.2
github.com/syndtr/goleveldb v1.0.0
github.com/tecbot/gorocksdb v0.0.0-20191217155057-f0fad39f321c
Expand Down Expand Up @@ -60,7 +61,6 @@ require (
github.com/lib/pq v1.10.7 // indirect
github.com/lucasb-eyer/go-colorful v1.0.3 // indirect
github.com/pkg/errors v0.9.1 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/rivo/uniseg v0.2.0 // indirect
go.opencensus.io v0.22.5 // indirect
go.uber.org/atomic v1.7.0 // indirect
Expand Down