Skip to content

Commit df1fbe3

Browse files
committed
build: always run go vet
This ensures 'make test' finds all errors that remote CI would find. Go 1.7 vet reports a false positive in package log, add a workaround.
1 parent e7911ad commit df1fbe3

File tree

4 files changed

+11
-9
lines changed

4 files changed

+11
-9
lines changed

.travis.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ matrix:
2424
- sudo chmod 666 /dev/fuse
2525
- sudo chown root:$USER /etc/fuse.conf
2626
- go run build/ci.go install
27-
- go run build/ci.go test -coverage -vet -misspell
27+
- go run build/ci.go test -coverage -misspell
2828

2929
- os: osx
3030
go: 1.8
@@ -34,7 +34,7 @@ matrix:
3434
- brew install caskroom/cask/brew-cask
3535
- brew cask install osxfuse
3636
- go run build/ci.go install
37-
- go run build/ci.go test -coverage -vet -misspell
37+
- go run build/ci.go test -coverage -misspell
3838

3939
# This builder does the Ubuntu PPA and Linux Azure uploads
4040
- os: linux

appveyor.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -36,4 +36,4 @@ after_build:
3636

3737
test_script:
3838
- set CGO_ENABLED=1
39-
- go run build\ci.go test -vet -coverage
39+
- go run build\ci.go test -coverage

build/ci.go

+2-5
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ Usage: go run ci.go <command> <command flags/arguments>
2424
Available commands are:
2525
2626
install [ -arch architecture ] [ packages... ] -- builds packages and executables
27-
test [ -coverage ] [ -vet ] [ -misspell ] [ packages... ] -- runs the tests
27+
test [ -coverage ] [ -misspell ] [ packages... ] -- runs the tests
2828
archive [ -arch architecture ] [ -type zip|tar ] [ -signer key-envvar ] [ -upload dest ] -- archives build artefacts
2929
importkeys -- imports signing keys from env
3030
debsrc [ -signer key-id ] [ -upload dest ] -- creates a debian source package
@@ -262,7 +262,6 @@ func goToolArch(arch string, subcmd string, args ...string) *exec.Cmd {
262262

263263
func doTest(cmdline []string) {
264264
var (
265-
vet = flag.Bool("vet", false, "Whether to run go vet")
266265
misspell = flag.Bool("misspell", false, "Whether to run the spell checker")
267266
coverage = flag.Bool("coverage", false, "Whether to record code coverage")
268267
)
@@ -275,9 +274,7 @@ func doTest(cmdline []string) {
275274
packages = build.ExpandPackagesNoVendor(packages)
276275

277276
// Run analysis tools before the tests.
278-
if *vet {
279-
build.MustRun(goTool("vet", packages...))
280-
}
277+
build.MustRun(goTool("vet", packages...))
281278
if *misspell {
282279
spellcheck(packages)
283280
}

log/handler.go

+6-1
Original file line numberDiff line numberDiff line change
@@ -106,11 +106,16 @@ func CallerFileHandler(h Handler) Handler {
106106
// the context with key "fn".
107107
func CallerFuncHandler(h Handler) Handler {
108108
return FuncHandler(func(r *Record) error {
109-
r.Ctx = append(r.Ctx, "fn", fmt.Sprintf("%+n", r.Call))
109+
r.Ctx = append(r.Ctx, "fn", formatCall("%+n", r.Call))
110110
return h.Log(r)
111111
})
112112
}
113113

114+
// This function is here to please go vet on Go < 1.8.
115+
func formatCall(format string, c stack.Call) string {
116+
return fmt.Sprintf(format, c)
117+
}
118+
114119
// CallerStackHandler returns a Handler that adds a stack trace to the context
115120
// with key "stack". The stack trace is formated as a space separated list of
116121
// call sites inside matching []'s. The most recent call site is listed first.

0 commit comments

Comments
 (0)