mirror of
https://github.com/golang/go
synced 2024-11-18 16:44:43 -07:00
internal/imports: fix TestNoMainModule
https://golang.org/cl/179998 made it an error to run go mod download without args and without a go.mod. Don't do that. Fixes golang/go#32488 Change-Id: Icd845feb8fecae69b6a8363438bb9ee546a310dc Reviewed-on: https://go-review.googlesource.com/c/tools/+/181298 Run-TryBot: Heschi Kreinick <heschi@google.com> Reviewed-by: Jay Conrod <jayconrod@google.com> TryBot-Result: Gobot Gobot <gobot@golang.org>
This commit is contained in:
parent
68211a626c
commit
755ce86c76
@ -524,10 +524,15 @@ func setup(t *testing.T, main, wd string) *modTest {
|
||||
WorkingDir: filepath.Join(mainDir, wd),
|
||||
}
|
||||
|
||||
// go mod tidy instead of download because tidy will notice dependencies
|
||||
// in code, not just in go.mod files.
|
||||
if _, err := env.invokeGo("mod", "download"); err != nil {
|
||||
t.Fatal(err)
|
||||
// go mod download gets mad if we don't have a go.mod, so make sure we do.
|
||||
_, err = os.Stat(filepath.Join(mainDir, "go.mod"))
|
||||
if err != nil && !os.IsNotExist(err) {
|
||||
t.Fatalf("checking if go.mod exists: %v", err)
|
||||
}
|
||||
if err == nil {
|
||||
if _, err := env.invokeGo("mod", "download"); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
}
|
||||
|
||||
return &modTest{
|
||||
|
Loading…
Reference in New Issue
Block a user