-
Notifications
You must be signed in to change notification settings - Fork 385
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(gnovm): add 'gno test -print-events' + cleanup machine between t…
…ests (#2975) - [x] add `gno test -print-events` flag for unit tests. Props to @r3v4s for his work on #2071 - [x] add `// Events:` support in `_filetests.gno`. - [x] cleanup `gno.Machine` between unit tests (\o/) . Fixes #1982 Closes #2071 Addresses #2007 --------- Signed-off-by: moul <[email protected]>
- Loading branch information
Showing
9 changed files
with
170 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
package main | ||
|
||
import "gno.land/r/demo/event" | ||
|
||
func main() { | ||
event.Emit("foo") | ||
event.Emit("bar") | ||
} | ||
|
||
// 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"}] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
# Test with a valid _filetest.gno file | ||
|
||
gno test -print-events . | ||
|
||
! stdout .+ | ||
stderr 'ok \. \d\.\d\ds' | ||
|
||
gno test -print-events -v . | ||
|
||
! stdout .+ | ||
stderr '=== RUN file/valid_filetest.gno' | ||
stderr '--- PASS: file/valid_filetest.gno \(\d\.\d\ds\)' | ||
stderr 'ok \. \d\.\d\ds' | ||
|
||
-- valid.gno -- | ||
package valid | ||
|
||
-- valid_filetest.gno -- | ||
package main | ||
|
||
import "std" | ||
|
||
func main() { | ||
println("test") | ||
std.Emit("EventA") | ||
std.Emit("EventB", "keyA", "valA") | ||
} | ||
|
||
// Output: | ||
// test | ||
|
||
// Events: | ||
// [{"type":"EventA","attrs":[],"pkg_path":"","func":"main"},{"type":"EventB","attrs":[{"key":"keyA","value":"valA"}],"pkg_path":"","func":"main"}] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
# Test with a valid _test.gno file | ||
|
||
gno test -print-events . | ||
|
||
! stdout .+ | ||
stderr 'EVENTS: \[{\"type\":\"EventA\",\"attrs\":\[\],\"pkg_path\":\"gno.land/r/.*\",\"func\":\"TestA\"}\]' | ||
stderr 'EVENTS: \[{\"type\":\"EventB\",\"attrs\":\[{\"key\":\"keyA\",\"value\":\"valA\"}\],\"pkg_path\":\"gno.land/r/.*\",\"func\":\"TestB\"},{\"type\":\"EventC\",\"attrs\":\[{\"key\":\"keyD\",\"value\":\"valD\"}\],\"pkg_path\":\"gno.land/r/.*\",\"func\":\"TestB\"}\]' | ||
stderr 'ok \. \d\.\d\ds' | ||
|
||
-- valid.gno -- | ||
package valid | ||
|
||
-- valid_test.gno -- | ||
package valid | ||
|
||
import "testing" | ||
import "std" | ||
|
||
func TestA(t *testing.T) { | ||
std.Emit("EventA") | ||
} | ||
|
||
func TestB(t *testing.T) { | ||
std.Emit("EventB", "keyA", "valA") | ||
std.Emit("EventC", "keyD", "valD") | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
f4c4204
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Possible performance regression was detected for benchmark 'Go Benchmarks'.
Benchmark result of this commit is worse than the previous benchmark result exceeding threshold
1.20
.BenchmarkBinary/EmptyStruct:encode
466.8
ns/op 96 B/op 2 allocs/op288.6
ns/op 96 B/op 2 allocs/op1.62
BenchmarkBinary/EmptyStruct:encode - ns/op
466.8
ns/op288.6
ns/op1.62
BenchmarkBinary/EmptyStruct:decode
252.9
ns/op 0 B/op 0 allocs/op136
ns/op 0 B/op 0 allocs/op1.86
BenchmarkBinary/EmptyStruct:decode - ns/op
252.9
ns/op136
ns/op1.86
BenchmarkBinary/ShortArraysStruct:decode
439.4
ns/op 0 B/op 0 allocs/op217.3
ns/op 0 B/op 0 allocs/op2.02
BenchmarkBinary/ShortArraysStruct:decode - ns/op
439.4
ns/op217.3
ns/op2.02
BenchmarkBinary/EmbeddedSt1:encode
6067
ns/op 2037 B/op 65 allocs/op4697
ns/op 2037 B/op 65 allocs/op1.29
BenchmarkBinary/EmbeddedSt1:encode - ns/op
6067
ns/op4697
ns/op1.29
BenchmarkRemoved
38.79
ns/op 0 B/op 0 allocs/op29.34
ns/op 0 B/op 0 allocs/op1.32
BenchmarkRemoved - ns/op
38.79
ns/op29.34
ns/op1.32
BenchmarkRemoved
38.91
ns/op 0 B/op 0 allocs/op29.34
ns/op 0 B/op 0 allocs/op1.33
BenchmarkRemoved - ns/op
38.91
ns/op29.34
ns/op1.33
BenchmarkBcryptGenerateFromPassword/benchmark-security-param
63650677
ns/op 5130 B/op 9 allocs/op31848676
ns/op 5125 B/op 9 allocs/op2.00
BenchmarkBcryptGenerateFromPassword/benchmark-security-param - ns/op
63650677
ns/op31848676
ns/op2.00
BenchmarkBcryptGenerateFromPassword/benchmark-security-param
127281554
ns/op 5139 B/op 9 allocs/op31848676
ns/op 5125 B/op 9 allocs/op4.00
BenchmarkBcryptGenerateFromPassword/benchmark-security-param - ns/op
127281554
ns/op31848676
ns/op4.00
BenchmarkBcryptGenerateFromPassword/benchmark-security-param
254997168
ns/op 5158 B/op 9 allocs/op31848676
ns/op 5125 B/op 9 allocs/op8.01
BenchmarkBcryptGenerateFromPassword/benchmark-security-param - ns/op
254997168
ns/op31848676
ns/op8.01
BenchmarkBcryptGenerateFromPassword/benchmark-security-param
508647108
ns/op 5196 B/op 10 allocs/op31848676
ns/op 5125 B/op 9 allocs/op15.97
BenchmarkBcryptGenerateFromPassword/benchmark-security-param - ns/op
508647108
ns/op31848676
ns/op15.97
BenchmarkBcryptGenerateFromPassword/benchmark-security-param
1017323785
ns/op 5528 B/op 13 allocs/op31848676
ns/op 5125 B/op 9 allocs/op31.94
BenchmarkBcryptGenerateFromPassword/benchmark-security-param - ns/op
1017323785
ns/op31848676
ns/op31.94
BenchmarkBcryptGenerateFromPassword/benchmark-security-param - allocs/op
13
allocs/op9
allocs/op1.44
BenchmarkBcryptGenerateFromPassword/benchmark-security-param
2038594459
ns/op 5736 B/op 15 allocs/op31848676
ns/op 5125 B/op 9 allocs/op64.01
BenchmarkBcryptGenerateFromPassword/benchmark-security-param - ns/op
2038594459
ns/op31848676
ns/op64.01
BenchmarkBcryptGenerateFromPassword/benchmark-security-param - allocs/op
15
allocs/op9
allocs/op1.67
BenchmarkSigning
84203
ns/op 1856 B/op 36 allocs/op25732
ns/op 64 B/op 1 allocs/op3.27
BenchmarkSigning - ns/op
84203
ns/op25732
ns/op3.27
BenchmarkSigning - B/op
1856
B/op64
B/op29
BenchmarkSigning - allocs/op
36
allocs/op1
allocs/op36
BenchmarkSigning
82619
ns/op 1856 B/op 36 allocs/op25732
ns/op 64 B/op 1 allocs/op3.21
BenchmarkSigning - ns/op
82619
ns/op25732
ns/op3.21
BenchmarkSigning - B/op
1856
B/op64
B/op29
BenchmarkSigning - allocs/op
36
allocs/op1
allocs/op36
BenchmarkVerification
168339
ns/op 864 B/op 19 allocs/op60972
ns/op 0 B/op 0 allocs/op2.76
BenchmarkVerification - ns/op
168339
ns/op60972
ns/op2.76
BenchmarkVerification - B/op
864
B/op0
B/op+∞
BenchmarkVerification - allocs/op
19
allocs/op0
allocs/op+∞
BenchmarkVerification
167401
ns/op 864 B/op 19 allocs/op60972
ns/op 0 B/op 0 allocs/op2.75
BenchmarkVerification - ns/op
167401
ns/op60972
ns/op2.75
BenchmarkVerification - B/op
864
B/op0
B/op+∞
BenchmarkVerification - allocs/op
19
allocs/op0
allocs/op+∞
BenchmarkRandomBytes/random
68.87
ns/op 16 B/op 1 allocs/op33.46
ns/op 4 B/op 1 allocs/op2.06
BenchmarkRandomBytes/random - ns/op
68.87
ns/op33.46
ns/op2.06
BenchmarkRandomBytes/random - B/op
16
B/op4
B/op4
BenchmarkRandomBytes/random
105.9
ns/op 32 B/op 1 allocs/op33.46
ns/op 4 B/op 1 allocs/op3.16
BenchmarkRandomBytes/random - ns/op
105.9
ns/op33.46
ns/op3.16
BenchmarkRandomBytes/random - B/op
32
B/op4
B/op8
BenchmarkRandomBytes/random
268
ns/op 112 B/op 1 allocs/op33.46
ns/op 4 B/op 1 allocs/op8.01
BenchmarkRandomBytes/random - ns/op
268
ns/op33.46
ns/op8.01
BenchmarkRandomBytes/random - B/op
112
B/op4
B/op28
BenchmarkRandomBytes/random
2330
ns/op 1024 B/op 1 allocs/op33.46
ns/op 4 B/op 1 allocs/op69.64
BenchmarkRandomBytes/random - ns/op
2330
ns/op33.46
ns/op69.64
BenchmarkRandomBytes/random - B/op
1024
B/op4
B/op256
BenchmarkSmall/boltdb-1000-100-16-40/update
1439515
ns/op 44051 B/op 383 allocs/op976476
ns/op 37401 B/op 371 allocs/op1.47
BenchmarkSmall/boltdb-1000-100-16-40/update - ns/op
1439515
ns/op976476
ns/op1.47
BenchmarkSmall/memdb-1000-100-16-40/block
17578211
ns/op 9207128 B/op 167826 allocs/op13193863
ns/op 6564968 B/op 116417 allocs/op1.33
BenchmarkSmall/memdb-1000-100-16-40/block - ns/op
17578211
ns/op13193863
ns/op1.33
BenchmarkSmall/memdb-1000-100-16-40/block - B/op
9207128
B/op6564968
B/op1.40
BenchmarkSmall/memdb-1000-100-16-40/block - allocs/op
167826
allocs/op116417
allocs/op1.44
BenchmarkMedium/boltdb-100000-100-16-40/update - B/op
130037
B/op101775
B/op1.28
BenchmarkMedium/memdb-100000-100-16-40/update - B/op
364529
B/op255768
B/op1.43
BenchmarkMedium/memdb-100000-100-16-40/update - allocs/op
7221
allocs/op4933
allocs/op1.46
BenchmarkLevelDBBatchSizes/goleveldb-100000-400-16-40/update - B/op
47758
B/op39100
B/op1.22
BenchmarkLevelDBBatchSizes/goleveldb-100000-400-16-40/update - allocs/op
574
allocs/op455
allocs/op1.26
BenchmarkLevelDBBatchSizes/goleveldb-100000-2000-16-40/block - B/op
96799236
B/op77924690
B/op1.24
BenchmarkHash/ripemd160
2841
ns/op 25 B/op 1 allocs/op703.2
ns/op 25 B/op 1 allocs/op4.04
BenchmarkHash/ripemd160 - ns/op
2841
ns/op703.2
ns/op4.04
BenchmarkHash/sha2-256
521.5
ns/op 33 B/op 1 allocs/op170.5
ns/op 33 B/op 1 allocs/op3.06
BenchmarkHash/sha2-256 - ns/op
521.5
ns/op170.5
ns/op3.06
BenchmarkHash/sha3-256
1840
ns/op 33 B/op 1 allocs/op714.2
ns/op 33 B/op 1 allocs/op2.58
BenchmarkHash/sha3-256 - ns/op
1840
ns/op714.2
ns/op2.58
BenchmarkWriteSecretConnection
6434
ns/op 0 B/op 0 allocs/op4044
ns/op 0 B/op 0 allocs/op1.59
BenchmarkWriteSecretConnection - ns/op
6434
ns/op4044
ns/op1.59
BenchmarkReadSecretConnection
3219
ns/op 0 B/op 0 allocs/op2361
ns/op 0 B/op 0 allocs/op1.36
BenchmarkReadSecretConnection - ns/op
3219
ns/op2361
ns/op1.36
BenchmarkCacheStoreGetNoKeyFound - B/op
177
B/op145
B/op1.22
This comment was automatically generated by workflow using github-action-benchmark.
CC: @ajnavarro @thehowl @zivkovicmilos