Open albttx opened 1 year ago
✅ This work
package airdrop import ( "testing" ) func TestABC(t *testing.T) { println("abc") }
❌ This fail
package airdrop_test import ( "testing" ) func TestABC(t *testing.T) { println("abc") }
with panic output
panic: package ./examples/gno.land/p/demo/airdrop already exists in cache goroutine 1 [running]: github.com/gnolang/gno/gnovm/pkg/gnolang.(*defaultStore).SetCachePackage(0xc0000c2000, 0xc009d5f860) /home/albttx/go/src/github.com/gnolang/gno/gnovm/pkg/gnolang/store.go:207 +0x16e github.com/gnolang/gno/gnovm/pkg/gnolang.(*Machine).RunMemPackage(0xc0092a59e0, 0xc0001fe180, 0x1) /home/albttx/go/src/github.com/gnolang/gno/gnovm/pkg/gnolang/machine.go:230 +0x1c6 main.gnoTestPkg({0xc00003ae40, 0x22}, {0xc0000d0210?, 0x1, 0x4?}, {0xc0000d0230, 0x1, 0x5066df?}, 0xc000112600, 0xc0000bc000) /home/albttx/go/src/github.com/gnolang/gno/gnovm/cmd/gno/test.go:266 +0x46f main.execTest(0xc000112600, {0xc000112070, 0x1, 0x1}, 0xc000112060?) /home/albttx/go/src/github.com/gnolang/gno/gnovm/cmd/gno/test.go:189 +0xca7 main.newTestCmd.func1({0x0?, 0x0?}, {0xc000112070?, 0x0?, 0x0?}) /home/albttx/go/src/github.com/gnolang/gno/gnovm/cmd/gno/test.go:46 +0x32 github.com/peterbourgon/ff/v3/ffcli.(*Command).Run(0x2?, {0xef9630?, 0xc000128000?}) /home/albttx/go/pkg/mod/github.com/peterbourgon/ff/v3@v3.3.0/ffcli/command.go:153 +0x16c github.com/peterbourgon/ff/v3/ffcli.(*Command).Run(0xc000016000?, {0xef9630?, 0xc000128000?}) /home/albttx/go/pkg/mod/github.com/peterbourgon/ff/v3@v3.3.0/ffcli/command.go:157 +0x113 github.com/peterbourgon/ff/v3/ffcli.(*Command).ParseAndRun(0x4055fc?, {0xef9630, 0xc000128000}, {0xc000112050?, 0x401230?, 0x0?}) /home/albttx/go/pkg/mod/github.com/peterbourgon/ff/v3@v3.3.0/ffcli/command.go:169 +0x4f main.main() /home/albttx/go/src/github.com/gnolang/gno/gnovm/cmd/gno/main.go:14 +0x77 exit status 2
To fix this, we can do a test with a main function, but testing with TestFunctionXXX(t *testing.T) would be nice:
main
TestFunctionXXX(t *testing.T)
The function TestFunctionXXX should be considered as a Realm
TestFunctionXXX
Directives like // PKGPATH: are not read in _test files, only in _filetest files. Can you remove it from your example for better clarity?
// PKGPATH:
_test
_filetest
Related with https://github.com/gnolang/gno/issues/1215.
Package test with suffix _test not working
✅ This work
❌ This fail
with panic output
To fix this, we can do a test with a
main
function, but testing withTestFunctionXXX(t *testing.T)
would be nice:NOTE
The function
TestFunctionXXX
should be considered as a Realm