Skip to content

Commit

Permalink
.travis.yml, tests: Update for GO111MODULE=on [ci-skip]
Browse files Browse the repository at this point in the history
I've flagged this as "[ci-skip]" becausee it finds a legitimate
regression; hold off on fixing that for another commit.
  • Loading branch information
LukeShu committed Jun 29, 2019
1 parent ff068b1 commit f4fbc7c
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 3 deletions.
6 changes: 6 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,16 @@ matrix:
- go: "1.10"
- go: "1.11"
env: {GO111MODULE: "off"}
- go: "1.11"
env: {GO111MODULE: "on"}
- go: "1.12"
env: {GO111MODULE: "off"}
- go: "1.12"
env: {GO111MODULE: "on"}
- go: "tip"
env: {GO111MODULE: "off"}
- go: "tip"
env: {GO111MODULE: "on"}

install: |
if test -z "$(go env GOMOD)"; then
Expand Down
28 changes: 25 additions & 3 deletions internal/errcheck/errcheck_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,9 @@ package custom
os.RemoveAll(tmpGopath)
}()

if err := ioutil.WriteFile(path.Join(testBuildTagsDir, "go.mod"), []byte("module github.com/testbuildtags"), 0644); err != nil {
t.Fatalf("Failed to write testbuildtags go.mod: %v", err)
}
if err := ioutil.WriteFile(path.Join(testBuildTagsDir, "custom1.go"), []byte(testBuildCustom1Tag), 0644); err != nil {
t.Fatalf("Failed to write testbuildtags custom1: %v", err)
}
Expand Down Expand Up @@ -167,7 +170,8 @@ package custom
checker.Tags = currCase.tags

loadPackages = func(cfg *packages.Config, paths ...string) ([]*packages.Package, error) {
cfg.Env = append(os.Environ(), "GOPATH="+tmpGopath)
cfg.Env = append(os.Environ(),
"GOPATH="+tmpGopath)
cfg.Dir = testBuildTagsDir
pkgs, err := packages.Load(cfg, paths...)
return pkgs, err
Expand Down Expand Up @@ -198,6 +202,10 @@ func TestWhitelist(t *testing.T) {
}

func TestIgnore(t *testing.T) {
const testVendorGoMod = `module github.com/testvendor
require github.com/testlog v0.0.0
`
const testVendorMain = `
package main
Expand Down Expand Up @@ -227,6 +235,9 @@ func TestIgnore(t *testing.T) {
os.RemoveAll(tmpGopath)
}()

if err := ioutil.WriteFile(path.Join(testVendorDir, "go.mod"), []byte(testVendorGoMod), 0755); err != nil {
t.Fatalf("Failed to write testvendor go.mod: %v", err)
}
if err := ioutil.WriteFile(path.Join(testVendorDir, "main.go"), []byte(testVendorMain), 0755); err != nil {
t.Fatalf("Failed to write testvendor main: %v", err)
}
Expand Down Expand Up @@ -264,7 +275,9 @@ func TestIgnore(t *testing.T) {
checker := NewChecker()
checker.Ignore = currCase.ignore
loadPackages = func(cfg *packages.Config, paths ...string) ([]*packages.Package, error) {
cfg.Env = append(os.Environ(), "GOPATH="+tmpGopath)
cfg.Env = append(os.Environ(),
"GOPATH="+tmpGopath,
"GOFLAGS=-mod=vendor")
cfg.Dir = testVendorDir
pkgs, err := packages.Load(cfg, paths...)
return pkgs, err
Expand All @@ -291,6 +304,10 @@ func TestIgnore(t *testing.T) {
}

func TestWithoutGeneratedCode(t *testing.T) {
const testVendorGoMod = `module github.com/testvendor
require github.com/testlog v0.0.0
`
const testVendorMain = `
// Code generated by protoc-gen-go. DO NOT EDIT.
package main
Expand Down Expand Up @@ -321,6 +338,9 @@ func TestWithoutGeneratedCode(t *testing.T) {
os.RemoveAll(tmpGopath)
}()

if err := ioutil.WriteFile(path.Join(testVendorDir, "go.mod"), []byte(testVendorGoMod), 0755); err != nil {
t.Fatalf("Failed to write testvendor go.mod: %v", err)
}
if err := ioutil.WriteFile(path.Join(testVendorDir, "main.go"), []byte(testVendorMain), 0755); err != nil {
t.Fatalf("Failed to write testvendor main: %v", err)
}
Expand Down Expand Up @@ -351,7 +371,9 @@ func TestWithoutGeneratedCode(t *testing.T) {
checker := NewChecker()
checker.WithoutGeneratedCode = currCase.withoutGeneratedCode
loadPackages = func(cfg *packages.Config, paths ...string) ([]*packages.Package, error) {
cfg.Env = append(os.Environ(), "GOPATH="+tmpGopath)
cfg.Env = append(os.Environ(),
"GOPATH="+tmpGopath,
"GOFLAGS=-mod=vendor")
cfg.Dir = testVendorDir
pkgs, err := packages.Load(cfg, paths...)
return pkgs, err
Expand Down

0 comments on commit f4fbc7c

Please sign in to comment.