Skip to content

Commit

Permalink
replace _test filter with change in tests functions
Browse files Browse the repository at this point in the history
  • Loading branch information
tbruyelle committed Jun 27, 2023
1 parent 1539ea3 commit 763ac29
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 10 deletions.
6 changes: 5 additions & 1 deletion gnovm/cmd/gno/test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
8 changes: 2 additions & 6 deletions gnovm/pkg/gnolang/realm.go
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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")
Expand Down
14 changes: 11 additions & 3 deletions gnovm/stdlibs/testing/match.gno
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

0 comments on commit 763ac29

Please sign in to comment.