Add gofmt check
rht committed
May 19, 2015 at 00:00 UTC
1e38f71a38661e3294de1163853a04a5ffa88b35
2 files changed
+25
-3
test/Makefile
+6
-3
@@ -43,16 +43,16 @@ bin/iptb: $(call find_go_files, $(IPTB_SRC)) IPFS-BUILD-OPTIONS
43
44
test: test_expensive
45
46
-test_expensive:
46
+test_expensive: verify_gofmt
47
cd sharness && make TEST_EXPENSIVE=1
48
cd 3nodetest && make
49
cd dependencies && make
50
51
-test_cheap:
51
+test_cheap: verify_gofmt
52
cd sharness && make
53
cd 3nodetest && make
54
55
-test_race:
55
+test_race: verify_gofmt
56
cd sharness && make GOFLAGS=-race TEST_EXPENSIVE=1
57
cd 3nodetest && make GOFLAGS=-race
58
cd dependencies && make GOFLAGS=-race
@@ -60,4 +60,7 @@ test_race:
60
IPFS-BUILD-OPTIONS: FORCE
61
@bin/checkflags '$@' '$(GOFLAGS)' '*** new Go flags ***'
62
63
+verify_gofmt:
64
+ bin/verify-go-fmt.sh
65
+
66
.PHONY: all clean FORCE
test/bin/verify-go-fmt.sh
new
+19
@@ -0,0 +1,19 @@
1
+#!/bin/sh
2
+
3
+#TODO add go lint and go vet
4
+
5
+verify_gofmt() {
6
+ GOFMT="gofmt -s"
7
+ cd "$(git rev-parse --show-toplevel)"
8
+ bad_files=$($GOFMT -l . | grep -v Godeps)
9
+ cd -
10
+ if [[ -n $bad_files ]]; then
11
+ echo "You have to run '$GOFMT' on these files:"
12
+ echo "$bad_files"
13
+ false
14
+ else
15
+ true
16
+ fi
17
+}
18
+
19
+verify_gofmt