Makefile: enforce formatting of sys files in presubmit

This commit is contained in:
Dmitry Vyukov 2017-08-18 11:14:20 +02:00
parent 5b461e7ecd
commit 41bbf437e1
3 changed files with 10 additions and 7 deletions

View File

@ -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.

View File

@ -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])
}
}
}

View File

@ -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)