From 9f5a5aedac9c52649919900c5db34c230679b4a1 Mon Sep 17 00:00:00 2001 From: Thomas Bruyelle Date: Wed, 14 Jun 2023 17:02:38 +0200 Subject: [PATCH 01/17] fix(gnovm): PrevRealm in _test files When _test files are executed, the pkg path is set to the real path to the test, which starts by `./examples/gno.land`, this leads to interpreting the test package as a non-realm, because a realm must start with `gno.lang/r`. Because of that, when calling `PrevRealm`, a test package is never considered as a realm whereas sometime it should. The fix truncates the `./examples` prefix from the test package, which ensures it is well detected as a realm when required. This had several consequences on tests execution, like `testing` and the test template must not declare global variable, or else the VM tries to persist them at the end of transaction and that triggers error. --- examples/gno.land/r/demo/tests/tests.gno | 6 +-- examples/gno.land/r/demo/tests/tests_test.gno | 16 ++++++ gnovm/cmd/gno/build.go | 2 +- gnovm/cmd/gno/test.go | 54 ++++++++++--------- gnovm/cmd/gno/util.go | 2 +- gnovm/stdlibs/testing/match.gno | 10 ++-- gnovm/tests/files/zrealm_crossrealm11.gno | 2 +- 7 files changed, 55 insertions(+), 37 deletions(-) diff --git a/examples/gno.land/r/demo/tests/tests.gno b/examples/gno.land/r/demo/tests/tests.gno index dd2518e2e49..fb49b2273ae 100644 --- a/examples/gno.land/r/demo/tests/tests.gno +++ b/examples/gno.land/r/demo/tests/tests.gno @@ -3,7 +3,7 @@ package tests import ( "std" - "gno.land/r/demo/tests/subtests" + rsubtests "gno.land/r/demo/tests/subtests" ) var counter int @@ -78,8 +78,8 @@ func GetPrevRealm() std.Realm { return std.PrevRealm() } -func GetPSubtestsPrevRealm() std.Realm { - return subtests.GetPrevRealm() +func GetRSubtestsPrevRealm() std.Realm { + return rsubtests.GetPrevRealm() } func Exec(fn func()) { diff --git a/examples/gno.land/r/demo/tests/tests_test.gno b/examples/gno.land/r/demo/tests/tests_test.gno index 6efc3f35672..3dcbeecf18c 100644 --- a/examples/gno.land/r/demo/tests/tests_test.gno +++ b/examples/gno.land/r/demo/tests/tests_test.gno @@ -1,6 +1,7 @@ package tests import ( + "std" "testing" "gno.land/p/demo/testutils" @@ -30,3 +31,18 @@ func TestAssertOriginCall(t *testing.T) { AssertOriginCall() }() } + +func TestPrevRealm(t *testing.T) { + var ( + user1Addr = std.DerivePkgAddr("user1.gno") + rTestsAddr = std.DerivePkgAddr("gno.land/r/demo/tests") + ) + // When a single realm in the frames, PrevRealm returns the user + if addr := GetPrevRealm().Addr(); addr != user1Addr { + t.Errorf("want GetPrevRealm().Addr==%s, got %s", user1Addr, addr) + } + // When 2 or more realms in the frames, PrevRealm returns the second to last + if addr := GetRSubtestsPrevRealm().Addr(); addr != rTestsAddr { + t.Errorf("want GetRSubtestsPrevRealm().Addr==%s, got %s", rTestsAddr, addr) + } +} diff --git a/gnovm/cmd/gno/build.go b/gnovm/cmd/gno/build.go index b80711586e4..07595adcddf 100644 --- a/gnovm/cmd/gno/build.go +++ b/gnovm/cmd/gno/build.go @@ -57,7 +57,7 @@ func execBuild(cfg *buildCfg, args []string, io *commands.IO) error { return flag.ErrHelp } - paths, err := gnoPackagesFromArgs(args) + paths, err := gnoPackagePathsFromArgs(args) if err != nil { return fmt.Errorf("list packages: %w", err) } diff --git a/gnovm/cmd/gno/test.go b/gnovm/cmd/gno/test.go index f5e180e694a..ab314443d11 100644 --- a/gnovm/cmd/gno/test.go +++ b/gnovm/cmd/gno/test.go @@ -14,13 +14,14 @@ import ( "text/template" "time" + "go.uber.org/multierr" + gno "github.com/gnolang/gno/gnovm/pkg/gnolang" "github.com/gnolang/gno/gnovm/tests" "github.com/gnolang/gno/tm2/pkg/commands" "github.com/gnolang/gno/tm2/pkg/errors" "github.com/gnolang/gno/tm2/pkg/std" "github.com/gnolang/gno/tm2/pkg/testutils" - "go.uber.org/multierr" ) type testCfg struct { @@ -133,7 +134,7 @@ func execTest(cfg *testCfg, args []string, io *commands.IO) error { cfg.rootDir = guessRootDir() } - pkgPaths, err := gnoPackagesFromArgs(args) + paths, err := gnoPackagePathsFromArgs(args) if err != nil { return fmt.Errorf("list packages from args: %w", err) } @@ -147,19 +148,19 @@ func execTest(cfg *testCfg, args []string, io *commands.IO) error { buildErrCount := 0 testErrCount := 0 - for _, pkgPath := range pkgPaths { + for _, path := range paths { if cfg.precompile { if verbose { - io.ErrPrintfln("=== PREC %s", pkgPath) + io.ErrPrintfln("=== PREC %s", path) } precompileOpts := newPrecompileOptions(&precompileCfg{ output: tempdirRoot, }) - err := precompilePkg(importPath(pkgPath), precompileOpts) + err := precompilePkg(importPath(path), precompileOpts) if err != nil { io.ErrPrintln(err) io.ErrPrintln("FAIL") - io.ErrPrintfln("FAIL %s", pkgPath) + io.ErrPrintfln("FAIL %s", path) io.ErrPrintln("FAIL") buildErrCount++ @@ -167,9 +168,9 @@ func execTest(cfg *testCfg, args []string, io *commands.IO) error { } if verbose { - io.ErrPrintfln("=== BUILD %s", pkgPath) + io.ErrPrintfln("=== BUILD %s", path) } - tempDir, err := ResolvePath(tempdirRoot, importPath(pkgPath)) + tempDir, err := ResolvePath(tempdirRoot, importPath(path)) if err != nil { return errors.New("cannot resolve build dir") } @@ -177,7 +178,7 @@ func execTest(cfg *testCfg, args []string, io *commands.IO) error { if err != nil { io.ErrPrintln(err) io.ErrPrintln("FAIL") - io.ErrPrintfln("FAIL %s", pkgPath) + io.ErrPrintfln("FAIL %s", path) io.ErrPrintln("FAIL") buildErrCount++ @@ -185,16 +186,16 @@ func execTest(cfg *testCfg, args []string, io *commands.IO) error { } } - unittestFiles, err := filepath.Glob(filepath.Join(pkgPath, "*_test.gno")) + unittestFiles, err := filepath.Glob(filepath.Join(path, "*_test.gno")) if err != nil { log.Fatal(err) } - filetestFiles, err := filepath.Glob(filepath.Join(pkgPath, "*_filetest.gno")) + filetestFiles, err := filepath.Glob(filepath.Join(path, "*_filetest.gno")) if err != nil { log.Fatal(err) } if len(unittestFiles) == 0 && len(filetestFiles) == 0 { - io.ErrPrintfln("? %s \t[no test files]", pkgPath) + io.ErrPrintfln("? %s \t[no test files]", path) continue } @@ -202,18 +203,18 @@ func execTest(cfg *testCfg, args []string, io *commands.IO) error { sort.Strings(filetestFiles) startedAt := time.Now() - err = gnoTestPkg(pkgPath, unittestFiles, filetestFiles, cfg, io) + err = gnoTestPkg(path, unittestFiles, filetestFiles, cfg, io) duration := time.Since(startedAt) dstr := fmtDuration(duration) if err != nil { - io.ErrPrintfln("%s: test pkg: %v", pkgPath, err) + io.ErrPrintfln("%s: test pkg: %v", path, err) io.ErrPrintfln("FAIL") - io.ErrPrintfln("FAIL %s \t%s", pkgPath, dstr) + io.ErrPrintfln("FAIL %s \t%s", path, dstr) io.ErrPrintfln("FAIL") testErrCount++ } else { - io.ErrPrintfln("ok %s \t%s", pkgPath, dstr) + io.ErrPrintfln("ok %s \t%s", path, dstr) } } if testErrCount > 0 || buildErrCount > 0 { @@ -225,7 +226,7 @@ func execTest(cfg *testCfg, args []string, io *commands.IO) error { } func gnoTestPkg( - pkgPath string, + path string, unittestFiles, filetestFiles []string, cfg *testCfg, @@ -267,14 +268,15 @@ func gnoTestPkg( // testing with *_test.gno if len(unittestFiles) > 0 { - memPkg := gno.ReadMemPackage(pkgPath, pkgPath) + pkgPath := strings.TrimPrefix(path, "./examples/") + memPkg := gno.ReadMemPackage(path, pkgPath) // tfiles, ifiles := gno.ParseMemPackageTests(memPkg) tfiles, ifiles := parseMemPackageTests(memPkg) // run test files in pkg { - m := tests.TestMachine(testStore, stdout, "main") + m := tests.TestMachine(testStore, stdout, pkgPath) if printRuntimeMetrics { // from tm2/pkg/sdk/vm/keeper.go // XXX: make maxAllocTx configurable. @@ -322,7 +324,7 @@ func gnoTestPkg( closer = testutils.CaptureStdoutAndStderr() } - testFilePath := filepath.Join(pkgPath, testFileName) + testFilePath := filepath.Join(path, testFileName) err := tests.RunFileTest(rootDir, testFilePath, tests.WithSyncWanted(cfg.updateGoldenTests)) duration := time.Since(startedAt) dstr := fmtDuration(duration) @@ -471,13 +473,13 @@ import ( "testing" ) -var tests = []testing.InternalTest{ -{{range .Tests}} - {"{{.Name}}", {{.Name}}}, -{{end}} -} - func runtest(name string) (report string) { + var tests = []testing.InternalTest{ + {{range .Tests}} + {"{{.Name}}", {{.Name}}}, + {{end}} + } + for _, test := range tests { if test.Name == name { return testing.RunTest({{printf "%q" .RunFlag}}, {{.Verbose}}, test) diff --git a/gnovm/cmd/gno/util.go b/gnovm/cmd/gno/util.go index 1bbdb968c45..de2cbb6cf4e 100644 --- a/gnovm/cmd/gno/util.go +++ b/gnovm/cmd/gno/util.go @@ -55,7 +55,7 @@ func gnoFilesFromArgs(args []string) ([]string, error) { return paths, nil } -func gnoPackagesFromArgs(args []string) ([]string, error) { +func gnoPackagePathsFromArgs(args []string) ([]string, error) { paths := []string{} for _, arg := range args { info, err := os.Stat(arg) diff --git a/gnovm/stdlibs/testing/match.gno b/gnovm/stdlibs/testing/match.gno index 5b7f509d8f6..13a7edd4f27 100644 --- a/gnovm/stdlibs/testing/match.gno +++ b/gnovm/stdlibs/testing/match.gno @@ -166,13 +166,13 @@ func isSpace(r rune) bool { return false } -var ( - matchPat string - matchRe *regexp.Regexp -) - // based on testing/internal/testdeps.TestDeps.MatchString. func matchString(pat, str string) (result bool, err error) { + var ( + matchPat string + matchRe *regexp.Regexp + ) + if matchRe == nil || matchPat != pat { matchPat = pat matchRe, err = regexp.Compile(matchPat) diff --git a/gnovm/tests/files/zrealm_crossrealm11.gno b/gnovm/tests/files/zrealm_crossrealm11.gno index ecb3555c29c..b250b07bbac 100644 --- a/gnovm/tests/files/zrealm_crossrealm11.gno +++ b/gnovm/tests/files/zrealm_crossrealm11.gno @@ -65,7 +65,7 @@ func main() { }, { callStackAdd: " -> r/demo/tests -> r/demo/tests/subtests", - callerFn: rtests.GetPSubtestsPrevRealm, + callerFn: rtests.GetRSubtestsPrevRealm, }, { callStackAdd: " -> p/demo/tests -> r/demo/tests", From 5667f861e52e995d28a75ebd3623e2aa50da9247 Mon Sep 17 00:00:00 2001 From: Thomas Bruyelle Date: Thu, 15 Jun 2023 15:05:32 +0200 Subject: [PATCH 02/17] fix for TestFunctions that write the store Probably dumb fix, should be improved --- gnovm/cmd/gno/test.go | 13 +++++++------ gnovm/pkg/gnolang/realm.go | 4 ++++ 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/gnovm/cmd/gno/test.go b/gnovm/cmd/gno/test.go index ab314443d11..a82f2f7a864 100644 --- a/gnovm/cmd/gno/test.go +++ b/gnovm/cmd/gno/test.go @@ -379,7 +379,7 @@ func runTestFiles( } m.RunFiles(files.Files...) - n := gno.MustParseFile("testmain.go", testmain) + n := gno.MustParseFile("main_test.gno", testmain) m.RunFiles(n) for _, test := range testFuncs.Tests { @@ -473,12 +473,13 @@ import ( "testing" ) +var tests = []testing.InternalTest{ +{{range .Tests}} + {"{{.Name}}", {{.Name}}}, +{{end}} +} + func runtest(name string) (report string) { - var tests = []testing.InternalTest{ - {{range .Tests}} - {"{{.Name}}", {{.Name}}}, - {{end}} - } for _, test := range tests { if test.Name == name { diff --git a/gnovm/pkg/gnolang/realm.go b/gnovm/pkg/gnolang/realm.go index 40f770c7720..a195f54cd4d 100644 --- a/gnovm/pkg/gnolang/realm.go +++ b/gnovm/pkg/gnolang/realm.go @@ -1121,6 +1121,10 @@ func copyValueWithRefs(parent Object, val Value) Value { } case *FuncValue: source := toRefNode(cv.Source) + if strings.HasSuffix(source.Location.File, "_test.gno") { + // Ignore _test files + return nil + } var closure Value if cv.Closure != nil { closure = toRefValue(parent, cv.Closure) From 24fa1d337deda947b587b9f179f0c781cfaa53d8 Mon Sep 17 00:00:00 2001 From: Thomas Bruyelle Date: Thu, 15 Jun 2023 15:37:27 +0200 Subject: [PATCH 03/17] fix annoying test --- gnovm/tests/files/zrealm_tests0.gno | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gnovm/tests/files/zrealm_tests0.gno b/gnovm/tests/files/zrealm_tests0.gno index bc07acea1b4..cfb1f08c6f4 100644 --- a/gnovm/tests/files/zrealm_tests0.gno +++ b/gnovm/tests/files/zrealm_tests0.gno @@ -972,7 +972,7 @@ func main() { // }, // "FileName": "tests.gno", // "IsMethod": false, -// "Name": "GetPSubtestsPrevRealm", +// "Name": "GetRSubtestsPrevRealm", // "PkgPath": "gno.land/r/demo/tests", // "Source": { // "@type": "/gno.RefNode", From ea64d71fb1c5fd56602f90590a1f500f79208481 Mon Sep 17 00:00:00 2001 From: Thomas Bruyelle Date: Thu, 15 Jun 2023 18:02:26 +0200 Subject: [PATCH 04/17] simplify --- gnovm/cmd/gno/test.go | 1 - gnovm/stdlibs/testing/match.gno | 14 +++----------- 2 files changed, 3 insertions(+), 12 deletions(-) diff --git a/gnovm/cmd/gno/test.go b/gnovm/cmd/gno/test.go index a82f2f7a864..c1d2b881f36 100644 --- a/gnovm/cmd/gno/test.go +++ b/gnovm/cmd/gno/test.go @@ -480,7 +480,6 @@ var tests = []testing.InternalTest{ } func runtest(name string) (report string) { - for _, test := range tests { if test.Name == name { return testing.RunTest({{printf "%q" .RunFlag}}, {{.Verbose}}, test) diff --git a/gnovm/stdlibs/testing/match.gno b/gnovm/stdlibs/testing/match.gno index 13a7edd4f27..cc34fc2f322 100644 --- a/gnovm/stdlibs/testing/match.gno +++ b/gnovm/stdlibs/testing/match.gno @@ -168,17 +168,9 @@ func isSpace(r rune) bool { // based on testing/internal/testdeps.TestDeps.MatchString. func matchString(pat, str string) (result bool, err error) { - var ( - matchPat string - matchRe *regexp.Regexp - ) - - if matchRe == nil || matchPat != pat { - matchPat = pat - matchRe, err = regexp.Compile(matchPat) - if err != nil { - return - } + matchRe, err := regexp.Compile(pat) + if err != nil { + return } return matchRe.MatchString(str), nil } From f910bf0a86c25e033c0f49682c8c1c5eb7e45698 Mon Sep 17 00:00:00 2001 From: Thomas Bruyelle Date: Fri, 16 Jun 2023 17:43:54 +0200 Subject: [PATCH 05/17] replace _test filter with change in tests functions --- gnovm/cmd/gno/test.go | 6 +++++- gnovm/pkg/gnolang/realm.go | 8 ++------ gnovm/stdlibs/testing/match.gno | 14 +++++++++++--- 3 files changed, 18 insertions(+), 10 deletions(-) diff --git a/gnovm/cmd/gno/test.go b/gnovm/cmd/gno/test.go index c1d2b881f36..ddab594c5fb 100644 --- a/gnovm/cmd/gno/test.go +++ b/gnovm/cmd/gno/test.go @@ -379,8 +379,12 @@ func runTestFiles( } m.RunFiles(files.Files...) - n := gno.MustParseFile("main_test.gno", testmain) + n := gno.MustParseFile("testmain.gno", testmain) m.RunFiles(n) + // XXX Affect an ID to testmain so it doesn't trigger a panic when + // realm.FinalizeRealmTransaction() is invoked + oo := m.Package.FBlocks[len(m.Package.FBlocks)-1] + m.Realm.AssignNewObjectID(oo.(*gno.Block)) for _, test := range testFuncs.Tests { if verbose { diff --git a/gnovm/pkg/gnolang/realm.go b/gnovm/pkg/gnolang/realm.go index a195f54cd4d..8d45cbc76a6 100644 --- a/gnovm/pkg/gnolang/realm.go +++ b/gnovm/pkg/gnolang/realm.go @@ -388,7 +388,7 @@ func (rlm *Realm) incRefCreatedDescendants(store Store, oo Object) { if !oo.GetObjectID().IsZero() { return } - rlm.assignNewObjectID(oo) + rlm.AssignNewObjectID(oo) rlm.created = append(rlm.created, oo) // RECURSE GUARD END @@ -1121,10 +1121,6 @@ func copyValueWithRefs(parent Object, val Value) Value { } case *FuncValue: source := toRefNode(cv.Source) - if strings.HasSuffix(source.Location.File, "_test.gno") { - // Ignore _test files - return nil - } var closure Value if cv.Closure != nil { closure = toRefValue(parent, cv.Closure) @@ -1394,7 +1390,7 @@ func (rlm *Realm) nextObjectID() ObjectID { // Object gets its id set (panics if already set), and becomes // marked as new and real. -func (rlm *Realm) assignNewObjectID(oo Object) ObjectID { +func (rlm *Realm) AssignNewObjectID(oo Object) ObjectID { oid := oo.GetObjectID() if !oid.IsZero() { panic("unexpected non-zero object id") diff --git a/gnovm/stdlibs/testing/match.gno b/gnovm/stdlibs/testing/match.gno index cc34fc2f322..5b7f509d8f6 100644 --- a/gnovm/stdlibs/testing/match.gno +++ b/gnovm/stdlibs/testing/match.gno @@ -166,11 +166,19 @@ func isSpace(r rune) bool { return false } +var ( + matchPat string + matchRe *regexp.Regexp +) + // based on testing/internal/testdeps.TestDeps.MatchString. func matchString(pat, str string) (result bool, err error) { - matchRe, err := regexp.Compile(pat) - if err != nil { - return + if matchRe == nil || matchPat != pat { + matchPat = pat + matchRe, err = regexp.Compile(matchPat) + if err != nil { + return + } } return matchRe.MatchString(str), nil } From 2f3f30fd0c97ae3266643b39e3901733f7558c23 Mon Sep 17 00:00:00 2001 From: Thomas Bruyelle Date: Fri, 16 Jun 2023 17:52:19 +0200 Subject: [PATCH 06/17] remove rename not so well and add too much diff --- gnovm/cmd/gno/test.go | 40 ++++++++++++++++++++-------------------- 1 file changed, 20 insertions(+), 20 deletions(-) diff --git a/gnovm/cmd/gno/test.go b/gnovm/cmd/gno/test.go index ddab594c5fb..8d66236ab2f 100644 --- a/gnovm/cmd/gno/test.go +++ b/gnovm/cmd/gno/test.go @@ -134,7 +134,7 @@ func execTest(cfg *testCfg, args []string, io *commands.IO) error { cfg.rootDir = guessRootDir() } - paths, err := gnoPackagePathsFromArgs(args) + pkgPaths, err := gnoPackagePathsFromArgs(args) if err != nil { return fmt.Errorf("list packages from args: %w", err) } @@ -148,19 +148,19 @@ func execTest(cfg *testCfg, args []string, io *commands.IO) error { buildErrCount := 0 testErrCount := 0 - for _, path := range paths { + for _, pkgPath := range pkgPaths { if cfg.precompile { if verbose { - io.ErrPrintfln("=== PREC %s", path) + io.ErrPrintfln("=== PREC %s", pkgPath) } precompileOpts := newPrecompileOptions(&precompileCfg{ output: tempdirRoot, }) - err := precompilePkg(importPath(path), precompileOpts) + err := precompilePkg(importPath(pkgPath), precompileOpts) if err != nil { io.ErrPrintln(err) io.ErrPrintln("FAIL") - io.ErrPrintfln("FAIL %s", path) + io.ErrPrintfln("FAIL %s", pkgPath) io.ErrPrintln("FAIL") buildErrCount++ @@ -168,9 +168,9 @@ func execTest(cfg *testCfg, args []string, io *commands.IO) error { } if verbose { - io.ErrPrintfln("=== BUILD %s", path) + io.ErrPrintfln("=== BUILD %s", pkgPath) } - tempDir, err := ResolvePath(tempdirRoot, importPath(path)) + tempDir, err := ResolvePath(tempdirRoot, importPath(pkgPath)) if err != nil { return errors.New("cannot resolve build dir") } @@ -178,7 +178,7 @@ func execTest(cfg *testCfg, args []string, io *commands.IO) error { if err != nil { io.ErrPrintln(err) io.ErrPrintln("FAIL") - io.ErrPrintfln("FAIL %s", path) + io.ErrPrintfln("FAIL %s", pkgPath) io.ErrPrintln("FAIL") buildErrCount++ @@ -186,16 +186,16 @@ func execTest(cfg *testCfg, args []string, io *commands.IO) error { } } - unittestFiles, err := filepath.Glob(filepath.Join(path, "*_test.gno")) + unittestFiles, err := filepath.Glob(filepath.Join(pkgPath, "*_test.gno")) if err != nil { log.Fatal(err) } - filetestFiles, err := filepath.Glob(filepath.Join(path, "*_filetest.gno")) + filetestFiles, err := filepath.Glob(filepath.Join(pkgPath, "*_filetest.gno")) if err != nil { log.Fatal(err) } if len(unittestFiles) == 0 && len(filetestFiles) == 0 { - io.ErrPrintfln("? %s \t[no test files]", path) + io.ErrPrintfln("? %s \t[no test files]", pkgPath) continue } @@ -203,18 +203,18 @@ func execTest(cfg *testCfg, args []string, io *commands.IO) error { sort.Strings(filetestFiles) startedAt := time.Now() - err = gnoTestPkg(path, unittestFiles, filetestFiles, cfg, io) + err = gnoTestPkg(pkgPath, unittestFiles, filetestFiles, cfg, io) duration := time.Since(startedAt) dstr := fmtDuration(duration) if err != nil { - io.ErrPrintfln("%s: test pkg: %v", path, err) + io.ErrPrintfln("%s: test pkg: %v", pkgPath, err) io.ErrPrintfln("FAIL") - io.ErrPrintfln("FAIL %s \t%s", path, dstr) + io.ErrPrintfln("FAIL %s \t%s", pkgPath, dstr) io.ErrPrintfln("FAIL") testErrCount++ } else { - io.ErrPrintfln("ok %s \t%s", path, dstr) + io.ErrPrintfln("ok %s \t%s", pkgPath, dstr) } } if testErrCount > 0 || buildErrCount > 0 { @@ -226,7 +226,7 @@ func execTest(cfg *testCfg, args []string, io *commands.IO) error { } func gnoTestPkg( - path string, + pkgPath string, unittestFiles, filetestFiles []string, cfg *testCfg, @@ -268,15 +268,15 @@ func gnoTestPkg( // testing with *_test.gno if len(unittestFiles) > 0 { - pkgPath := strings.TrimPrefix(path, "./examples/") - memPkg := gno.ReadMemPackage(path, pkgPath) + pkgName := strings.TrimPrefix(pkgPath, "./examples/") + memPkg := gno.ReadMemPackage(pkgPath, pkgName) // tfiles, ifiles := gno.ParseMemPackageTests(memPkg) tfiles, ifiles := parseMemPackageTests(memPkg) // run test files in pkg { - m := tests.TestMachine(testStore, stdout, pkgPath) + m := tests.TestMachine(testStore, stdout, pkgName) if printRuntimeMetrics { // from tm2/pkg/sdk/vm/keeper.go // XXX: make maxAllocTx configurable. @@ -324,7 +324,7 @@ func gnoTestPkg( closer = testutils.CaptureStdoutAndStderr() } - testFilePath := filepath.Join(path, testFileName) + testFilePath := filepath.Join(pkgPath, testFileName) err := tests.RunFileTest(rootDir, testFilePath, tests.WithSyncWanted(cfg.updateGoldenTests)) duration := time.Since(startedAt) dstr := fmtDuration(duration) From 47fbd416ead80c285794d470f375c2567fe89074 Mon Sep 17 00:00:00 2001 From: Thomas Bruyelle Date: Wed, 21 Jun 2023 13:54:13 +0200 Subject: [PATCH 07/17] better use the machine API --- gnovm/cmd/gno/test.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/gnovm/cmd/gno/test.go b/gnovm/cmd/gno/test.go index 8d66236ab2f..e6c77817f6a 100644 --- a/gnovm/cmd/gno/test.go +++ b/gnovm/cmd/gno/test.go @@ -383,8 +383,8 @@ func runTestFiles( m.RunFiles(n) // XXX Affect an ID to testmain so it doesn't trigger a panic when // realm.FinalizeRealmTransaction() is invoked - oo := m.Package.FBlocks[len(m.Package.FBlocks)-1] - m.Realm.AssignNewObjectID(oo.(*gno.Block)) + oo := m.Package.GetFileBlock(m.Store, n.Name) + m.Realm.AssignNewObjectID(oo) for _, test := range testFuncs.Tests { if verbose { From 917337bc7c3684ceccfa386f879cc3e3c8508eca Mon Sep 17 00:00:00 2001 From: Thomas Bruyelle Date: Thu, 22 Jun 2023 14:17:08 +0200 Subject: [PATCH 08/17] do not assign id to testmain if it's not a realm --- gnovm/cmd/gno/test.go | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/gnovm/cmd/gno/test.go b/gnovm/cmd/gno/test.go index e6c77817f6a..f2292f80747 100644 --- a/gnovm/cmd/gno/test.go +++ b/gnovm/cmd/gno/test.go @@ -381,10 +381,13 @@ func runTestFiles( m.RunFiles(files.Files...) n := gno.MustParseFile("testmain.gno", testmain) m.RunFiles(n) - // XXX Affect an ID to testmain so it doesn't trigger a panic when - // realm.FinalizeRealmTransaction() is invoked - oo := m.Package.GetFileBlock(m.Store, n.Name) - m.Realm.AssignNewObjectID(oo) + + if m.Realm != nil { + // XXX Affect an ID to testmain if it's under a realm, so it doesn't + // trigger a panic when realm.FinalizeRealmTransaction() is invoked. + b := m.Package.GetFileBlock(m.Store, n.Name) + m.Realm.AssignNewObjectID(b) + } for _, test := range testFuncs.Tests { if verbose { From cd3213d2a2e96250d0e7afdf0779867f9c6926de Mon Sep 17 00:00:00 2001 From: Thomas Bruyelle Date: Fri, 23 Jun 2023 17:46:39 +0200 Subject: [PATCH 09/17] remove global var from testing --- .../gno.land/p/demo/tests/subtests/subtests_test.gno | 5 +++++ gnovm/cmd/gno/test.go | 5 ++--- gnovm/stdlibs/testing/match.gno | 10 +++++----- 3 files changed, 12 insertions(+), 8 deletions(-) create mode 100644 examples/gno.land/p/demo/tests/subtests/subtests_test.gno diff --git a/examples/gno.land/p/demo/tests/subtests/subtests_test.gno b/examples/gno.land/p/demo/tests/subtests/subtests_test.gno new file mode 100644 index 00000000000..e3ea2c600c4 --- /dev/null +++ b/examples/gno.land/p/demo/tests/subtests/subtests_test.gno @@ -0,0 +1,5 @@ +package subtests_test + +func TestPrivate(t *testing.T) { + println("hello from private test") +} diff --git a/gnovm/cmd/gno/test.go b/gnovm/cmd/gno/test.go index f2292f80747..fd9271ca22c 100644 --- a/gnovm/cmd/gno/test.go +++ b/gnovm/cmd/gno/test.go @@ -241,11 +241,9 @@ func gnoTestPkg( stdin = io.In stdout = io.Out stderr = io.Err + errs error ) - filter := splitRegexp(runFlag) - var errs error - mode := tests.ImportModeStdlibsOnly if cfg.withNativeFallback { // XXX: display a warn? @@ -310,6 +308,7 @@ func gnoTestPkg( for _, testFile := range filetestFiles { testFileName := filepath.Base(testFile) testName := "file/" + testFileName + filter := splitRegexp(runFlag) if !shouldRun(filter, testName) { continue } diff --git a/gnovm/stdlibs/testing/match.gno b/gnovm/stdlibs/testing/match.gno index 5b7f509d8f6..13a7edd4f27 100644 --- a/gnovm/stdlibs/testing/match.gno +++ b/gnovm/stdlibs/testing/match.gno @@ -166,13 +166,13 @@ func isSpace(r rune) bool { return false } -var ( - matchPat string - matchRe *regexp.Regexp -) - // based on testing/internal/testdeps.TestDeps.MatchString. func matchString(pat, str string) (result bool, err error) { + var ( + matchPat string + matchRe *regexp.Regexp + ) + if matchRe == nil || matchPat != pat { matchPat = pat matchRe, err = regexp.Compile(matchPat) From a3e86bdb14a6871def9133183e614702264a36d1 Mon Sep 17 00:00:00 2001 From: Thomas Bruyelle Date: Tue, 27 Jun 2023 10:56:21 +0200 Subject: [PATCH 10/17] Revert "replace _test filter with change in tests functions" This reverts commit 763ac290930534c1ffcd260653db862f16bfc0a4. --- .../gno.land/p/demo/tests/subtests/subtests_test.gno | 5 ----- gnovm/cmd/gno/test.go | 9 +-------- gnovm/pkg/gnolang/realm.go | 8 ++++++-- gnovm/stdlibs/testing/match.gno | 10 +++++----- 4 files changed, 12 insertions(+), 20 deletions(-) delete mode 100644 examples/gno.land/p/demo/tests/subtests/subtests_test.gno diff --git a/examples/gno.land/p/demo/tests/subtests/subtests_test.gno b/examples/gno.land/p/demo/tests/subtests/subtests_test.gno deleted file mode 100644 index e3ea2c600c4..00000000000 --- a/examples/gno.land/p/demo/tests/subtests/subtests_test.gno +++ /dev/null @@ -1,5 +0,0 @@ -package subtests_test - -func TestPrivate(t *testing.T) { - println("hello from private test") -} diff --git a/gnovm/cmd/gno/test.go b/gnovm/cmd/gno/test.go index fd9271ca22c..cf95e5c1b4b 100644 --- a/gnovm/cmd/gno/test.go +++ b/gnovm/cmd/gno/test.go @@ -378,16 +378,9 @@ func runTestFiles( } m.RunFiles(files.Files...) - n := gno.MustParseFile("testmain.gno", testmain) + n := gno.MustParseFile("main_test.gno", testmain) m.RunFiles(n) - if m.Realm != nil { - // XXX Affect an ID to testmain if it's under a realm, so it doesn't - // trigger a panic when realm.FinalizeRealmTransaction() is invoked. - b := m.Package.GetFileBlock(m.Store, n.Name) - m.Realm.AssignNewObjectID(b) - } - for _, test := range testFuncs.Tests { if verbose { io.ErrPrintfln("=== RUN %s", test.Name) diff --git a/gnovm/pkg/gnolang/realm.go b/gnovm/pkg/gnolang/realm.go index 8d45cbc76a6..a195f54cd4d 100644 --- a/gnovm/pkg/gnolang/realm.go +++ b/gnovm/pkg/gnolang/realm.go @@ -388,7 +388,7 @@ func (rlm *Realm) incRefCreatedDescendants(store Store, oo Object) { if !oo.GetObjectID().IsZero() { return } - rlm.AssignNewObjectID(oo) + rlm.assignNewObjectID(oo) rlm.created = append(rlm.created, oo) // RECURSE GUARD END @@ -1121,6 +1121,10 @@ func copyValueWithRefs(parent Object, val Value) Value { } case *FuncValue: source := toRefNode(cv.Source) + if strings.HasSuffix(source.Location.File, "_test.gno") { + // Ignore _test files + return nil + } var closure Value if cv.Closure != nil { closure = toRefValue(parent, cv.Closure) @@ -1390,7 +1394,7 @@ func (rlm *Realm) nextObjectID() ObjectID { // Object gets its id set (panics if already set), and becomes // marked as new and real. -func (rlm *Realm) AssignNewObjectID(oo Object) ObjectID { +func (rlm *Realm) assignNewObjectID(oo Object) ObjectID { oid := oo.GetObjectID() if !oid.IsZero() { panic("unexpected non-zero object id") diff --git a/gnovm/stdlibs/testing/match.gno b/gnovm/stdlibs/testing/match.gno index 13a7edd4f27..5b7f509d8f6 100644 --- a/gnovm/stdlibs/testing/match.gno +++ b/gnovm/stdlibs/testing/match.gno @@ -166,13 +166,13 @@ func isSpace(r rune) bool { return false } +var ( + matchPat string + matchRe *regexp.Regexp +) + // based on testing/internal/testdeps.TestDeps.MatchString. func matchString(pat, str string) (result bool, err error) { - var ( - matchPat string - matchRe *regexp.Regexp - ) - if matchRe == nil || matchPat != pat { matchPat = pat matchRe, err = regexp.Compile(matchPat) From 85cc13531227209375e4577481936160b2f99667 Mon Sep 17 00:00:00 2001 From: Thomas Bruyelle Date: Tue, 4 Jul 2023 16:41:48 +0200 Subject: [PATCH 11/17] exclude testing from saved objects --- gnovm/cmd/gno/test.go | 1 + gnovm/tests/imports.go | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/gnovm/cmd/gno/test.go b/gnovm/cmd/gno/test.go index cf95e5c1b4b..2332ff50cc6 100644 --- a/gnovm/cmd/gno/test.go +++ b/gnovm/cmd/gno/test.go @@ -266,6 +266,7 @@ func gnoTestPkg( // testing with *_test.gno if len(unittestFiles) > 0 { + // TODO not pkgName, bc it's usually the last part of the pkgPath pkgName := strings.TrimPrefix(pkgPath, "./examples/") memPkg := gno.ReadMemPackage(pkgPath, pkgName) diff --git a/gnovm/tests/imports.go b/gnovm/tests/imports.go index 58d62f02d8d..2342a7379a8 100644 --- a/gnovm/tests/imports.go +++ b/gnovm/tests/imports.go @@ -104,7 +104,8 @@ func TestStore(rootDir, filesPath string, stdin io.Reader, stdout, stderr io.Wri Output: stdout, Store: store, }) - return m2.RunMemPackage(memPkg, true) + save := pkgPath != "testing" + return m2.RunMemPackage(memPkg, save) } } From a8ab7e9b07488ceff2c32d46653f12d823066c7d Mon Sep 17 00:00:00 2001 From: Thomas Bruyelle Date: Tue, 4 Jul 2023 16:47:01 +0200 Subject: [PATCH 12/17] rename pkgName to gnoPkgPath --- gnovm/cmd/gno/build.go | 2 +- gnovm/cmd/gno/test.go | 10 +++++----- gnovm/cmd/gno/util.go | 2 +- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/gnovm/cmd/gno/build.go b/gnovm/cmd/gno/build.go index 07595adcddf..b80711586e4 100644 --- a/gnovm/cmd/gno/build.go +++ b/gnovm/cmd/gno/build.go @@ -57,7 +57,7 @@ func execBuild(cfg *buildCfg, args []string, io *commands.IO) error { return flag.ErrHelp } - paths, err := gnoPackagePathsFromArgs(args) + paths, err := gnoPackagesFromArgs(args) if err != nil { return fmt.Errorf("list packages: %w", err) } diff --git a/gnovm/cmd/gno/test.go b/gnovm/cmd/gno/test.go index 2332ff50cc6..0ffffb50512 100644 --- a/gnovm/cmd/gno/test.go +++ b/gnovm/cmd/gno/test.go @@ -134,7 +134,7 @@ func execTest(cfg *testCfg, args []string, io *commands.IO) error { cfg.rootDir = guessRootDir() } - pkgPaths, err := gnoPackagePathsFromArgs(args) + pkgPaths, err := gnoPackagesFromArgs(args) if err != nil { return fmt.Errorf("list packages from args: %w", err) } @@ -266,16 +266,16 @@ func gnoTestPkg( // testing with *_test.gno if len(unittestFiles) > 0 { - // TODO not pkgName, bc it's usually the last part of the pkgPath - pkgName := strings.TrimPrefix(pkgPath, "./examples/") - memPkg := gno.ReadMemPackage(pkgPath, pkgName) + // FIXME: read gnoPkgPath from gno.mod when ready + gnoPkgPath := strings.TrimPrefix(pkgPath, "./examples/") + memPkg := gno.ReadMemPackage(pkgPath, gnoPkgPath) // tfiles, ifiles := gno.ParseMemPackageTests(memPkg) tfiles, ifiles := parseMemPackageTests(memPkg) // run test files in pkg { - m := tests.TestMachine(testStore, stdout, pkgName) + m := tests.TestMachine(testStore, stdout, gnoPkgPath) if printRuntimeMetrics { // from tm2/pkg/sdk/vm/keeper.go // XXX: make maxAllocTx configurable. diff --git a/gnovm/cmd/gno/util.go b/gnovm/cmd/gno/util.go index de2cbb6cf4e..1bbdb968c45 100644 --- a/gnovm/cmd/gno/util.go +++ b/gnovm/cmd/gno/util.go @@ -55,7 +55,7 @@ func gnoFilesFromArgs(args []string) ([]string, error) { return paths, nil } -func gnoPackagePathsFromArgs(args []string) ([]string, error) { +func gnoPackagesFromArgs(args []string) ([]string, error) { paths := []string{} for _, arg := range args { info, err := os.Stat(arg) From 13089a5dfed2561f584cb1a5c65a1c4c0f7dd1ac Mon Sep 17 00:00:00 2001 From: Thomas Bruyelle Date: Mon, 31 Jul 2023 12:33:36 +0200 Subject: [PATCH 13/17] read gnoPkgPath from gno.mod, if not found, generate a random realm one --- gnovm/cmd/gno/main_test.go | 2 +- gnovm/cmd/gno/test.go | 13 +++++++++++-- gnovm/cmd/gno/test_test.go | 6 +++--- gnovm/pkg/doc/dirs.go | 3 +++ gnovm/pkg/gnolang/realm.go | 2 +- gnovm/pkg/gnomod/parse.go | 34 ++++++++++++++++++++++++++++++++++ 6 files changed, 53 insertions(+), 7 deletions(-) diff --git a/gnovm/cmd/gno/main_test.go b/gnovm/cmd/gno/main_test.go index 6b9a6f5c0d8..bc4fd8eb4b8 100644 --- a/gnovm/cmd/gno/main_test.go +++ b/gnovm/cmd/gno/main_test.go @@ -92,7 +92,7 @@ func testMainCaseRun(t *testing.T, tc []testMainCase) { require.False(t, recoverShouldBeEmpty, "should panic") require.True(t, errShouldBeEmpty, "should not return an error") if test.recoverShouldContain != "" { - require.Contains(t, output, test.recoverShouldContain, "recover should contain") + require.Regexpf(t, test.recoverShouldContain, output, "recover should contain") } if test.recoverShouldBe != "" { require.Equal(t, test.recoverShouldBe, output, "recover should be") diff --git a/gnovm/cmd/gno/test.go b/gnovm/cmd/gno/test.go index 0ffffb50512..46cb4915777 100644 --- a/gnovm/cmd/gno/test.go +++ b/gnovm/cmd/gno/test.go @@ -17,9 +17,11 @@ import ( "go.uber.org/multierr" gno "github.com/gnolang/gno/gnovm/pkg/gnolang" + "github.com/gnolang/gno/gnovm/pkg/gnomod" "github.com/gnolang/gno/gnovm/tests" "github.com/gnolang/gno/tm2/pkg/commands" "github.com/gnolang/gno/tm2/pkg/errors" + "github.com/gnolang/gno/tm2/pkg/random" "github.com/gnolang/gno/tm2/pkg/std" "github.com/gnolang/gno/tm2/pkg/testutils" ) @@ -266,8 +268,15 @@ func gnoTestPkg( // testing with *_test.gno if len(unittestFiles) > 0 { - // FIXME: read gnoPkgPath from gno.mod when ready - gnoPkgPath := strings.TrimPrefix(pkgPath, "./examples/") + // Determine gnoPkgPath by reading gno.mod + var gnoPkgPath string + modfile, err := gnomod.ParseAt(pkgPath) + if err == nil { + gnoPkgPath = modfile.Module.Mod.Path + } else { + // unable to read pkgPath from gno.mod, generate a random realm path + gnoPkgPath = gno.GnoRealmPkgsPrefixBefore + random.RandStr(8) + } memPkg := gno.ReadMemPackage(pkgPath, gnoPkgPath) // tfiles, ifiles := gno.ParseMemPackageTests(memPkg) diff --git a/gnovm/cmd/gno/test_test.go b/gnovm/cmd/gno/test_test.go index 9059bc365dc..67df26facd7 100644 --- a/gnovm/cmd/gno/test_test.go +++ b/gnovm/cmd/gno/test_test.go @@ -153,7 +153,7 @@ func TestTest(t *testing.T) { }, { args: []string{"test", "--verbose", "../../tests/integ/native-lib"}, - recoverShouldContain: "./../../tests/integ/native-lib/contract.gno:1: unknown import path net", + recoverShouldContain: "gno.land/r/\\w{8}/contract.gno:1: unknown import path net", }, { args: []string{"test", "--verbose", "--with-native-fallback", "../../tests/integ/native-lib"}, @@ -161,11 +161,11 @@ func TestTest(t *testing.T) { }, { args: []string{"test", "--verbose", "../../tests/integ/unknown-lib"}, - recoverShouldContain: "./../../tests/integ/unknown-lib/contract.gno:1: unknown import path foobarbaz", + recoverShouldContain: "gno.land/r/\\w{8}/contract.gno:1: unknown import path foobarbaz", }, { args: []string{"test", "--verbose", "--with-native-fallback", "../../tests/integ/unknown-lib"}, - recoverShouldContain: "./../../tests/integ/unknown-lib/contract.gno:1: unknown import path foobarbaz", + recoverShouldContain: "gno.land/r/\\w{8}/contract.gno:1: unknown import path foobarbaz", }, { args: []string{"test", "--verbose", "--print-runtime-metrics", "../../../examples/gno.land/p/demo/ufmt"}, diff --git a/gnovm/pkg/doc/dirs.go b/gnovm/pkg/doc/dirs.go index df8640a65cb..21216828ce4 100644 --- a/gnovm/pkg/doc/dirs.go +++ b/gnovm/pkg/doc/dirs.go @@ -70,6 +70,9 @@ func newDirs(dirs []string, modDirs []string) *bfsDirs { // tries to parse gno mod file given the filename, using Parse and Validate from // the gnomod package +// +// TODO(tb): replace by `gnomod.ParseAt` ? The key difference is the latter +// looks for gno.mod in parent directories, while this function doesn't. func parseGnoMod(fname string) (*gnomod.File, error) { file, err := os.Stat(fname) if err != nil { diff --git a/gnovm/pkg/gnolang/realm.go b/gnovm/pkg/gnolang/realm.go index a195f54cd4d..567aea58284 100644 --- a/gnovm/pkg/gnolang/realm.go +++ b/gnovm/pkg/gnolang/realm.go @@ -1506,7 +1506,7 @@ func isUnsaved(oo Object) bool { func IsRealmPath(pkgPath string) bool { // TODO: make it more distinct to distinguish from normal paths. - if strings.HasPrefix(pkgPath, "gno.land/r/") { + if strings.HasPrefix(pkgPath, GnoRealmPkgsPrefixBefore) { return true } else { return false diff --git a/gnovm/pkg/gnomod/parse.go b/gnovm/pkg/gnomod/parse.go index a23a5a06b46..588c0f231a2 100644 --- a/gnovm/pkg/gnomod/parse.go +++ b/gnovm/pkg/gnomod/parse.go @@ -2,6 +2,9 @@ package gnomod import ( "fmt" + "os" + "path" + "path/filepath" "reflect" "strings" @@ -9,6 +12,37 @@ import ( "golang.org/x/mod/module" ) +// ParseAt parses, validates and returns a gno.mod file located at dir or at +// dir's parents. +func ParseAt(dir string) (*File, error) { + ferr := func(err error) (*File, error) { + return nil, fmt.Errorf("parsing gno.mod at %s: %w", dir, err) + } + + // FindRootDir requires absolute path, make sure its the case + absDir, err := filepath.Abs(dir) + if err != nil { + return ferr(err) + } + rd, err := FindRootDir(absDir) + if err != nil { + return ferr(err) + } + fname := path.Join(rd, "gno.mod") + b, err := os.ReadFile(fname) + if err != nil { + return ferr(err) + } + gm, err := Parse(fname, b) + if err != nil { + return ferr(err) + } + if err := gm.Validate(); err != nil { + return ferr(err) + } + return gm, nil +} + // Parse parses and returns a gno.mod file. // // - file is the name of the file, used in positions and errors. From 7798dfb98c61783324af49f643ce1693ebd62db9 Mon Sep 17 00:00:00 2001 From: Thomas Bruyelle Date: Mon, 31 Jul 2023 22:18:13 +0200 Subject: [PATCH 14/17] add comment --- gnovm/tests/imports.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gnovm/tests/imports.go b/gnovm/tests/imports.go index 2342a7379a8..0af77f9c59c 100644 --- a/gnovm/tests/imports.go +++ b/gnovm/tests/imports.go @@ -104,7 +104,7 @@ func TestStore(rootDir, filesPath string, stdin io.Reader, stdout, stderr io.Wri Output: stdout, Store: store, }) - save := pkgPath != "testing" + save := pkgPath != "testing" // never save the "testing" package return m2.RunMemPackage(memPkg, save) } } From 836b71de72e2ffea6c124c3019f18db03bbebb72 Mon Sep 17 00:00:00 2001 From: Thomas Bruyelle Date: Mon, 31 Jul 2023 23:28:42 +0200 Subject: [PATCH 15/17] more splitRegexp outside the loop --- gnovm/cmd/gno/test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gnovm/cmd/gno/test.go b/gnovm/cmd/gno/test.go index 46cb4915777..b99645df0b4 100644 --- a/gnovm/cmd/gno/test.go +++ b/gnovm/cmd/gno/test.go @@ -315,10 +315,10 @@ func gnoTestPkg( // testing with *_filetest.gno { + filter := splitRegexp(runFlag) for _, testFile := range filetestFiles { testFileName := filepath.Base(testFile) testName := "file/" + testFileName - filter := splitRegexp(runFlag) if !shouldRun(filter, testName) { continue } From 724d3b78229892c9b3b2917d0a6f2aeb06f4af20 Mon Sep 17 00:00:00 2001 From: Thomas Bruyelle Date: Fri, 4 Aug 2023 14:47:49 +0200 Subject: [PATCH 16/17] Update gnovm/pkg/gnomod/parse.go Co-authored-by: Manfred Touron <94029+moul@users.noreply.github.com> --- gnovm/pkg/gnomod/parse.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gnovm/pkg/gnomod/parse.go b/gnovm/pkg/gnomod/parse.go index 588c0f231a2..514388ebbca 100644 --- a/gnovm/pkg/gnomod/parse.go +++ b/gnovm/pkg/gnomod/parse.go @@ -28,7 +28,7 @@ func ParseAt(dir string) (*File, error) { if err != nil { return ferr(err) } - fname := path.Join(rd, "gno.mod") + fname := filepath.Join(rd, "gno.mod") b, err := os.ReadFile(fname) if err != nil { return ferr(err) From 0404c36053f3793e34a9b70e3217be3ba195ef4e Mon Sep 17 00:00:00 2001 From: Thomas Bruyelle Date: Fri, 4 Aug 2023 15:10:12 +0200 Subject: [PATCH 17/17] fix after apply suggestion --- gnovm/pkg/gnomod/parse.go | 1 - 1 file changed, 1 deletion(-) diff --git a/gnovm/pkg/gnomod/parse.go b/gnovm/pkg/gnomod/parse.go index 514388ebbca..5bda3c31f70 100644 --- a/gnovm/pkg/gnomod/parse.go +++ b/gnovm/pkg/gnomod/parse.go @@ -3,7 +3,6 @@ package gnomod import ( "fmt" "os" - "path" "path/filepath" "reflect" "strings"