command: Use vendoring when building helper programs in tests

In a couple places in tests we execute a child "go build" to make a helper
program. Now that we're running in module mode, "go build" will normally
default to downloading and caching dependencies, which we don't want
because we're still using vendoring for the moment.

Therefore we need to instruct these child builds to use vendoring too,
avoiding the need to download all of the dependencies and ensuring that
we'll be building with the same dependencies that we'd use for a normal
build.
This commit is contained in:
Martin Atkins 2018-11-19 11:15:58 -08:00
parent 5b676059a4
commit 884aa387b8
2 changed files with 2 additions and 1 deletions

View File

@ -798,7 +798,7 @@ func testLockState(sourceDir, path string) (func(), error) {
source := filepath.Join(sourceDir, "statelocker.go")
lockBin := filepath.Join(buildDir, "statelocker")
out, err := exec.Command("go", "build", "-o", lockBin, source).CombinedOutput()
out, err := exec.Command("go", "build", "-mod=vendor", "-o", lockBin, source).CombinedOutput()
if err != nil {
cleanFunc()
return nil, fmt.Errorf("%s %s", err, out)

View File

@ -236,6 +236,7 @@ func GoBuild(pkgPath, tmpPrefix string) string {
cmd := exec.Command(
"go", "build",
"-mod=vendor",
"-o", tmpFilename,
pkgPath,
)