Skip to content

Commit f2aba08

Browse files
committed
Merge pull request #1024 from ipfs/run_tests_with_race_flag2
Run tests with race flag using checkflags script
2 parents 447f1ef + dbf91a1 commit f2aba08

File tree

4 files changed

+57
-15
lines changed

4 files changed

+57
-15
lines changed

test/.gitignore

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,2 +1 @@
1-
bin/ipfs
2-
bin/random
1+
IPFS-BUILD-OPTIONS

test/Makefile

+24-9
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@ RANDOM_SRC = ../Godeps/_workspace/src/github.com/jbenet/go-random
66
MULTIHASH_SRC = ../Godeps/_workspace/src/github.com/jbenet/go-multihash
77
POLLENDPOINT_SRC= ../thirdparty/pollEndpoint
88

9+
# User might want to override those on the command line
10+
GOFLAGS =
11+
912
all: deps
1013

1114
deps: bins
@@ -15,17 +18,21 @@ clean:
1518

1619
bins: $(BINS)
1720

18-
bin/random: $(RANDOM_SRC)/**/*.go
19-
go build -o bin/random $(RANDOM_SRC)/random
21+
bin/random: $(RANDOM_SRC)/**/*.go IPFS-BUILD-OPTIONS
22+
@echo "*** installing $@ ***"
23+
go build $(GOFLAGS) -o bin/random $(RANDOM_SRC)/random
2024

21-
bin/multihash: $(MULTIHASH_SRC)/**/*.go
22-
go build -o bin/multihash $(MULTIHASH_SRC)/multihash
25+
bin/multihash: $(MULTIHASH_SRC)/**/*.go IPFS-BUILD-OPTIONS
26+
@echo "*** installing $@ ***"
27+
go build $(GOFLAGS) -o bin/multihash $(MULTIHASH_SRC)/multihash
2328

24-
bin/ipfs: $(IPFS_ROOT)/**/*.go
25-
go build -o bin/ipfs $(IPFS_CMD)
29+
bin/ipfs: $(IPFS_ROOT)/**/*.go IPFS-BUILD-OPTIONS
30+
@echo "*** installing $@ ***"
31+
go build $(GOFLAGS) -o bin/ipfs $(IPFS_CMD)
2632

27-
bin/pollEndpoint: $(POLLENDPOINT_SRC)/*.go
28-
go build -o bin/pollEndpoint $(POLLENDPOINT_SRC)
33+
bin/pollEndpoint: $(POLLENDPOINT_SRC)/*.go IPFS-BUILD-OPTIONS
34+
@echo "*** installing $@ ***"
35+
go build $(GOFLAGS) -o bin/pollEndpoint $(POLLENDPOINT_SRC)
2936

3037
test: test_expensive
3138

@@ -38,4 +45,12 @@ test_cheap:
3845
cd sharness && make
3946
cd 3nodetest && make
4047

41-
.PHONY: all clean
48+
test_race:
49+
cd sharness && make GOFLAGS=-race TEST_EXPENSIVE=1
50+
cd 3nodetest && make GOFLAGS=-race
51+
cd dependencies && make GOFLAGS=-race
52+
53+
IPFS-BUILD-OPTIONS: FORCE
54+
@bin/checkflags '$@' '$(GOFLAGS)' '*** new Go flags ***'
55+
56+
.PHONY: all clean FORCE

test/bin/checkflags

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
#!/bin/sh
2+
# Author: Christian Couder <[email protected]>
3+
# MIT LICENSED
4+
5+
if test "$#" -lt 3
6+
then
7+
echo >&2 "usage $0 FILE VALUES MSG..."
8+
exit 1
9+
fi
10+
11+
FLAG_FILE="$1"
12+
FLAG_VALS="$2"
13+
shift
14+
shift
15+
FLAG_MSGS="$@"
16+
17+
# Use x in front of tested values as flags could be
18+
# interpreted by "test" to be for itself.
19+
if test x"$FLAG_VALS" != x"$(cat "$FLAG_FILE" 2>/dev/null)"
20+
then
21+
echo "$FLAG_MSGS"
22+
echo "$FLAG_VALS" >"$FLAG_FILE"
23+
fi

test/sharness/Makefile

+9-4
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@ BINS = bin/random bin/multihash bin/ipfs bin/pollEndpoint
1111
SHARNESS = lib/sharness/sharness.sh
1212
IPFS_ROOT = ../..
1313

14+
# User might want to override those on the command line
15+
GOFLAGS =
16+
1417
all: clean deps $(T) aggregate
1518

1619
clean:
@@ -32,11 +35,13 @@ $(SHARNESS):
3235
@echo "*** installing $@ ***"
3336
lib/install-sharness.sh
3437

35-
bin/%: $(IPFS_ROOT)/**/*.go
36-
@echo "*** installing $@ ***"
37-
cd .. && make $@
38+
bin/%: FORCE
39+
cd .. && make GOFLAGS=$(GOFLAGS) $@
40+
41+
race:
42+
make GOFLAGS=-race all
3843

39-
.PHONY: all clean $(T) aggregate
44+
.PHONY: all clean $(T) aggregate FORCE
4045

4146
# will fail if curl is not installed.
4247
# TODO: get rid of this and install curl with git or ipfs.

0 commit comments

Comments
 (0)