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

gnodev test with testing.T #208

Merged
merged 8 commits into from
May 27, 2022
Merged

gnodev test with testing.T #208

merged 8 commits into from
May 27, 2022

Conversation

anarcher
Copy link
Contributor

It's the proof of concept(PoC) state. This approach is using stdlibs/testing/testing.gno for testing.

$ gnodev test ./cmd/gnodev/test/
?       ./cmd/gnodev/test       [no test files]
baking uverse... done

--- FAIL: TestFail

--- FAIL: TestHello

FAIL
FAIL    ./cmd/gnodev/test       11.4445ms
--- foo_test.gno ---
package foo

import "testing"

func TestOk(t *testing.T) {
}

func TestFail(t *testing.T) {
        t.Error("fail")
}

func TestHello(t *testing.T) {
        if str == "hello" {
                t.Error("hello")
        }
}
--- foo.gno ---
package foo

var str = "hello"

@moul moul added core labels May 20, 2022
@moul moul self-requested a review May 20, 2022 20:14
@moul moul marked this pull request as draft May 21, 2022 22:00
@anarcher anarcher changed the title gnodev test with testing.T WIP: gnodev test with testing.T May 22, 2022
@anarcher
Copy link
Contributor Author

$ gnodev test ./examples/gno.land/r/foo20/ --verbose
=== RUN   file/foo200_filetest.gno
baking uverse... done
--- PASS: file/foo200_filetest.gno (847.3075ms)
=== RUN   file/foo201_filetest.gno
--- PASS: file/foo201_filetest.gno (849.621583ms)
=== RUN   file/foo202_filetest.gno
--- PASS: file/foo202_filetest.gno (858.10275ms)
=== RUN   file/foo203_filetest.gno
--- PASS: file/foo203_filetest.gno (863.438958ms)
ok      ./examples/gno.land/r/foo20     3.418522667s
--- FAIL: TestReadOnlyPublicMethods
admin: g1us8428u2a5satrlxzagqqa5m6vmuze025anjlj
BalanceOf(admin): want: 10000000000 have: 10000000000

FAIL
FAIL    ./examples/gno.land/r/foo20     735.357417ms

cmd/gnodev/test.go Outdated Show resolved Hide resolved
Copy link
Member

@moul moul left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Brilliant, tell me if you need any help on something, but for me it’s already ok to merge as a V1 of the feature 👍

anarcher and others added 2 commits May 27, 2022 17:53
Co-authored-by: Manfred Touron <94029+moul@users.noreply.github.com>
@anarcher
Copy link
Contributor Author

Brilliant, tell me if you need any help on something, but for me it’s already ok to merge as a V1 of the feature 👍

Thanks, I agree to merge as a v1 :-) But now CI is failed at go run ./cmd/gnodev precompile ./examples --verbose.

examples/gno.land/r/foo20/foo200_test.gno: precompile: import "testing" is not in the whitelist

@anarcher anarcher changed the title WIP: gnodev test with testing.T gnodev test with testing.T May 27, 2022
@anarcher
Copy link
Contributor Author

anarcher commented May 27, 2022

Todo (next):

  • Support subtests t.Run()
  • Support t.Skip() (maybe we use panic for this control flow?)
  • Using std.XXX (std.AssertOriginCall(),...) in tests
  • Display the file and line of the call site of test funcs
    (I don't know something like runtime.Frame or runtime.Caller in Gno runtime.)
  • Integreted look and feel both of _filetest and _test?

I'm not sure this TODO is appropriate. we need to more figure out this :-)

@moul moul marked this pull request as ready for review May 27, 2022 21:42
Signed-off-by: Manfred Touron <94029+moul@users.noreply.github.com>
@moul
Copy link
Member

moul commented May 27, 2022

@anarcher I’ve pushed a fix for the issue with “testing” whitelisting (I disabled package whitelist checks completely for testing files)

@moul moul merged commit 25f9b2b into gnolang:master May 27, 2022
@anarcher anarcher deleted the gnotest-1 branch May 30, 2022 16:08
@moul moul added this to the 🏗2️⃣ test2.gno.land milestone Oct 20, 2022
moul added a commit to gnolang/game-of-realms that referenced this pull request Oct 14, 2023
moul added a commit to gnolang/game-of-realms that referenced this pull request Oct 18, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

None yet

2 participants