From d51dabf6bc34d700251536a5e943a85a0339bc58 Mon Sep 17 00:00:00 2001 From: shantuo Date: Fri, 21 Sep 2018 13:25:33 -0700 Subject: [PATCH] wire: make Vendor test work with Go module (#469) --- wire/internal/wire/testdata/Vendor/bar/dummy.go | 16 ---------------- .../{foo => }/vendor/example.com/bar/bar.go | 0 wire/internal/wire/wire_test.go | 10 +++++----- 3 files changed, 5 insertions(+), 21 deletions(-) delete mode 100644 wire/internal/wire/testdata/Vendor/bar/dummy.go rename wire/internal/wire/testdata/Vendor/{foo => }/vendor/example.com/bar/bar.go (100%) diff --git a/wire/internal/wire/testdata/Vendor/bar/dummy.go b/wire/internal/wire/testdata/Vendor/bar/dummy.go deleted file mode 100644 index 2e693b3a70..0000000000 --- a/wire/internal/wire/testdata/Vendor/bar/dummy.go +++ /dev/null @@ -1,16 +0,0 @@ -// Copyright 2018 The Go Cloud Authors -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// https://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -// Package bar is left intentionally blank. -package bar diff --git a/wire/internal/wire/testdata/Vendor/foo/vendor/example.com/bar/bar.go b/wire/internal/wire/testdata/Vendor/vendor/example.com/bar/bar.go similarity index 100% rename from wire/internal/wire/testdata/Vendor/foo/vendor/example.com/bar/bar.go rename to wire/internal/wire/testdata/Vendor/vendor/example.com/bar/bar.go diff --git a/wire/internal/wire/wire_test.go b/wire/internal/wire/wire_test.go index bf8a01b3dc..78f333dcfa 100644 --- a/wire/internal/wire/wire_test.go +++ b/wire/internal/wire/wire_test.go @@ -72,10 +72,6 @@ func TestWire(t *testing.T) { for _, test := range tests { test := test t.Run(test.name, func(t *testing.T) { - if test.name == "Vendor" && os.Getenv("GO111MODULE") != "off" { - // TODO: Remove the GO111MODULE check when it is not relevant (maybe after Go 1.12). - t.Skip("Skipped testing for vendored package for Go module turned on, see https://github.com/google/go-cloud/issues/326") - } t.Parallel() // Run Wire from a fake build context. @@ -167,7 +163,11 @@ func goBuildCheck(test *testCase, wd string, bctx *build.Context, gen []byte) er ReleaseTags: bctx.ReleaseTags, } buildDir := filepath.Join(gopath, "src", genPkg.ImportPath) - if err := runGo(realBuildCtx, buildDir, "build", "-o", testExePath); err != nil { + buildCmd := []string{"build", "-o", testExePath} + if test.name == "Vendor" && os.Getenv("GO111MODULE") == "on" { + buildCmd = append(buildCmd, "-mod=vendor") + } + if err := runGo(realBuildCtx, buildDir, buildCmd...); err != nil { return fmt.Errorf("build: %v", err) }