mirror of
https://github.com/golang/go
synced 2024-11-18 18:04:46 -07:00
go/packages: remove go.mod files
Files named go.mod define a module boundary and punch a hole in the repository when the module is fetched with go get. We had a couple in testdata. Get rid of them. In one case the changes I made to produce a module cache in packagestest were enough. In the other, the test needs multiple minor/patch versions of the same module, which we have no provision for. Rename them to "definitelynot_go.mod" in the repo and fix it up in the test. Updates golang/go#34352 Change-Id: I284578b3aebb0f1fec3ddb4bef0df24f050d0636 Reviewed-on: https://go-review.googlesource.com/c/tools/+/196258 Run-TryBot: Heschi Kreinick <heschi@google.com> Reviewed-by: Ian Cottrell <iancottrell@google.com>
This commit is contained in:
parent
9098376d50
commit
68f92b6635
@ -1543,41 +1543,37 @@ func testName(t *testing.T, exporter packagestest.Exporter) {
|
||||
|
||||
func TestName_Modules(t *testing.T) {
|
||||
// Test the top-level package case described in runNamedQueries.
|
||||
// Note that overriding GOPATH below prevents Export from
|
||||
// creating more than one module.
|
||||
exported := packagestest.Export(t, packagestest.Modules, []packagestest.Module{{
|
||||
Name: "golang.org/pkg",
|
||||
Files: map[string]interface{}{
|
||||
"pkg.go": `package pkg`,
|
||||
}}})
|
||||
exported := packagestest.Export(t, packagestest.Modules, []packagestest.Module{
|
||||
{
|
||||
Name: "golang.org/pkg",
|
||||
Files: map[string]interface{}{
|
||||
"pkg.go": `package pkg`,
|
||||
},
|
||||
},
|
||||
{
|
||||
Name: "example.com/tools-testrepo",
|
||||
Files: map[string]interface{}{
|
||||
"pkg/pkg.go": `package pkg`,
|
||||
},
|
||||
},
|
||||
{
|
||||
Name: "example.com/tools-testrepo/v2",
|
||||
Files: map[string]interface{}{
|
||||
"pkg/pkg.go": `package pkg`,
|
||||
},
|
||||
},
|
||||
})
|
||||
defer exported.Cleanup()
|
||||
|
||||
wd, err := os.Getwd()
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
gopath, err := ioutil.TempDir("", "TestName_Modules")
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
defer os.RemoveAll(gopath)
|
||||
if err := copyAll(filepath.Join(wd, "testdata", "TestName_Modules"), gopath); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
// testdata/TestNamed_Modules contains:
|
||||
// - pkg/mod/github.com/heschik/tools-testrepo@v1.0.0/pkg
|
||||
// - pkg/mod/github.com/heschik/tools-testrepo/v2@v2.0.0/pkg
|
||||
// - src/b/pkg
|
||||
exported.Config.Mode = packages.LoadImports
|
||||
exported.Config.Env = append(exported.Config.Env, "GOPATH="+gopath)
|
||||
initial, err := packages.Load(exported.Config, "iamashamedtousethedisabledqueryname=pkg")
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
graph, _ := importGraph(initial)
|
||||
wantGraph := `
|
||||
* github.com/heschik/tools-testrepo/pkg
|
||||
* github.com/heschik/tools-testrepo/v2/pkg
|
||||
* example.com/tools-testrepo/pkg
|
||||
* example.com/tools-testrepo/v2/pkg
|
||||
* golang.org/pkg
|
||||
`[1:]
|
||||
if graph != wantGraph {
|
||||
@ -2504,7 +2500,7 @@ func copyAll(srcPath, dstPath string) error {
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
dstFilePath := filepath.Join(dstPath, rel)
|
||||
dstFilePath := strings.Replace(filepath.Join(dstPath, rel), "definitelynot_go.mod", "go.mod", -1)
|
||||
if err := os.MkdirAll(filepath.Dir(dstFilePath), 0755); err != nil {
|
||||
return err
|
||||
}
|
||||
|
@ -1 +0,0 @@
|
||||
v1.0.0
|
@ -1 +0,0 @@
|
||||
{"Version":"v1.0.0","Time":"2018-09-28T22:09:08Z"}
|
@ -1 +0,0 @@
|
||||
module github.com/heschik/tools-testrepo
|
Binary file not shown.
@ -1 +0,0 @@
|
||||
h1:D2qc+R2eCTCyoT8WAYoExXhPBThJWmlYSfB4coWbfBE=
|
@ -1 +0,0 @@
|
||||
v2.0.0
|
@ -1 +0,0 @@
|
||||
{"Version":"v2.0.0","Time":"2018-09-28T22:12:08Z"}
|
@ -1 +0,0 @@
|
||||
module github.com/heschik/tools-testrepo/v2
|
Binary file not shown.
@ -1 +0,0 @@
|
||||
h1:Ll4Bx8ZD8zg8lD4idX7CAhx/jh16o9dWC2m9SnT1qu0=
|
@ -1 +0,0 @@
|
||||
package pkg
|
@ -1 +0,0 @@
|
||||
package pkg
|
@ -1 +0,0 @@
|
||||
package pkg
|
@ -1,3 +0,0 @@
|
||||
module github.com/heschik/tools-testrepo/v2
|
||||
|
||||
go 1.12
|
@ -1,3 +0,0 @@
|
||||
module github.com/heschik/tools-testrepo
|
||||
|
||||
go 1.12
|
Loading…
Reference in New Issue
Block a user