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 3410030 commit 7c0b1cf
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)

Check warning on line 331 in gnovm/cmd/gno/test.go

View check run for this annotation

Codecov / codecov/patch

gnovm/cmd/gno/test.go#L331

Added line #L331 was not covered by tests

// run test files in pkg
{
if !strings.HasSuffix(testPkgName, "_test") {

Check warning on line 334 in gnovm/cmd/gno/test.go

View check run for this annotation

Codecov / codecov/patch

gnovm/cmd/gno/test.go#L334

Added line #L334 was not covered by tests
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

Check warning on line 348 in gnovm/cmd/gno/test.go

View check run for this annotation

Codecov / codecov/patch

gnovm/cmd/gno/test.go#L348

Added line #L348 was not covered by tests
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 7c0b1cf

Please sign in to comment.