Skip to content

Commit d352d2d

Browse files
committed
x/exp/cmd/gorelease: add test for tidy submodule
Details: - Adds a test for the missing req submodule case. However, it turns out we don't need any code in the filepath.Walk to handle submodules, since earlier in copyModuleToTempDir we only copy the module's contents (not any submodule contents) with zip.CreateFromDir. This means that prepareLoadDir is never going to consider any submodule content, and we don't have to build logic for that. The test will maintain that guarantee. - Remove some extraneous go.mod dupes from other tests. - Remove a TODO related to filepath.Walk submodule checking which is no longer needed. Fixes golang/go#41456 Change-Id: Ib0bac2fb227d4175c31603880b629374991b8bde Reviewed-on: https://go-review.googlesource.com/c/exp/+/287972 Run-TryBot: Jean de Klerk <[email protected]> TryBot-Result: Go Bot <[email protected]> Trust: Jean de Klerk <[email protected]> Reviewed-by: Jay Conrod <[email protected]>
1 parent 8498777 commit d352d2d

File tree

4 files changed

+19
-11
lines changed

4 files changed

+19
-11
lines changed

cmd/gorelease/gorelease.go

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1085,9 +1085,6 @@ func prepareLoadDir(modFile *modfile.File, modPath, modRoot, version string, cac
10851085
// of the modPath module).
10861086
//
10871087
// Note: the returned importPaths will include main if it exists in root.
1088-
//
1089-
// TODO(deklerk): Stop at any discovered submodule. Make sure a test exists that
1090-
// asserts that behavior.
10911088
func collectImportPaths(modPath, root string) (importPaths []string, _ error) {
10921089
err := filepath.Walk(root, func(walkPath string, fi os.FileInfo, err error) error {
10931090
if err != nil {

cmd/gorelease/testdata/tidy/missing_req_nested.test

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,6 @@ Run 'go mod tidy' to add missing requirements.
1313
-- go.mod --
1414
module example.com/tidy
1515

16-
go 1.12
17-
-- go.mod --
18-
module example.com/tidy
19-
2016
go 1.12
2117
-- tidy.go --
2218
package tidy
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
mod=example.com/tidy
2+
base=v0.0.1
3+
success=true
4+
-- want --
5+
Suggested version: v0.0.2
6+
-- go.mod --
7+
module example.com/tidy
8+
9+
go 1.12
10+
-- foo/go.mod --
11+
module example.com/tidy/foo
12+
13+
go 1.12
14+
-- tidy.go --
15+
package tidy
16+
-- foo/tidy.go --
17+
package subpkg
18+
19+
import _ "example.com/basic/a"

cmd/gorelease/testdata/tidy/missing_req_twice_nested.test

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,6 @@ Run 'go mod tidy' to add missing requirements.
1313
-- go.mod --
1414
module example.com/tidy
1515

16-
go 1.12
17-
-- go.mod --
18-
module example.com/tidy
19-
2016
go 1.12
2117
-- tidy.go --
2218
package tidy

0 commit comments

Comments
 (0)