Skip to content

Commit

Permalink
build: always run go vet
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
fjl committed Mar 24, 2017
1 parent e7911ad commit df1fbe3
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 9 deletions.
4 changes: 2 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ matrix:
- sudo chmod 666 /dev/fuse
- sudo chown root:$USER /etc/fuse.conf
- go run build/ci.go install
- go run build/ci.go test -coverage -vet -misspell
- go run build/ci.go test -coverage -misspell

- os: osx
go: 1.8
Expand All @@ -34,7 +34,7 @@ matrix:
- brew install caskroom/cask/brew-cask
- brew cask install osxfuse
- go run build/ci.go install
- go run build/ci.go test -coverage -vet -misspell
- go run build/ci.go test -coverage -misspell

# This builder does the Ubuntu PPA and Linux Azure uploads
- os: linux
Expand Down
2 changes: 1 addition & 1 deletion appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,4 @@ after_build:

test_script:
- set CGO_ENABLED=1
- go run build\ci.go test -vet -coverage
- go run build\ci.go test -coverage
7 changes: 2 additions & 5 deletions build/ci.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ Usage: go run ci.go <command> <command flags/arguments>
Available commands are:
install [ -arch architecture ] [ packages... ] -- builds packages and executables
test [ -coverage ] [ -vet ] [ -misspell ] [ packages... ] -- runs the tests
test [ -coverage ] [ -misspell ] [ packages... ] -- runs the tests
archive [ -arch architecture ] [ -type zip|tar ] [ -signer key-envvar ] [ -upload dest ] -- archives build artefacts
importkeys -- imports signing keys from env
debsrc [ -signer key-id ] [ -upload dest ] -- creates a debian source package
Expand Down Expand Up @@ -262,7 +262,6 @@ func goToolArch(arch string, subcmd string, args ...string) *exec.Cmd {

func doTest(cmdline []string) {
var (
vet = flag.Bool("vet", false, "Whether to run go vet")
misspell = flag.Bool("misspell", false, "Whether to run the spell checker")
coverage = flag.Bool("coverage", false, "Whether to record code coverage")
)
Expand All @@ -275,9 +274,7 @@ func doTest(cmdline []string) {
packages = build.ExpandPackagesNoVendor(packages)

// Run analysis tools before the tests.
if *vet {
build.MustRun(goTool("vet", packages...))
}
build.MustRun(goTool("vet", packages...))
if *misspell {
spellcheck(packages)
}
Expand Down
7 changes: 6 additions & 1 deletion log/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -106,11 +106,16 @@ func CallerFileHandler(h Handler) Handler {
// the context with key "fn".
func CallerFuncHandler(h Handler) Handler {
return FuncHandler(func(r *Record) error {
r.Ctx = append(r.Ctx, "fn", fmt.Sprintf("%+n", r.Call))
r.Ctx = append(r.Ctx, "fn", formatCall("%+n", r.Call))
return h.Log(r)
})
}

// This function is here to please go vet on Go < 1.8.
func formatCall(format string, c stack.Call) string {
return fmt.Sprintf(format, c)
}

// CallerStackHandler returns a Handler that adds a stack trace to the context
// with key "stack". The stack trace is formated as a space separated list of
// call sites inside matching []'s. The most recent call site is listed first.
Expand Down

0 comments on commit df1fbe3

Please sign in to comment.