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

feat: add 'gnodev test' command #149

Merged
merged 12 commits into from
May 12, 2022
Merged

Conversation

moul
Copy link
Member

@moul moul commented Apr 29, 2022

Usage

gnodev test --help    
# testOptions options
- verbose (bool) - verbose 
- root-dir (string) - github.com/gnolang/gno clone dir 

Example

gnodev test ./examples
?       ./examples/gno.land/p/avl       [no test files]
?       ./examples/gno.land/p/bank      [no test files]
?       ./examples/gno.land/p/dom       [no test files]
?       ./examples/gno.land/p/grc/grc20         [no test files]
?       ./examples/gno.land/p/grc/grc20/impl    [no test files]
?       ./examples/gno.land/p/grc/grc721        [no test files]
?       ./examples/gno.land/p/groups    [no test files]
?       ./examples/gno.land/p/maths     [no test files]
ok      ./examples/gno.land/p/rand      51.707949ms
?       ./examples/gno.land/p/releases  [no test files]
?       ./examples/gno.land/p/tests     [no test files]
?       ./examples/gno.land/p/testutils         [no test files]
?       ./examples/gno.land/p/ufmt      [no test files]
?       ./examples/gno.land/r/banktest  [no test files]
?       ./examples/gno.land/r/boards    [no test files]
ok      ./examples/gno.land/r/foo20     497.964559ms
?       ./examples/gno.land/r/nft       [no test files]
ok      ./examples/gno.land/r/releases-example  55.550871ms
?       ./examples/gno.land/r/tests     [no test files]
?       ./examples/gno.land/r/tests_foo         [no test files]
?       ./examples/gno.land/r/users     [no test files]

@moul-bot moul-bot force-pushed the dev/moul/gnodev-test branch 3 times, most recently from f6df414 to 98e1d39 Compare April 30, 2022 21:21
@moul-bot moul-bot force-pushed the dev/moul/gnodev-test branch 2 times, most recently from ac5e446 to 7cb55a9 Compare May 7, 2022 16:15
@moul moul changed the title WIP feat: add 'gnodev test' command feat: add 'gnodev test' command May 7, 2022
@moul
Copy link
Member Author

moul commented May 7, 2022

BCE4F2F8-9F2B-4BCE-B977-9BE2A40B6BFE

@moul
Copy link
Member Author

moul commented May 7, 2022

And with verbose

DB4FCAAD-ADAC-4A0D-AE72-EDE08CAD770D

@moul moul marked this pull request as ready for review May 7, 2022 16:19
@moul
Copy link
Member Author

moul commented May 7, 2022

@jaekwon this first version is ready for review, it requires having all the source files in a cloned gnolang/gno repo

I plan to make something like go mod download or even go mod vendor that will fetch from the chain the current published contracts that are imported by the contract in development.

But that’ll be huge, and in another PR :)

Also, I only integrated the current test mode that runs a whole file and writes the Output and Error as comment; I will then look how to manage the standard testing.T mode.

@moul
Copy link
Member Author

moul commented May 7, 2022

Oops, sorry for the noise; I’ve some tests to fix (Fixed)

@moul moul marked this pull request as draft May 7, 2022 17:55
@moul moul marked this pull request as ready for review May 7, 2022 19:07
Comment on lines +30 to +43
// fmt -- gofmt
// clean
// graph
// vendor -- download deps from the chain in vendor/
// list -- list packages
// run -- call render(), or maybe create a new main?
// publish/release
// generate
// doc -- godoc
// "vm" -- starts an in-memory chain that can be interacted with?
// bug -- start a bug report
// version -- show gnodev, golang versions
Copy link
Member Author

Choose a reason for hiding this comment

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

new feature ides for gnodev

tests/package_test.go Outdated Show resolved Hide resolved
@moul moul added core labels May 9, 2022
moul added 10 commits May 9, 2022 23:56
Signed-off-by: Manfred Touron <94029+moul@users.noreply.github.com>
Signed-off-by: Manfred Touron <94029+moul@users.noreply.github.com>
Signed-off-by: Manfred Touron <94029+moul@users.noreply.github.com>
Signed-off-by: Manfred Touron <94029+moul@users.noreply.github.com>
Signed-off-by: Manfred Touron <94029+moul@users.noreply.github.com>
… able to skip unwanted .go files

Signed-off-by: Manfred Touron <94029+moul@users.noreply.github.com>
Signed-off-by: Manfred Touron <94029+moul@users.noreply.github.com>
Signed-off-by: Manfred Touron <94029+moul@users.noreply.github.com>
Signed-off-by: Manfred Touron <94029+moul@users.noreply.github.com>
Signed-off-by: Manfred Touron <94029+moul@users.noreply.github.com>
Signed-off-by: Manfred Touron <94029+moul@users.noreply.github.com>
Signed-off-by: Manfred Touron <94029+moul@users.noreply.github.com>
@anarcher
Copy link
Contributor

IMHO, I feel that testing with Output and Error as comment is Gno internal testing style. (like Go's internal testscript?[1])
I think it is enough for gnodev test to support only the standard testing.T mode.

[1]: testscript was originally created for testing the Go compiler itself.

@moul
Copy link
Member Author

moul commented May 10, 2022

IMHO, I feel that testing with Output and Error as comment is Gno internal testing style. (like Go's internal testscript?[1]) I think it is enough for gnodev test to support only the standard testing.T mode.

[1]: testscript was originally created for testing the Go compiler itself.

Yep I agree and I’m for going more and more with the standard go testing package as soon as it will be supported with gnodev.

Additionally to being the historical custom mode for Gno; there are still some advantages that could eventually be interesting to keep, like the format itself which is relatively like a « main » program and gives a whole new sense to contract testing (IMHO); but I hope that I will be able to mimic this with the official « func ExampleXXX » of std go which offers similar concise tests, but only supports Output and not Error.

The biggest game changer that will help get less/rid of historical testing in gno dev will certainly be a strong « testutil » package to replace everything managed with custom comments today.

Looking forward for the future Gno :)

@moul moul self-assigned this May 10, 2022
@moul moul merged commit c81342e into gnolang:master May 12, 2022
@moul moul deleted the dev/moul/gnodev-test branch May 12, 2022 11:59
@moul moul added this to the 🏗1️⃣ test1.gno.land milestone Oct 20, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: ✅ Done
Archived in project
Development

Successfully merging this pull request may close these issues.

3 participants