From 3b9001bfdd073d72c39e13af57b9b4b3b7978038 Mon Sep 17 00:00:00 2001 From: Thomas Bruyelle Date: Fri, 23 Jun 2023 17:46:39 +0200 Subject: [PATCH] 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)