From 48e6cc831ba7a398f464e003c20e8337b75c05ca Mon Sep 17 00:00:00 2001 From: Hariom Verma Date: Fri, 7 Jul 2023 03:01:21 +0530 Subject: [PATCH 01/16] Initialize `gno mod init` command --- gnovm/cmd/gno/mod.go | 34 ++++++++++++++++++++++++++++++++++ gnovm/pkg/gnomod/gnomod.go | 5 +++++ 2 files changed, 39 insertions(+) diff --git a/gnovm/cmd/gno/mod.go b/gnovm/cmd/gno/mod.go index b5e13b8913d..b854b3f251a 100644 --- a/gnovm/cmd/gno/mod.go +++ b/gnovm/cmd/gno/mod.go @@ -30,6 +30,7 @@ func newModCmd(io *commands.IO) *commands.Command { cmd.AddSubCommands( newModDownloadCmd(io), + newModInitCmd(), ) return cmd @@ -51,6 +52,20 @@ func newModDownloadCmd(io *commands.IO) *commands.Command { ) } +func newModInitCmd() *commands.Command { + return commands.NewCommand( + commands.Metadata{ + Name: "init", + ShortUsage: "init [module-path]", + ShortHelp: "Initialize gno.mod file in current directory", + }, + nil, + func(_ context.Context, args []string) error { + return execModInit(args) + }, + ) +} + func (c *modDownloadCfg) RegisterFlags(fs *flag.FlagSet) { fs.StringVar( &c.remote, @@ -118,3 +133,22 @@ func execModDownload(cfg *modDownloadCfg, args []string, io *commands.IO) error return nil } + +func execModInit(args []string) error { + if len(args) > 1 { + return flag.ErrHelp + } + var modPath string + if len(args) == 1 { + modPath = args[0] + } + dir, err := os.Getwd() + if err != nil { + return err + } + if err := gnomod.CreateGnoModFile(dir, modPath); err != nil { + return fmt.Errorf("create gno.mod file: %w", err) + } + + return nil +} diff --git a/gnovm/pkg/gnomod/gnomod.go b/gnovm/pkg/gnomod/gnomod.go index 0fd22d659a3..6237ad55fa7 100644 --- a/gnovm/pkg/gnomod/gnomod.go +++ b/gnovm/pkg/gnomod/gnomod.go @@ -163,6 +163,11 @@ func GnoToGoMod(f File) (*File, error) { return &f, nil } +func CreateGnoModFile(absDir, modPath string) error { + // TODO: implement + return nil +} + func isReplaced(mod module.Version, repl []*modfile.Replace) (module.Version, bool) { for _, r := range repl { hasNoVersion := r.Old.Path == mod.Path && r.Old.Version == "" From c8062013eaaf8d625aa15337d8cdb2f7fa6ddeb9 Mon Sep 17 00:00:00 2001 From: Hariom Verma Date: Sat, 8 Jul 2023 03:56:52 +0530 Subject: [PATCH 02/16] Implement `CreateGnoModFile()` --- gnovm/cmd/gno/mod.go | 2 +- gnovm/pkg/gnomod/file.go | 11 ++++---- gnovm/pkg/gnomod/gnomod.go | 57 ++++++++++++++++++++++++++++++++++++-- 3 files changed, 61 insertions(+), 9 deletions(-) diff --git a/gnovm/cmd/gno/mod.go b/gnovm/cmd/gno/mod.go index b854b3f251a..13dd0ef8b88 100644 --- a/gnovm/cmd/gno/mod.go +++ b/gnovm/cmd/gno/mod.go @@ -126,7 +126,7 @@ func execModDownload(cfg *modDownloadCfg, args []string, io *commands.IO) error } // write go.mod file - err = gomod.WriteToPath(path) + err = gomod.WriteToPath(filepath.Join(path, "go.mod")) if err != nil { return fmt.Errorf("write go.mod file: %w", err) } diff --git a/gnovm/pkg/gnomod/file.go b/gnovm/pkg/gnomod/file.go index 7f8879a35ed..18e16be1e76 100644 --- a/gnovm/pkg/gnomod/file.go +++ b/gnovm/pkg/gnomod/file.go @@ -110,7 +110,7 @@ func (f *File) FetchDeps(path string, remote string, verbose bool) error { if err != nil { return err } - err = goMod.WriteToPath(PackageDir(path, mod)) + err = goMod.WriteToPath(filepath.Join(PackageDir(path, mod), "go.mod")) if err != nil { return err } @@ -119,10 +119,10 @@ func (f *File) FetchDeps(path string, remote string, verbose bool) error { return nil } -// WriteToPath writes go.mod file in the given absolute path +// WriteToPath writes file to the given absolute file path // TODO: Find better way to do this. Try to use `modfile` // package to manage this. -func (f *File) WriteToPath(absPath string) error { +func (f *File) WriteToPath(absFilePath string) error { if f.Module == nil { return errors.New("writing go.mod: module not found") } @@ -150,10 +150,9 @@ func (f *File) WriteToPath(absPath string) error { data += ")\n" } - modPath := filepath.Join(absPath, "go.mod") - err := os.WriteFile(modPath, []byte(data), 0o644) + err := os.WriteFile(absFilePath, []byte(data), 0o644) if err != nil { - return fmt.Errorf("writefile %q: %w", modPath, err) + return fmt.Errorf("writefile %q: %w", absFilePath, err) } return nil diff --git a/gnovm/pkg/gnomod/gnomod.go b/gnovm/pkg/gnomod/gnomod.go index 6237ad55fa7..520cd6b25d8 100644 --- a/gnovm/pkg/gnomod/gnomod.go +++ b/gnovm/pkg/gnomod/gnomod.go @@ -1,7 +1,9 @@ package gnomod import ( + "errors" "fmt" + "io/ioutil" "os" "path/filepath" "strings" @@ -163,8 +165,59 @@ func GnoToGoMod(f File) (*File, error) { return &f, nil } -func CreateGnoModFile(absDir, modPath string) error { - // TODO: implement +func CreateGnoModFile(rootDir, modPath string) error { + if !filepath.IsAbs(rootDir) { + return fmt.Errorf("dir %q is not absolute", rootDir) + } + + modFilePath := filepath.Join(rootDir, "gno.mod") + if _, err := os.Stat(modFilePath); err == nil { + return errors.New("gno.mod file already exists") + } + + if modPath == "" { + // Check .gno files for package name + // and use it as modPath + files, err := ioutil.ReadDir(rootDir) + if err != nil { + fmt.Errorf("read dir %q: %w", rootDir, err) + } + + var pkgName gnolang.Name + for _, file := range files { + if file.IsDir() || !strings.HasSuffix(file.Name(), ".gno") || strings.HasSuffix(file.Name(), "_filetest.gno") { + continue + } + + fpath := filepath.Join(rootDir, file.Name()) + bz, err := os.ReadFile(fpath) + if err != nil { + return fmt.Errorf("read file %q: %w", fpath, err) + } + + pn := gnolang.PackageNameFromFileBody(file.Name(), string(bz)) + if strings.HasSuffix(string(pkgName), "_test") { + pkgName = pkgName[:len(pkgName)-len("_test")] + } + if pkgName == "" { + pkgName = pn + } + if pkgName != pn { + return fmt.Errorf("package name mismatch: [%q] and [%q]", pkgName, pn) + } + } + modPath = string(pkgName) + } + + modFile := &File{ + Module: &modfile.Module{ + Mod: module.Version{ + Path: modPath, + }, + }, + } + modFile.WriteToPath(filepath.Join(rootDir, "gno.mod")) + return nil } From d42924615805e0e12a60a747de59b902b32feb78 Mon Sep 17 00:00:00 2001 From: Hariom Verma Date: Sat, 8 Jul 2023 04:04:43 +0530 Subject: [PATCH 03/16] Todo: write tests --- gnovm/pkg/gnomod/gnomod_test.go | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 gnovm/pkg/gnomod/gnomod_test.go diff --git a/gnovm/pkg/gnomod/gnomod_test.go b/gnovm/pkg/gnomod/gnomod_test.go new file mode 100644 index 00000000000..4ac43e72773 --- /dev/null +++ b/gnovm/pkg/gnomod/gnomod_test.go @@ -0,0 +1,7 @@ +package gnomod + +import "testing" + +func TestCreateGnoModFile(t *testing.T) { + t.Skip("TODO") +} From a80d4a27167674bc0d5d9b5aac136f2cee166b38 Mon Sep 17 00:00:00 2001 From: Hariom Verma Date: Mon, 10 Jul 2023 18:52:18 +0530 Subject: [PATCH 04/16] fix: error if cannot determine package name --- gnovm/pkg/gnomod/gnomod.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/gnovm/pkg/gnomod/gnomod.go b/gnovm/pkg/gnomod/gnomod.go index 520cd6b25d8..0edf2f4c1f0 100644 --- a/gnovm/pkg/gnomod/gnomod.go +++ b/gnovm/pkg/gnomod/gnomod.go @@ -206,6 +206,9 @@ func CreateGnoModFile(rootDir, modPath string) error { return fmt.Errorf("package name mismatch: [%q] and [%q]", pkgName, pn) } } + if pkgName == "" { + return errors.New("cannot determine package name") + } modPath = string(pkgName) } From ac6410667db7815f00f53753fc8b0a7bced27e93 Mon Sep 17 00:00:00 2001 From: Hariom Verma Date: Mon, 10 Jul 2023 18:52:42 +0530 Subject: [PATCH 05/16] Add `gno mod init` tests --- gnovm/cmd/gno/mod_test.go | 67 ++++++++++++++++++++++++++++++++++++++- 1 file changed, 66 insertions(+), 1 deletion(-) diff --git a/gnovm/cmd/gno/mod_test.go b/gnovm/cmd/gno/mod_test.go index ecdc3d2516f..fdae3d12c7a 100644 --- a/gnovm/cmd/gno/mod_test.go +++ b/gnovm/cmd/gno/mod_test.go @@ -9,7 +9,7 @@ func TestModApp(t *testing.T) { errShouldBe: "flag: help requested", }, - // test gno.mod + // test gno.mod download { args: []string{"mod", "download"}, testDir: "../../tests/integ/empty-dir", @@ -72,6 +72,71 @@ func TestModApp(t *testing.T) { simulateExternalRepo: true, errShouldContain: "fetch: writepackage: querychain", }, + + // test gno.mod init with no module name + { + args: []string{"mod", "init"}, + testDir: "../../tests/integ/valid1", + simulateExternalRepo: true, + }, + { + args: []string{"mod", "init"}, + testDir: "../../tests/integ/empty-dir", + simulateExternalRepo: true, + errShouldBe: "create gno.mod file: cannot determine package name", + }, + { + args: []string{"mod", "init"}, + testDir: "../../tests/integ/empty-gno1", + simulateExternalRepo: true, + recoverShouldContain: "expected 'package', found 'EOF'", + }, + { + args: []string{"mod", "init"}, + testDir: "../../tests/integ/empty-gno2", + simulateExternalRepo: true, + recoverShouldContain: "expected 'package', found 'EOF'", + }, + { + args: []string{"mod", "init"}, + testDir: "../../tests/integ/empty-gno3", + simulateExternalRepo: true, + recoverShouldContain: "expected 'package', found 'EOF'", + }, + { + args: []string{"mod", "init"}, + testDir: "../../tests/integ/empty-gnomod", + simulateExternalRepo: true, + errShouldBe: "create gno.mod file: gno.mod file already exists", + }, + + // test gno.mod init with module name + { + args: []string{"mod", "init", "gno.land/p/demo/foo"}, + testDir: "../../tests/integ/empty-dir", + simulateExternalRepo: true, + }, + { + args: []string{"mod", "init", "gno.land/p/demo/foo"}, + testDir: "../../tests/integ/empty-gno1", + simulateExternalRepo: true, + }, + { + args: []string{"mod", "init", "gno.land/p/demo/foo"}, + testDir: "../../tests/integ/empty-gno2", + simulateExternalRepo: true, + }, + { + args: []string{"mod", "init", "gno.land/p/demo/foo"}, + testDir: "../../tests/integ/empty-gno3", + simulateExternalRepo: true, + }, + { + args: []string{"mod", "init", "gno.land/p/demo/foo"}, + testDir: "../../tests/integ/empty-gnomod", + simulateExternalRepo: true, + errShouldBe: "create gno.mod file: gno.mod file already exists", + }, } testMainCaseRun(t, tc) } From fd9cf8dcd7c8aca5cda530eb6e62424ae33c960f Mon Sep 17 00:00:00 2001 From: Hariom Verma Date: Mon, 10 Jul 2023 19:57:41 +0530 Subject: [PATCH 06/16] Test `CreateGnoModFile()` --- gnovm/pkg/gnomod/gnomod_test.go | 133 +++++++++++++++++++++++++++++++- 1 file changed, 131 insertions(+), 2 deletions(-) diff --git a/gnovm/pkg/gnomod/gnomod_test.go b/gnovm/pkg/gnomod/gnomod_test.go index 4ac43e72773..99c66955773 100644 --- a/gnovm/pkg/gnomod/gnomod_test.go +++ b/gnovm/pkg/gnomod/gnomod_test.go @@ -1,7 +1,136 @@ package gnomod -import "testing" +import ( + "os" + "path/filepath" + "testing" + + "github.com/gnolang/gno/tm2/pkg/testutils" + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" +) func TestCreateGnoModFile(t *testing.T) { - t.Skip("TODO") + for _, tc := range []struct { + desc string + in []struct{ filename, content string } + inModPath string + out string + errShouldContain string + }{ + { + desc: "empty directory", + inModPath: "gno.land/p/demo/foo", + out: "module gno.land/p/demo/foo\n", + }, + { + desc: "empty directory (without modPath)", + errShouldContain: "cannot determine package name", + }, + { + desc: "valid package", + in: []struct{ filename, content string }{ + { + "foo.gno", + `package foo`, + }, + }, + inModPath: "gno.land/p/demo/foo", + out: "module gno.land/p/demo/foo\n", + }, + { + desc: "valid package (without modPath)", + in: []struct{ filename, content string }{ + { + "foo.gno", + `package foo`, + }, + }, + out: "module foo\n", + }, + { + desc: "ambigious package names", + in: []struct{ filename, content string }{ + { + "foo.gno", + `package foo`, + }, + { + "bar.gno", + `package bar`, + }, + }, + inModPath: "gno.land/p/demo/foo", + out: "module gno.land/p/demo/foo\n", + }, + { + desc: "ambigious package names (without modPath)", + in: []struct{ filename, content string }{ + { + "foo.gno", + `package foo`, + }, + { + "bar.gno", + `package bar`, + }, + }, + errShouldContain: "package name mismatch:", + }, + { + desc: "valid package with gno.mod file", + in: []struct{ filename, content string }{ + { + "foo.gno", + `package foo`, + }, + { + "gno.mod", + `module gno.land/p/demo/foo`, + }, + }, + inModPath: "gno.land/p/demo/foo", + errShouldContain: "gno.mod file already exists", + }, + { + desc: "valid package with gno.mod file (without modPath)", + in: []struct{ filename, content string }{ + { + "foo.gno", + `package foo`, + }, + { + "gno.mod", + `module gno.land/p/demo/foo`, + }, + }, + errShouldContain: "gno.mod file already exists", + }, + } { + t.Run(tc.desc, func(t *testing.T) { + // Create test dir + dirPath, cleanUpFn := testutils.NewTestCaseDir(t) + require.NotNil(t, dirPath) + defer cleanUpFn() + + // Create files + for _, f := range tc.in { + err := os.WriteFile(filepath.Join(dirPath, f.filename), []byte(f.content), 0644) + require.NoError(t, err) + } + + err := CreateGnoModFile(dirPath, tc.inModPath) + if tc.errShouldContain != "" { + assert.Error(t, err) + assert.Contains(t, err.Error(), tc.errShouldContain) + return + } + assert.NoError(t, err) + + // Verify gno.mod file + bz, err := os.ReadFile(filepath.Join(dirPath, "gno.mod")) + assert.NoError(t, err) + assert.Equal(t, string(bz), tc.out) + }) + } } From 1dd6df8773fd410eac3a7e2fc88939fdd3dd2dcf Mon Sep 17 00:00:00 2001 From: Hariom Verma Date: Mon, 10 Jul 2023 20:01:53 +0530 Subject: [PATCH 07/16] Updated go-gno-compatibility.md --- gnovm/docs/go-gno-compatibility.md | 1 + 1 file changed, 1 insertion(+) diff --git a/gnovm/docs/go-gno-compatibility.md b/gnovm/docs/go-gno-compatibility.md index 1162c7285aa..6c6dbb63166 100644 --- a/gnovm/docs/go-gno-compatibility.md +++ b/gnovm/docs/go-gno-compatibility.md @@ -361,6 +361,7 @@ Additional native types: | go list | | | | go mod | | | | + go mod download | gno mod download | same behavior | +| + go mod init | gno mod init | same behavior | | | gno precompile | | | go work | | | | | gno repl | | From 6e942874bf485087c879dd2886091346893344f2 Mon Sep 17 00:00:00 2001 From: Hariom Verma Date: Mon, 10 Jul 2023 20:06:29 +0530 Subject: [PATCH 08/16] make fmt --- gnovm/pkg/gnomod/gnomod_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gnovm/pkg/gnomod/gnomod_test.go b/gnovm/pkg/gnomod/gnomod_test.go index 99c66955773..8df3b23b761 100644 --- a/gnovm/pkg/gnomod/gnomod_test.go +++ b/gnovm/pkg/gnomod/gnomod_test.go @@ -115,7 +115,7 @@ func TestCreateGnoModFile(t *testing.T) { // Create files for _, f := range tc.in { - err := os.WriteFile(filepath.Join(dirPath, f.filename), []byte(f.content), 0644) + err := os.WriteFile(filepath.Join(dirPath, f.filename), []byte(f.content), 0o644) require.NoError(t, err) } From b189d2ad85637437b008c05505ae28a3e65541f4 Mon Sep 17 00:00:00 2001 From: Hariom Verma Date: Tue, 11 Jul 2023 00:16:33 +0530 Subject: [PATCH 09/16] Split WriteToPath() args into multiple lines --- gnovm/pkg/gnomod/file.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/gnovm/pkg/gnomod/file.go b/gnovm/pkg/gnomod/file.go index 18e16be1e76..71d98b2d14b 100644 --- a/gnovm/pkg/gnomod/file.go +++ b/gnovm/pkg/gnomod/file.go @@ -110,7 +110,9 @@ func (f *File) FetchDeps(path string, remote string, verbose bool) error { if err != nil { return err } - err = goMod.WriteToPath(filepath.Join(PackageDir(path, mod), "go.mod")) + pkgPath := PackageDir(path, mod) + goModFilePath := filepath.Join(pkgPath, "go.mod") + err = goMod.WriteToPath(goModFilePath) if err != nil { return err } From 58f6ffa83d211acb9afa681f5d7cf1507280bdc3 Mon Sep 17 00:00:00 2001 From: Hariom Verma Date: Thu, 27 Jul 2023 20:58:13 +0530 Subject: [PATCH 10/16] fix: switch args `assert.Equal()` --- gnovm/pkg/gnomod/gnomod_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gnovm/pkg/gnomod/gnomod_test.go b/gnovm/pkg/gnomod/gnomod_test.go index 8df3b23b761..f4ec932823f 100644 --- a/gnovm/pkg/gnomod/gnomod_test.go +++ b/gnovm/pkg/gnomod/gnomod_test.go @@ -130,7 +130,7 @@ func TestCreateGnoModFile(t *testing.T) { // Verify gno.mod file bz, err := os.ReadFile(filepath.Join(dirPath, "gno.mod")) assert.NoError(t, err) - assert.Equal(t, string(bz), tc.out) + assert.Equal(t, tc.out, string(bz)) }) } } From 791996de6235538ed34680581c8c237bdcd438d3 Mon Sep 17 00:00:00 2001 From: Hariom Verma Date: Thu, 27 Jul 2023 21:02:06 +0530 Subject: [PATCH 11/16] Use `commands.NewEmptyConfig()` instead of `nil` --- gnovm/cmd/gno/mod.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gnovm/cmd/gno/mod.go b/gnovm/cmd/gno/mod.go index 13dd0ef8b88..09194232fec 100644 --- a/gnovm/cmd/gno/mod.go +++ b/gnovm/cmd/gno/mod.go @@ -59,7 +59,7 @@ func newModInitCmd() *commands.Command { ShortUsage: "init [module-path]", ShortHelp: "Initialize gno.mod file in current directory", }, - nil, + commands.NewEmptyConfig(), func(_ context.Context, args []string) error { return execModInit(args) }, From fa7fc5ae05809fbf9120ce8c377e2d2302129dbf Mon Sep 17 00:00:00 2001 From: Hariom Verma Date: Wed, 2 Aug 2023 02:59:52 +0800 Subject: [PATCH 12/16] fix: validate module path --- gnovm/pkg/gnomod/gnomod.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/gnovm/pkg/gnomod/gnomod.go b/gnovm/pkg/gnomod/gnomod.go index 0edf2f4c1f0..8d1ea7844bc 100644 --- a/gnovm/pkg/gnomod/gnomod.go +++ b/gnovm/pkg/gnomod/gnomod.go @@ -211,6 +211,9 @@ func CreateGnoModFile(rootDir, modPath string) error { } modPath = string(pkgName) } + if err := module.CheckPath(modPath); err != nil { + return err + } modFile := &File{ Module: &modfile.Module{ From 4286d3d25dfa05c589d3f2299f64e07947a0e1c9 Mon Sep 17 00:00:00 2001 From: Hariom Verma Date: Wed, 2 Aug 2023 03:12:59 +0800 Subject: [PATCH 13/16] Use less strict `CheckImportPath()` --- gnovm/pkg/gnomod/gnomod.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gnovm/pkg/gnomod/gnomod.go b/gnovm/pkg/gnomod/gnomod.go index 8d1ea7844bc..aa41c5aa00c 100644 --- a/gnovm/pkg/gnomod/gnomod.go +++ b/gnovm/pkg/gnomod/gnomod.go @@ -211,7 +211,7 @@ func CreateGnoModFile(rootDir, modPath string) error { } modPath = string(pkgName) } - if err := module.CheckPath(modPath); err != nil { + if err := module.CheckImportPath(modPath); err != nil { return err } From 7807a32b121b4613f8bde724790aac1474b609e3 Mon Sep 17 00:00:00 2001 From: Hariom Verma Date: Wed, 2 Aug 2023 03:13:17 +0800 Subject: [PATCH 14/16] Add test for invalid char in modPath --- gnovm/pkg/gnomod/gnomod_test.go | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/gnovm/pkg/gnomod/gnomod_test.go b/gnovm/pkg/gnomod/gnomod_test.go index f4ec932823f..fc483f75c97 100644 --- a/gnovm/pkg/gnomod/gnomod_test.go +++ b/gnovm/pkg/gnomod/gnomod_test.go @@ -27,6 +27,16 @@ func TestCreateGnoModFile(t *testing.T) { desc: "empty directory (without modPath)", errShouldContain: "cannot determine package name", }, + { + desc: "invalid modPath 1", + inModPath: " ", + errShouldContain: "malformed import path", + }, + { + desc: "invalid modPath 2", + inModPath: "\"", + errShouldContain: "malformed import path", + }, { desc: "valid package", in: []struct{ filename, content string }{ From efc2e5baea9877685b84b3b8d21e9bf5884e6a56 Mon Sep 17 00:00:00 2001 From: Hariom Verma Date: Wed, 2 Aug 2023 16:06:43 +0800 Subject: [PATCH 15/16] Parallelize TestCreateGnoModFile --- gnovm/pkg/gnomod/gnomod_test.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/gnovm/pkg/gnomod/gnomod_test.go b/gnovm/pkg/gnomod/gnomod_test.go index fc483f75c97..a8a0c993bea 100644 --- a/gnovm/pkg/gnomod/gnomod_test.go +++ b/gnovm/pkg/gnomod/gnomod_test.go @@ -117,7 +117,10 @@ func TestCreateGnoModFile(t *testing.T) { errShouldContain: "gno.mod file already exists", }, } { + tc := tc t.Run(tc.desc, func(t *testing.T) { + t.Parallel() + // Create test dir dirPath, cleanUpFn := testutils.NewTestCaseDir(t) require.NotNil(t, dirPath) From c1ef18bfec2a042ede61b54d63ec379da2f72eb8 Mon Sep 17 00:00:00 2001 From: Hariom Verma Date: Wed, 2 Aug 2023 16:13:21 +0800 Subject: [PATCH 16/16] fix lint --- gnovm/pkg/gnomod/gnomod_test.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/gnovm/pkg/gnomod/gnomod_test.go b/gnovm/pkg/gnomod/gnomod_test.go index a8a0c993bea..76c9a96c4e8 100644 --- a/gnovm/pkg/gnomod/gnomod_test.go +++ b/gnovm/pkg/gnomod/gnomod_test.go @@ -11,6 +11,8 @@ import ( ) func TestCreateGnoModFile(t *testing.T) { + t.Parallel() + for _, tc := range []struct { desc string in []struct{ filename, content string }