Skip to content

Commit 9ce3372

Browse files
committed
Makefile: Set GO111MODULE=on for consistency, adjust tests accordingly
1 parent b51d53e commit 9ce3372

31 files changed

+1524
-20
lines changed

.travis.yml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,6 @@ go:
44
- 1.11.x
55
- 1.12.x
66

7-
before_script:
8-
- go get github.com/valyala/quicktemplate
9-
107
script: make check_generated test
118

129
after_success:

Makefile

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
export GO111MODULE = on
2+
13
test: build
24
GL_TEST_RUN=1 ./golangci-lint run -v
35
GL_TEST_RUN=1 ./golangci-lint run --fast --no-config -v --skip-dirs 'test/testdata_etc,pkg/golinters/goanalysis/(checker|passes)'
@@ -32,9 +34,9 @@ release:
3234
curl -sL https://git.io/goreleaser | bash
3335

3436
update_deps:
35-
GO111MODULE=on go mod verify
36-
GO111MODULE=on go mod tidy
37+
go mod verify
38+
go mod tidy
3739
rm -rf vendor
38-
GO111MODULE=on go mod vendor
40+
go mod vendor
3941

4042
.PHONY: test

go.mod

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ require (
4949
github.com/spf13/pflag v1.0.1
5050
github.com/spf13/viper v1.0.2
5151
github.com/stretchr/testify v1.2.2
52+
github.com/valyala/quicktemplate v1.1.1
5253
golang.org/x/crypto v0.0.0-20190313024323-a1f597ede03a // indirect
5354
golang.org/x/net v0.0.0-20190313220215-9f648a60d977 // indirect
5455
golang.org/x/sys v0.0.0-20190312061237-fead79001313 // indirect

go.sum

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,10 @@ github.com/inconshreveable/mousetrap v1.0.0/go.mod h1:PxqpIevigyE2G7u3NXJIT2ANyt
8686
github.com/kisielk/gotool v0.0.0-20161130080628-0de1eaf82fa3/go.mod h1:jxZFDH7ILpTPQTk+E2s+z4CUas9lVNjIuKR4c5/zKgM=
8787
github.com/kisielk/gotool v1.0.0 h1:AV2c/EiW3KqPNT9ZKl07ehoAGi4C5/01Cfbblndcapg=
8888
github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck=
89+
github.com/klauspost/compress v1.4.0/go.mod h1:RyIbtBH6LamlWaDj8nUwkbUhJ87Yi3uG0guNDohfE1A=
90+
github.com/klauspost/compress v1.4.1/go.mod h1:RyIbtBH6LamlWaDj8nUwkbUhJ87Yi3uG0guNDohfE1A=
91+
github.com/klauspost/cpuid v0.0.0-20180405133222-e7e905edc00e/go.mod h1:Pj4uuM528wm8OyEC2QMXAi2YiTZ96dNQPGgoMS4s3ek=
92+
github.com/klauspost/cpuid v1.2.0/go.mod h1:Pj4uuM528wm8OyEC2QMXAi2YiTZ96dNQPGgoMS4s3ek=
8993
github.com/kr/pretty v0.1.0 h1:L/CwN0zerZDmRFUapSPitk6f+Q3+0za1rQkzVuMiMFI=
9094
github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo=
9195
github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
@@ -150,12 +154,19 @@ github.com/spf13/viper v1.0.2 h1:Ncr3ZIuJn322w2k1qmzXDnkLAdQMlJqBa9kfAH+irso=
150154
github.com/spf13/viper v1.0.2/go.mod h1:A8kyI5cUJhb8N+3pkfONlcEcZbueH6nhAm0Fq7SrnBM=
151155
github.com/stretchr/testify v1.2.2 h1:bSDNvY7ZPG5RlJ8otE/7V6gMiyenm9RtJ7IUVIAoJ1w=
152156
github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
157+
github.com/valyala/bytebufferpool v1.0.0 h1:GqA5TC/0021Y/b9FG4Oi9Mr3q7XYx6KllzawFIhcdPw=
158+
github.com/valyala/bytebufferpool v1.0.0/go.mod h1:6bBcMArwyJ5K/AmCkWv1jt77kVWyCJ6HpOuEn7z0Csc=
159+
github.com/valyala/fasthttp v1.2.0/go.mod h1:4vX61m6KN+xDduDNwXrhIAVZaZaZiQ1luJk8LWSxF3s=
160+
github.com/valyala/quicktemplate v1.1.1 h1:C58y/wN0FMTi2PR0n3onltemfFabany53j7M6SDDB8k=
161+
github.com/valyala/quicktemplate v1.1.1/go.mod h1:EH+4AkTd43SvgIbQHYu59/cJyxDoOVRUAfrukLPuGJ4=
162+
github.com/valyala/tcplisten v0.0.0-20161114210144-ceec8f93295a/go.mod h1:v3UYOV9WzVtRmSR+PDvWpU/qWl4Wa5LApYYX4ZtKbio=
153163
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
154164
golang.org/x/crypto v0.0.0-20190313024323-a1f597ede03a h1:YX8ljsm6wXlHZO+aRz9Exqr0evNhKRNe5K/gi+zKh4U=
155165
golang.org/x/crypto v0.0.0-20190313024323-a1f597ede03a/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
156166
golang.org/x/net v0.0.0-20170915142106-8351a756f30f/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
157167
golang.org/x/net v0.0.0-20180906233101-161cd47e91fd h1:nTDtHvHSdCn1m6ITfMRqtOd/9+7a3s8RBNOZ3eYZzJA=
158168
golang.org/x/net v0.0.0-20180906233101-161cd47e91fd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
169+
golang.org/x/net v0.0.0-20180911220305-26e67e76b6c3/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
159170
golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
160171
golang.org/x/net v0.0.0-20190313220215-9f648a60d977 h1:actzWV6iWn3GLqN8dZjzsB+CLt+gaV2+wsxroxiQI8I=
161172
golang.org/x/net v0.0.0-20190313220215-9f648a60d977/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=

scripts/gen_readme/main.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,18 +53,18 @@ func buildTemplateContext() (map[string]interface{}, error) {
5353
return nil, fmt.Errorf("can't read .golangci.example.yml: %s", err)
5454
}
5555

56-
if err = exec.Command("go", "install", "./cmd/...").Run(); err != nil {
56+
if err = exec.Command("make", "build").Run(); err != nil {
5757
return nil, fmt.Errorf("can't run go install: %s", err)
5858
}
5959

60-
lintersOut, err := exec.Command("golangci-lint", "help", "linters").Output()
60+
lintersOut, err := exec.Command("./golangci-lint", "help", "linters").Output()
6161
if err != nil {
6262
return nil, fmt.Errorf("can't run linters cmd: %s", err)
6363
}
6464

6565
lintersOutParts := bytes.Split(lintersOut, []byte("\n\n"))
6666

67-
helpCmd := exec.Command("golangci-lint", "run", "-h")
67+
helpCmd := exec.Command("./golangci-lint", "run", "-h")
6868
helpCmd.Env = append(helpCmd.Env, os.Environ()...)
6969
helpCmd.Env = append(helpCmd.Env, "HELP_RUN=1") // make default concurrency stable: don't depend on machine CPU number
7070
help, err := helpCmd.Output()

test/data.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ package test
33
import "path/filepath"
44

55
const testdataDir = "testdata"
6-
const binName = "golangci-lint"
6+
const binName = "../golangci-lint"
77

88
func getProjectRoot() string {
99
return filepath.Join("..", "...")

test/run_test.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ import (
1010
"github.com/golangci/golangci-lint/test/testshared"
1111

1212
"github.com/golangci/golangci-lint/pkg/exitcodes"
13+
14+
_ "github.com/valyala/quicktemplate"
1315
)
1416

1517
func getCommonRunArgs() []string {
@@ -25,13 +27,13 @@ func TestAutogeneratedNoIssues(t *testing.T) {
2527
}
2628

2729
func TestEmptyDirRun(t *testing.T) {
28-
testshared.NewLintRunner(t).Run(getTestDataDir("nogofiles")).
30+
testshared.NewLintRunner(t, "GO111MODULE=off").Run(getTestDataDir("nogofiles")).
2931
ExpectExitCode(exitcodes.NoGoFiles).
3032
ExpectOutputContains(": no go files to analyze")
3133
}
3234

3335
func TestNotExistingDirRun(t *testing.T) {
34-
testshared.NewLintRunner(t).Run(getTestDataDir("no_such_dir")).
36+
testshared.NewLintRunner(t, "GO111MODULE=off").Run(getTestDataDir("no_such_dir")).
3537
ExpectExitCode(exitcodes.Failure).
3638
ExpectOutputContains(`cannot find package \"./testdata/no_such_dir\"`)
3739
}

test/testshared/testshared.go

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import (
44
"io/ioutil"
55
"os"
66
"os/exec"
7-
"path/filepath"
87
"strings"
98
"syscall"
109

@@ -17,27 +16,26 @@ import (
1716
type LintRunner struct {
1817
t assert.TestingT
1918
log logutils.Log
20-
21-
installed bool
19+
env []string
2220
}
2321

24-
func NewLintRunner(t assert.TestingT) *LintRunner {
22+
func NewLintRunner(t assert.TestingT, environ ...string) *LintRunner {
2523
log := logutils.NewStderrLog("test")
2624
log.SetLevel(logutils.LogLevelInfo)
2725
return &LintRunner{
2826
t: t,
2927
log: log,
28+
env: environ,
3029
}
3130
}
3231

3332
func (r *LintRunner) Install() {
34-
if r.installed {
33+
if _, err := os.Stat("../golangci-lint"); err == nil {
3534
return
3635
}
3736

38-
cmd := exec.Command("go", "install", filepath.Join("..", "cmd", "golangci-lint"))
37+
cmd := exec.Command("make", "-C", "..", "build")
3938
assert.NoError(r.t, cmd.Run(), "Can't go install golangci-lint")
40-
r.installed = true
4139
}
4240

4341
type RunResult struct {
@@ -82,7 +80,8 @@ func (r *LintRunner) Run(args ...string) *RunResult {
8280

8381
runArgs := append([]string{"run"}, args...)
8482
r.log.Infof("golangci-lint %s", strings.Join(runArgs, " "))
85-
cmd := exec.Command("golangci-lint", runArgs...)
83+
cmd := exec.Command("../golangci-lint", runArgs...)
84+
cmd.Env = append(os.Environ(), r.env...)
8685
out, err := cmd.CombinedOutput()
8786
if err != nil {
8887
if exitError, ok := err.(*exec.ExitError); ok {

vendor/github.com/valyala/bytebufferpool/.travis.yml

Lines changed: 15 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

vendor/github.com/valyala/bytebufferpool/LICENSE

Lines changed: 22 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

vendor/github.com/valyala/bytebufferpool/README.md

Lines changed: 21 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

vendor/github.com/valyala/bytebufferpool/bytebuffer.go

Lines changed: 111 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

vendor/github.com/valyala/bytebufferpool/doc.go

Lines changed: 7 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)