From 21c7ec8c35354a7f2690b2d2855a7b75b8273e95 Mon Sep 17 00:00:00 2001 From: Jakub Sztandera Date: Thu, 24 Nov 2016 20:06:22 +0100 Subject: [PATCH] Add test_go_fmt to makefile License: MIT Signed-off-by: Jakub Sztandera --- Makefile | 7 +++++-- bin/test-go-fmt | 15 +++++++++++++++ 2 files changed, 20 insertions(+), 2 deletions(-) create mode 100755 bin/test-go-fmt diff --git a/Makefile b/Makefile index bbc7ffc6e2d..1a8f98b9d37 100644 --- a/Makefile +++ b/Makefile @@ -75,13 +75,16 @@ PHONY += go_check deps vendor install build nofuse clean uninstall test: test_expensive -test_short: build test_go_short test_sharness_short +test_short: test_go_fmt build test_go_short test_sharness_short -test_expensive: build test_go_expensive test_sharness_expensive windows_build_check +test_expensive: test_go_fmt build test_go_expensive test_sharness_expensive windows_build_check test_3node: $(MAKE) -C test/3nodetest +test_go_fmt: + bin/test-go-fmt + test_go_short: $(go_test) -test.short ./... diff --git a/bin/test-go-fmt b/bin/test-go-fmt new file mode 100755 index 00000000000..8bc7d2e667e --- /dev/null +++ b/bin/test-go-fmt @@ -0,0 +1,15 @@ +#!/usr/bin/env bash +set -euo pipefail +T="$(mktemp)" +find . -name '*.go' | xargs gofmt -l > "$T" + +if [ -n "$(cat $T)" ]; then + echo "Following Go code is not formatted." + echo "-----------------------------------" + cat "$T" + echo "-----------------------------------" + echo "Run 'go fmt ./...' in your source directory" + rm -f "$T" + exit 1 +fi +rm -f "$T"