Skip to content

Commit

Permalink
chore: fix pkg_test
Browse files Browse the repository at this point in the history
  • Loading branch information
albttx committed Nov 6, 2023
1 parent 2141917 commit 84c9af2
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 7 deletions.
9 changes: 3 additions & 6 deletions gnovm/cmd/gno/test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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)
Expand Down
4 changes: 3 additions & 1 deletion gnovm/pkg/gnolang/machine.go
Original file line number Diff line number Diff line change
Expand Up @@ -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))
}
Expand Down

0 comments on commit 84c9af2

Please sign in to comment.