feat(gno): add `-print-events` flag to `gno test` to print emitted events
Closes half of #2007
Add print-events flag to print emitted events in gno -test.
Sample
// event.gno
package event
import (
"std"
)
func Hello() string {
std.Emit("hello", "emit_key", "emit_value")
return "hello_return"
}
// event_test.gno
package event
import (
"std"
"testing"
)
func TestFunc(t *testing.T) {
Hello()
std.Emit("tEsTfUnC", "test key", "test value")
}
Ouput
Contributors' checklist...
- [x] Added new tests, or not needed, or not feasible
- [x] Provided an example (e.g. screenshot) to aid review or the PR is self-explanatory
- [x] Updated the official documentation or not needed
- [x] No breaking changes were made, or a
BREAKING CHANGE: xxxmessage was included in the description - [x] Added references to related issues and PRs
- [ ] Provided any useful hints for running manual tests
- [ ] Added new benchmarks to generated graphs, if any. More info here.
Codecov Report
Attention: Patch coverage is 55.55556% with 8 lines in your changes missing coverage. Please review.
Project coverage is 60.99%. Comparing base (
a2b4d4b) to head (984093b). Report is 46 commits behind head on master.
| Files with missing lines | Patch % | Lines |
|---|---|---|
| tm2/pkg/colors/colors.go | 0.00% | 8 Missing :warning: |
Additional details and impacted files
@@ Coverage Diff @@
## master #2071 +/- ##
==========================================
+ Coverage 60.95% 60.99% +0.03%
==========================================
Files 564 564
Lines 75273 75290 +17
==========================================
+ Hits 45885 45925 +40
+ Misses 26018 25995 -23
Partials 3370 3370
| Flag | Coverage Δ | |
|---|---|---|
| contribs/gnodev | 61.46% <ø> (ø) |
|
| contribs/gnofaucet | 14.46% <ø> (ø) |
|
| gno.land | 67.92% <ø> (ø) |
|
| gnovm | 65.88% <100.00%> (+0.10%) |
:arrow_up: |
| misc/genstd | 80.54% <ø> (ø) |
|
| misc/logos | 20.23% <ø> (ø) |
|
| tm2 | 62.07% <0.00%> (+<0.01%) |
:arrow_up: |
Flags with carried forward coverage won't be shown. Click here to find out more.
:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.
Hey @moul, here is the issue with the discussion about this - TL;DR I am in favor of adding -print-events apart from -v, since the events might clog up the test output if there is lots of them, making the output unreadable. Maybe -print-events would have the same functionality that -v has, plus the added printing of events.
If stdout is printed, events should also be printed if they exist. Currently, events should be considered as returned values of a contract, representing an outcome or consequence as the returned value (stdout).
Let's wait for a clear example to determine if events are too spammy. Initially, we should consider reducing the number of events. If they overwhelm users, it makes the contract's usage more implicit, which we aim to avoid.
We should always print events when stdout is printed and maintain our usual rule: strive for straightforward, explicit, and simple communication without hiding things as soon as they become complex; let's just remove the complex.
@r3v4s
Can you please check why the CI is failing and apply @moul's comment, so we can go ahead with merging this? 🙏
@zivkovicmilos
Removed new flag(print-events) and applied existing flag verbose` to print emitted events or not.
And CI fails on codecov against ColoredBytesOnlyAscii function, which I can't think of straightforward way to make it not to fail. Can you enlighten me?
Closed in favor of #2975. But thank you @r3v4s!