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 <deklerk@google.com> TryBot-Result: Go Bot <gobot@golang.org> Trust: Jean de Klerk <deklerk@google.com> Reviewed-by: Jay Conrod <jayconrod@google.com>
diff --git a/cmd/gorelease/gorelease.go b/cmd/gorelease/gorelease.go index 10860bd..3e09351 100644 --- a/cmd/gorelease/gorelease.go +++ b/cmd/gorelease/gorelease.go
@@ -1085,9 +1085,6 @@ // of the modPath module). // // Note: the returned importPaths will include main if it exists in root. -// -// TODO(deklerk): Stop at any discovered submodule. Make sure a test exists that -// asserts that behavior. func collectImportPaths(modPath, root string) (importPaths []string, _ error) { err := filepath.Walk(root, func(walkPath string, fi os.FileInfo, err error) error { if err != nil {
diff --git a/cmd/gorelease/testdata/tidy/missing_req_nested.test b/cmd/gorelease/testdata/tidy/missing_req_nested.test index 57e3ff9..75ca2bd 100644 --- a/cmd/gorelease/testdata/tidy/missing_req_nested.test +++ b/cmd/gorelease/testdata/tidy/missing_req_nested.test
@@ -14,10 +14,6 @@ module example.com/tidy go 1.12 --- go.mod -- -module example.com/tidy - -go 1.12 -- tidy.go -- package tidy -- subdir/tidy.go --
diff --git a/cmd/gorelease/testdata/tidy/missing_req_submodule.test b/cmd/gorelease/testdata/tidy/missing_req_submodule.test new file mode 100644 index 0000000..d864d26 --- /dev/null +++ b/cmd/gorelease/testdata/tidy/missing_req_submodule.test
@@ -0,0 +1,19 @@ +mod=example.com/tidy +base=v0.0.1 +success=true +-- want -- +Suggested version: v0.0.2 +-- go.mod -- +module example.com/tidy + +go 1.12 +-- foo/go.mod -- +module example.com/tidy/foo + +go 1.12 +-- tidy.go -- +package tidy +-- foo/tidy.go -- +package subpkg + +import _ "example.com/basic/a"
diff --git a/cmd/gorelease/testdata/tidy/missing_req_twice_nested.test b/cmd/gorelease/testdata/tidy/missing_req_twice_nested.test index ab0dd9c..006c242 100644 --- a/cmd/gorelease/testdata/tidy/missing_req_twice_nested.test +++ b/cmd/gorelease/testdata/tidy/missing_req_twice_nested.test
@@ -14,10 +14,6 @@ module example.com/tidy go 1.12 --- go.mod -- -module example.com/tidy - -go 1.12 -- tidy.go -- package tidy -- subdir/subsubdir/tidy.go --