Skip to content

Commit

Permalink
chore: doc integration command and cleanup
Browse files Browse the repository at this point in the history
Signed-off-by: gfanton <[email protected]>
  • Loading branch information
gfanton committed Jan 6, 2025
1 parent b3c3a83 commit d19d089
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 27 deletions.
26 changes: 20 additions & 6 deletions gno.land/pkg/integration/testdata_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,12 @@ import (
"github.com/stretchr/testify/require"
)

var debugTs = false

func init() { debugTs, _ = strconv.ParseBool(os.Getenv("DEBUG_TS")) }

func TestTestdata(t *testing.T) {
t.Parallel()

flagInMemoryTS, _ := strconv.ParseBool(os.Getenv("INMEMORY_TS"))
flagNoSeqTS, _ := strconv.ParseBool(os.Getenv("NO_SEQ_TS"))

p := gno_integration.NewTestingParams(t, "testdata")

if coverdir, ok := gno_integration.ResolveCoverageDir(); ok {
Expand All @@ -29,7 +28,7 @@ func TestTestdata(t *testing.T) {
require.NoError(t, err)

mode := commandKindTesting
if debugTs {
if flagInMemoryTS {
mode = commandKindInMemory
}

Expand All @@ -45,9 +44,24 @@ func TestTestdata(t *testing.T) {
return nil
}

if debugTs {
if flagInMemoryTS && !flagNoSeqTS {
testscript.RunT(tSeqShim{t}, p)
} else {
testscript.Run(t, p)
}
}

type tSeqShim struct{ *testing.T }

// noop Parallel method allow us to run test sequentially
func (tSeqShim) Parallel() {}

func (t tSeqShim) Run(name string, f func(testscript.T)) {
t.T.Run(name, func(t *testing.T) {
f(tSeqShim{t})
})
}

func (t tSeqShim) Verbose() bool {
return testing.Verbose()
}
6 changes: 6 additions & 0 deletions gno.land/pkg/integration/testscript_gnoland.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,14 @@ const (
type commandkind int

const (
// commandKindBin builds and uses an integration binary to run the testscript
// in a separate process. This should be used for any external package that
// wants to use test scripts.
commandKindBin commandkind = iota
// commandKindTesting uses the current testing binary to run the testscript
// in a separate process. This command cannot be used outside this package.
commandKindTesting
// commandKindInMemory runs testscripts in memory.
commandKindInMemory
)

Expand Down
21 changes: 0 additions & 21 deletions gno.land/pkg/integration/testscript_seqs.go
Original file line number Diff line number Diff line change
@@ -1,22 +1 @@
package integration

import (
"testing"

"github.com/rogpeppe/go-internal/testscript"
)

type tSeqShim struct{ *testing.T }

// noop Parallel method allow us to run test sequentially
func (tSeqShim) Parallel() {}

func (t tSeqShim) Run(name string, f func(testscript.T)) {
t.T.Run(name, func(t *testing.T) {
f(tSeqShim{t})
})
}

func (t tSeqShim) Verbose() bool {
return testing.Verbose()
}

0 comments on commit d19d089

Please sign in to comment.