From 7c0b1cfe8acb6fbdbda121361cbbaff42635c980 Mon Sep 17 00:00:00 2001 From: albttx Date: Mon, 6 Nov 2023 01:44:21 +0000 Subject: [PATCH] chore: fix pkg_test --- gnovm/cmd/gno/test.go | 9 +++------ gnovm/pkg/gnolang/machine.go | 4 +++- 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/gnovm/cmd/gno/test.go b/gnovm/cmd/gno/test.go index 85fe3f7ee7d..7d15698369a 100644 --- a/gnovm/cmd/gno/test.go +++ b/gnovm/cmd/gno/test.go @@ -328,9 +328,10 @@ func gnoTestPkg( // tfiles, ifiles := gno.ParseMemPackageTests(memPkg) tfiles, ifiles := parseMemPackageTests(memPkg) + testPkgName := getPkgNameFromFileset(ifiles) // run test files in pkg - { + if !strings.HasSuffix(testPkgName, "_test") { m := tests.TestMachine(testStore, stdout, gnoPkgPath) if printRuntimeMetrics { // from tm2/pkg/sdk/vm/keeper.go @@ -344,11 +345,7 @@ func gnoTestPkg( if err != nil { errs = multierr.Append(errs, err) } - } - - // run test files in xxx_test pkg - { - testPkgName := getPkgNameFromFileset(ifiles) + } else { // run xxx_test if testPkgName != "" { m := tests.TestMachine(testStore, stdout, testPkgName) m.RunMemPackage(memPkg, true) diff --git a/gnovm/pkg/gnolang/machine.go b/gnovm/pkg/gnolang/machine.go index 94232e014d2..723d5e41f85 100644 --- a/gnovm/pkg/gnolang/machine.go +++ b/gnovm/pkg/gnolang/machine.go @@ -402,7 +402,9 @@ func (m *Machine) runFiles(fns ...*FileNode) { // Files' package names must match the machine's active one. // if there is one. for _, fn := range fns { - if fn.PkgName != "" && fn.PkgName != m.Package.PkgName { + if fn.PkgName != "" && + fn.PkgName != m.Package.PkgName && + m.Package.PkgName+"_test" != fn.PkgName { panic(fmt.Sprintf("expected package name [%s] but got [%s]", m.Package.PkgName, fn.PkgName)) }