aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDmitry Vyukov <dvyukov@google.com>2017-08-18 11:14:20 +0200
committerDmitry Vyukov <dvyukov@google.com>2017-08-18 11:26:50 +0200
commit41bbf437e1e843fd3ab5603ec4c2eb4a42dca76f (patch)
treee29cacc7839a64866af3d3229aa7ec035d8081ba
parent5b461e7ecd9556f9a54e1a5afc3ef962bc5cd11e (diff)
Makefile: enforce formatting of sys files in presubmit
-rw-r--r--Makefile6
-rw-r--r--pkg/ast/parser_test.go10
-rw-r--r--tools/syz-fmt/syz-fmt.go1
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)