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,11 +524,16 @@ func setup(t *testing.T, main, wd string) *modTest {
|
||||||
WorkingDir: filepath.Join(mainDir, wd),
|
WorkingDir: filepath.Join(mainDir, wd),
|
||||||
}
|
}
|
||||||
|
|
||||||
// go mod tidy instead of download because tidy will notice dependencies
|
// go mod download gets mad if we don't have a go.mod, so make sure we do.
|
||||||
// in code, not just in go.mod files.
|
_, 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 {
|
if _, err := env.invokeGo("mod", "download"); err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return &modTest{
|
return &modTest{
|
||||||
T: t,
|
T: t,
|
||||||
|
|
Loading…
Reference in New Issue