Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Run tests with race flag #1013

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
37 changes: 28 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,16 @@ 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
@VARS='$(GOFLAGS)'; \
if test x"$$VARS" != x"`cat $@ 2>/dev/null`" ; then \
echo "*** new Go flags ***"; \
echo "$$VARS" >$@; \
fi
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this seems very magic-y to me. wonder if maybe the right thing to do is to have both:

bin/program
bin/program-race

that way we could even have concurrent tests going

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I copied what is done in the Git Makefile for these kind of things.
It is just checking if the content of the GOFLAGS variable is different from what is in the IPFS-BUILD-OPTIONS file, and if it is different, it puts the content of the GOFLAGS variable into the file.

We could have something like:

bin/program-normal
bin/program-race

and then a bin/program symlink that points to one or the other of the above binaries. But I am not sure it would be simpler and this way we couldn't have concurent tests going on.

To have concurent tests going on, we would need to modify the test scripts before launching them with something like sed 's/ipfs/ipfs-race/g' but it could be tricky to get right too.

Or maybe I am missing something?


.PHONY: all clean FORCE
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