wire: make Vendor test work with Go module (google/go-cloud#469)

This commit is contained in:
shantuo
2018-09-21 13:25:33 -07:00
committed by Ross Light
parent a8c7c0b8e1
commit fbcb6a82cb
3 changed files with 5 additions and 21 deletions

View File

@@ -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

View File

@@ -72,10 +72,6 @@ func TestWire(t *testing.T) {
for _, test := range tests { for _, test := range tests {
test := test test := test
t.Run(test.name, func(t *testing.T) { 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() t.Parallel()
// Run Wire from a fake build context. // 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, ReleaseTags: bctx.ReleaseTags,
} }
buildDir := filepath.Join(gopath, "src", genPkg.ImportPath) 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) return fmt.Errorf("build: %v", err)
} }