Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

build: misc make check improvements #9902

Merged
merged 4 commits into from Oct 12, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion Makefile
Expand Up @@ -165,7 +165,7 @@ check:
# compile everything; go vet sometimes reports incorrect errors if
# the build artifacts are stale.
$(GO) test -i -tags '$(TAGS)' ./...
$(GO) test ./build -v -tags check
$(GO) test ./build -v -tags check -run 'TestStyle/$(TESTS)'

.PHONY: clean
clean:
Expand Down
16 changes: 15 additions & 1 deletion build/style_test.go
Expand Up @@ -23,6 +23,7 @@ import (
"os"
"os/exec"
"path/filepath"
"strconv"
"strings"
"testing"

Expand Down Expand Up @@ -445,6 +446,19 @@ func TestStyle(t *testing.T) {
t.Fatalf("err=%s, stderr=%s", err, out)
}
}

if t.Failed() {
args := append([]string(nil), cmd.Args[1:len(cmd.Args)-1]...)
args = append(args, "-w", ".")
for i := range args {
args[i] = strconv.Quote(args[i])
}
t.Logf("run the following to fix your formatting:\n"+
"\n%s %s\n\n"+
"Don't forget to add amend the result to the correct commits.",
cmd.Args[0], strings.Join(args, " "),
)
}
})

t.Run("TestVet", func(t *testing.T) {
Expand Down Expand Up @@ -482,7 +496,7 @@ func TestStyle(t *testing.T) {
switch err := cmd.Run(); err.(type) {
case nil:
case *exec.ExitError:
t.Log(err) // Non-zero exit is expected.
// Non-zero exit is expected.
default:
t.Fatal(err)
}
Expand Down
3 changes: 3 additions & 0 deletions githooks/pre-push
@@ -0,0 +1,3 @@
#!/usr/bin/env sh

make check TESTS=TestCrlfmt