Skip to content

Commit

Permalink
Merge pull request #1024 from ipfs/run_tests_with_race_flag2
Browse files Browse the repository at this point in the history
Run tests with race flag using checkflags script
  • Loading branch information
jbenet committed Apr 7, 2015
2 parents 447f1ef + dbf91a1 commit f2aba08
Show file tree
Hide file tree
Showing 4 changed files with 57 additions and 15 deletions.
3 changes: 1 addition & 2 deletions test/.gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
bin/ipfs
bin/random
IPFS-BUILD-OPTIONS
33 changes: 24 additions & 9 deletions test/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ RANDOM_SRC = ../Godeps/_workspace/src/github.com/jbenet/go-random
MULTIHASH_SRC = ../Godeps/_workspace/src/github.com/jbenet/go-multihash
POLLENDPOINT_SRC= ../thirdparty/pollEndpoint

# User might want to override those on the command line
GOFLAGS =

all: deps

deps: bins
Expand All @@ -15,17 +18,21 @@ clean:

bins: $(BINS)

bin/random: $(RANDOM_SRC)/**/*.go
go build -o bin/random $(RANDOM_SRC)/random
bin/random: $(RANDOM_SRC)/**/*.go IPFS-BUILD-OPTIONS
@echo "*** installing $@ ***"
go build $(GOFLAGS) -o bin/random $(RANDOM_SRC)/random

bin/multihash: $(MULTIHASH_SRC)/**/*.go
go build -o bin/multihash $(MULTIHASH_SRC)/multihash
bin/multihash: $(MULTIHASH_SRC)/**/*.go IPFS-BUILD-OPTIONS
@echo "*** installing $@ ***"
go build $(GOFLAGS) -o bin/multihash $(MULTIHASH_SRC)/multihash

bin/ipfs: $(IPFS_ROOT)/**/*.go
go build -o bin/ipfs $(IPFS_CMD)
bin/ipfs: $(IPFS_ROOT)/**/*.go IPFS-BUILD-OPTIONS
@echo "*** installing $@ ***"
go build $(GOFLAGS) -o bin/ipfs $(IPFS_CMD)

bin/pollEndpoint: $(POLLENDPOINT_SRC)/*.go
go build -o bin/pollEndpoint $(POLLENDPOINT_SRC)
bin/pollEndpoint: $(POLLENDPOINT_SRC)/*.go IPFS-BUILD-OPTIONS
@echo "*** installing $@ ***"
go build $(GOFLAGS) -o bin/pollEndpoint $(POLLENDPOINT_SRC)

test: test_expensive

Expand All @@ -38,4 +45,12 @@ test_cheap:
cd sharness && make
cd 3nodetest && make

.PHONY: all clean
test_race:
cd sharness && make GOFLAGS=-race TEST_EXPENSIVE=1
cd 3nodetest && make GOFLAGS=-race
cd dependencies && make GOFLAGS=-race

IPFS-BUILD-OPTIONS: FORCE
@bin/checkflags '$@' '$(GOFLAGS)' '*** new Go flags ***'

.PHONY: all clean FORCE
23 changes: 23 additions & 0 deletions test/bin/checkflags
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#!/bin/sh
# Author: Christian Couder <chriscool@tuxfamily.org>
# MIT LICENSED

if test "$#" -lt 3
then
echo >&2 "usage $0 FILE VALUES MSG..."
exit 1
fi

FLAG_FILE="$1"
FLAG_VALS="$2"
shift
shift
FLAG_MSGS="$@"

# Use x in front of tested values as flags could be
# interpreted by "test" to be for itself.
if test x"$FLAG_VALS" != x"$(cat "$FLAG_FILE" 2>/dev/null)"
then
echo "$FLAG_MSGS"
echo "$FLAG_VALS" >"$FLAG_FILE"
fi
13 changes: 9 additions & 4 deletions test/sharness/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ BINS = bin/random bin/multihash bin/ipfs bin/pollEndpoint
SHARNESS = lib/sharness/sharness.sh
IPFS_ROOT = ../..

# User might want to override those on the command line
GOFLAGS =

all: clean deps $(T) aggregate

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

bin/%: $(IPFS_ROOT)/**/*.go
@echo "*** installing $@ ***"
cd .. && make $@
bin/%: FORCE
cd .. && make GOFLAGS=$(GOFLAGS) $@

race:
make GOFLAGS=-race all

.PHONY: all clean $(T) aggregate
.PHONY: all clean $(T) aggregate FORCE

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

0 comments on commit f2aba08

Please sign in to comment.