Skip to content

Commit

Permalink
Load pkgs from GNO_HOME
Browse files Browse the repository at this point in the history
  • Loading branch information
harry-hov committed Jun 20, 2023
1 parent ac29bd2 commit 83c84aa
Showing 1 changed file with 15 additions and 10 deletions.
25 changes: 15 additions & 10 deletions gnovm/tests/imports.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ import (
gno "github.com/gnolang/gno/gnovm/pkg/gnolang"
"github.com/gnolang/gno/gnovm/stdlibs"
"github.com/gnolang/gno/tm2/pkg/crypto"
"github.com/gnolang/gno/tm2/pkg/crypto/keys/client"
dbm "github.com/gnolang/gno/tm2/pkg/db"
osm "github.com/gnolang/gno/tm2/pkg/os"
"github.com/gnolang/gno/tm2/pkg/std"
Expand Down Expand Up @@ -423,17 +424,21 @@ func TestStore(rootDir, filesPath string, stdin io.Reader, stdout, stderr io.Wri
}

// if examples package...
examplePath := filepath.Join(rootDir, "examples", pkgPath)
if osm.DirExists(examplePath) {
memPkg := gno.ReadMemPackage(examplePath, pkgPath)
m2 := gno.NewMachineWithOptions(gno.MachineOptions{
PkgPath: "test",
Output: stdout,
Store: store,
})
pn, pv = m2.RunMemPackage(memPkg, true)
return
homeDir := client.HomeDir()
if homeDir != "" {
examplePath := filepath.Join(homeDir, "pkg", "mod", pkgPath)
if osm.DirExists(examplePath) {
memPkg := gno.ReadMemPackage(examplePath, pkgPath)
m2 := gno.NewMachineWithOptions(gno.MachineOptions{
PkgPath: "test",
Output: stdout,
Store: store,
})
pn, pv = m2.RunMemPackage(memPkg, true)
return
}
}

return nil, nil
}
// NOTE: store is also used in closure above.
Expand Down

0 comments on commit 83c84aa

Please sign in to comment.