Skip to content

Commit

Permalink
test(gnovm): indented json on filetests's Events: directives (#3055)
Browse files Browse the repository at this point in the history
Closer to the current `// Realm:` output, and more git-friendly.

Bigger example in #3003.

Signed-off-by: moul <[email protected]>
  • Loading branch information
moul authored Oct 31, 2024
1 parent 8ec556e commit 2873354
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 3 deletions.
25 changes: 24 additions & 1 deletion examples/gno.land/r/demo/event/z1_filetest.gno
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,27 @@ func main() {
}

// Events:
// [{"type":"TAG","attrs":[{"key":"key","value":"foo"}],"pkg_path":"gno.land/r/demo/event","func":"Emit"},{"type":"TAG","attrs":[{"key":"key","value":"bar"}],"pkg_path":"gno.land/r/demo/event","func":"Emit"}]
// [
// {
// "type": "TAG",
// "attrs": [
// {
// "key": "key",
// "value": "foo"
// }
// ],
// "pkg_path": "gno.land/r/demo/event",
// "func": "Emit"
// },
// {
// "type": "TAG",
// "attrs": [
// {
// "key": "key",
// "value": "bar"
// }
// ],
// "pkg_path": "gno.land/r/demo/event",
// "func": "Emit"
// }
// ]
20 changes: 19 additions & 1 deletion gnovm/cmd/gno/testdata/gno_test/filetest_events.txtar
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,22 @@ func main() {
// test

// Events:
// [{"type":"EventA","attrs":[],"pkg_path":"","func":"main"},{"type":"EventB","attrs":[{"key":"keyA","value":"valA"}],"pkg_path":"","func":"main"}]
// [
// {
// "type": "EventA",
// "attrs": [],
// "pkg_path": "",
// "func": "main"
// },
// {
// "type": "EventB",
// "attrs": [
// {
// "key": "keyA",
// "value": "valA"
// }
// ],
// "pkg_path": "",
// "func": "main"
// }
// ]
2 changes: 1 addition & 1 deletion gnovm/tests/file.go
Original file line number Diff line number Diff line change
Expand Up @@ -374,7 +374,7 @@ func RunFileTest(rootDir string, path string, opts ...RunFileTestOption) error {
}
// check result
events := m.Context.(*teststd.TestExecContext).EventLogger.Events()
evtjson, err := json.Marshal(events)
evtjson, err := json.MarshalIndent(events, "", " ")
if err != nil {
panic(err)
}
Expand Down

0 comments on commit 2873354

Please sign in to comment.