Skip to content

Commit

Permalink
fix: speed gnovm integration tests
Browse files Browse the repository at this point in the history
Signed-off-by: gfanton <[email protected]>
  • Loading branch information
gfanton committed Dec 20, 2024
1 parent f664c62 commit e55ff48
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 11 deletions.
3 changes: 2 additions & 1 deletion gnovm/cmd/gno/testdata_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ func Test_Scripts(t *testing.T) {
testdirs, err := os.ReadDir(testdata)
require.NoError(t, err)

homeDir, buildDir := t.TempDir(), t.TempDir()
for _, dir := range testdirs {
if !dir.IsDir() {
continue
Expand All @@ -36,7 +37,7 @@ func Test_Scripts(t *testing.T) {
require.NoError(t, err)
}

err := integration.SetupGno(&p, t.TempDir())
err := integration.SetupGno(&p, homeDir, buildDir)
require.NoError(t, err)

testscript.Run(t, p)
Expand Down
12 changes: 2 additions & 10 deletions gnovm/pkg/integration/gno.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import (
// If the `gno` binary doesn't exist, it's built using the `go build` command into the specified buildDir.
// The function also include the `gno` command into `p.Cmds` to and wrap environment into p.Setup
// to correctly set up the environment variables needed for the `gno` command.
func SetupGno(p *testscript.Params, buildDir string) error {
func SetupGno(p *testscript.Params, homeDir, buildDir string) error {
// Try to fetch `GNOROOT` from the environment variables
gnoroot := gnoenv.RootDir()

Expand Down Expand Up @@ -62,18 +62,10 @@ func SetupGno(p *testscript.Params, buildDir string) error {
// Set the GNOROOT environment variable
env.Setenv("GNOROOT", gnoroot)

// Create a temporary home directory because certain commands require access to $HOME/.cache/go-build
home, err := os.MkdirTemp("", "gno")
if err != nil {
return fmt.Errorf("unable to create temporary home directory: %w", err)
}
env.Setenv("HOME", home)
env.Setenv("HOME", homeDir)
// Avoids go command printing errors relating to lack of go.mod.
env.Setenv("GO111MODULE", "off")

// Cleanup home folder
env.Defer(func() { os.RemoveAll(home) })

return nil
}

Expand Down

0 comments on commit e55ff48

Please sign in to comment.