diff --git a/examples/gno.land/r/demo/groups/README.md b/examples/gno.land/r/demo/groups/README.md index 549b2fd7cf5..1db5ae56b51 100644 --- a/examples/gno.land/r/demo/groups/README.md +++ b/examples/gno.land/r/demo/groups/README.md @@ -1,6 +1,6 @@ ### - test package - ./build/gnodev test examples/gno.land/r/demo/groups/ + ./build/gno test examples/gno.land/r/demo/groups/ ### - add pkg diff --git a/gnovm/cmd/gno/lint.go b/gnovm/cmd/gno/lint.go index 8042a1f1703..158b9d8db5d 100644 --- a/gnovm/cmd/gno/lint.go +++ b/gnovm/cmd/gno/lint.go @@ -37,7 +37,7 @@ func newLintCmd(io *commands.IO) *commands.Command { func (c *lintCfg) RegisterFlags(fs *flag.FlagSet) { fs.BoolVar(&c.verbose, "verbose", false, "verbose output when lintning") - fs.StringVar(&c.rootDir, "root-dir", "", "clone location of github.com/gnolang/gno (gnodev tries to guess it)") + fs.StringVar(&c.rootDir, "root-dir", "", "clone location of github.com/gnolang/gno (gno tries to guess it)") fs.IntVar(&c.setExitStatus, "set_exit_status", 1, "set exit status to 1 if any issues are found") } diff --git a/gnovm/cmd/gno/repl.go b/gnovm/cmd/gno/repl.go index f39d23335f3..a0ba7a21d76 100644 --- a/gnovm/cmd/gno/repl.go +++ b/gnovm/cmd/gno/repl.go @@ -53,7 +53,7 @@ func (c *replCfg) RegisterFlags(fs *flag.FlagSet) { &c.rootDir, "root-dir", "", - "clone location of github.com/gnolang/gno (gnodev tries to guess it)", + "clone location of github.com/gnolang/gno (gno tries to guess it)", ) fs.StringVar( diff --git a/gnovm/cmd/gno/test.go b/gnovm/cmd/gno/test.go index f5e180e694a..e7e2fefff25 100644 --- a/gnovm/cmd/gno/test.go +++ b/gnovm/cmd/gno/test.go @@ -42,6 +42,48 @@ func newTestCmd(io *commands.IO) *commands.Command { Name: "test", ShortUsage: "test [flags] [...]", ShortHelp: "Runs the tests for the specified packages", + LongHelp: `Runs the tests for the specified packages. + +'Gno test' recompiles each package along with any files with names matching the +file pattern "*_test.gno" or "*_filetest.gno". + +The only supported for now is a directory (relative or absolute). + +- "*_test.gno" files work like "*_test.go" files, but they contain only test +functions. Benchmark and fuzz functions aren't supported yet. Similarly, only +tests that belong to the same package are supported for now (no "xxx_test"). + +- "*_filetest.gno" files on the other hand are kind of unique. They exist to +provide a way to interact and assert a gno contract, thanks to a set of +specific instructions that can be added using code comments. + +"*_filetest.gno" must be declared in the 'main' package and so must have a +'main' function, that will be executed to test the target contract. + +List of available instructions that can be used in "*_filetest.gno" files: + - "PKGPATH:" is a single line instruction that can be used to define the + package used to interact with the tested package. If not specified, "main" is + used. + - "MAXALLOC:" is a signle line instruction that can be used to define a limit + to the VM allocator. If this limit is exceeded, the VM will panic. Default to + 0, no limit. + - "SEND:" is a single line instruction that can be used to send an amount of + token along with the transaction. The format is for example "1000000ugnot". + Default is empty. + - "Output:\n" (*) is a multiple lines instruction that can be used to assert + the output of the "*_filetest.gno" file. Any prints executed inside the + 'main' function must match the lines that follows the "Output:\n" + instruction, or else the test fails. + - "Error:\n" works similarly to "Output:\n", except that it asserts the + stderr of the program, which in that case, comes from the VM because of a + panic, rather than the 'main' function. + - "Realm:\n" (*) is a multiple lines instruction that can be used to assert + what has been recorded in the store following the execution of the 'main' + function. + +(*) The 'update-golden-test' flag can be set to fill out the content of the +instruction with the actual content of the test. +`, }, cfg, func(_ context.Context, args []string) error { @@ -69,14 +111,14 @@ func (c *testCfg) RegisterFlags(fs *flag.FlagSet) { &c.updateGoldenTests, "update-golden-tests", false, - "writes actual as wanted in test comments", + `writes actual as wanted for "Output:" and "Realm:" instructions`, ) fs.StringVar( &c.rootDir, "root-dir", "", - "clone location of github.com/gnolang/gno (gnodev tries to guess it)", + "clone location of github.com/gnolang/gno (gno tries to guess it)", ) fs.StringVar(