From 41bbf437e1e843fd3ab5603ec4c2eb4a42dca76f Mon Sep 17 00:00:00 2001 From: Dmitry Vyukov Date: Fri, 18 Aug 2017 11:14:20 +0200 Subject: Makefile: enforce formatting of sys files in presubmit --- Makefile | 6 +++++- pkg/ast/parser_test.go | 10 ++++------ tools/syz-fmt/syz-fmt.go | 1 + 3 files changed, 10 insertions(+), 7 deletions(-) diff --git a/Makefile b/Makefile index 708a74467..7941814ef 100644 --- a/Makefile +++ b/Makefile @@ -10,6 +10,7 @@ endif manager fuzzer executor \ ci hub \ execprog mutate prog2c stress repro upgrade db \ + bin/syz-sysgen bin/syz-extract bin/syz-fmt \ extract generate \ android \ format tidy test arch presubmit clean @@ -81,9 +82,12 @@ generate: bin/syz-sysgen bin/syz-sysgen: go build $(GOFLAGS) -o $@ ./sys/syz-sysgen -format: +format: bin/syz-fmt go fmt ./... clang-format --style=file -i executor/*.cc executor/*.h tools/kcovtrace/*.c + bin/syz-fmt sys +bin/syz-fmt: + go build $(GOFLAGS) -o $@ ./tools/syz-fmt tidy: # A single check is enabled for now. But it's always fixable and proved to be useful. diff --git a/pkg/ast/parser_test.go b/pkg/ast/parser_test.go index 521078805..43587d7a3 100644 --- a/pkg/ast/parser_test.go +++ b/pkg/ast/parser_test.go @@ -42,12 +42,10 @@ func TestParseAll(t *testing.T) { if len(top) != len(top2) { t.Fatalf("formatting number of top level decls: %v/%v", len(top), len(top2)) } - if false { - // While sys files are not formatted, formatting in fact changes it. - for i := range top { - if !reflect.DeepEqual(top[i], top2[i]) { - t.Fatalf("formatting changed code:\n%#v\nvs:\n%#v", top[i], top2[i]) - } + // While sys files are not formatted, formatting in fact changes it. + for i := range top { + if !reflect.DeepEqual(top[i], top2[i]) { + t.Fatalf("formatting changed code:\n%#v\nvs:\n%#v", top[i], top2[i]) } } } diff --git a/tools/syz-fmt/syz-fmt.go b/tools/syz-fmt/syz-fmt.go index f78e8b8dc..e6f14dcbe 100644 --- a/tools/syz-fmt/syz-fmt.go +++ b/tools/syz-fmt/syz-fmt.go @@ -61,6 +61,7 @@ func processFile(file string, mode os.FileMode) { if bytes.Equal(data, formatted) { return } + fmt.Printf("reformatting %v\n", file) if err := os.Rename(file, file+"~"); err != nil { fmt.Fprintf(os.Stderr, "%v\n", err) os.Exit(1) -- cgit mrf-deployment