From d36a9eef2bd3da01c4985f6cda7b8419bbf11bee Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tor=20Arne=20Vestb=C3=B8?= Date: Tue, 7 Apr 2015 18:42:13 +0200 Subject: [PATCH 1/3] Ensure IPFS-BUILD-OPTIONS build dependency is created If the file doesn't exist, make will conclude that the missing prerequisite should trigger a rebuild of the binaries. --- test/bin/checkflags | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/test/bin/checkflags b/test/bin/checkflags index a246a82c3..e78e54835 100755 --- a/test/bin/checkflags +++ b/test/bin/checkflags @@ -14,9 +14,11 @@ shift shift FLAG_MSGS="$@" +test -f $FLAG_FILE || touch $FLAG_FILE + # 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)" +if test x"$FLAG_VALS" != x"$(cat "$FLAG_FILE")" then echo "$FLAG_MSGS" echo "$FLAG_VALS" >"$FLAG_FILE" From 7b49419d9361c5a7893baf18745ed2bdbdb6604a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tor=20Arne=20Vestb=C3=B8?= Date: Tue, 7 Apr 2015 19:43:41 +0200 Subject: [PATCH 2/3] Fix dependencies in sharness test makefile Running make -jN would result in the tests starting to execute before the tests binaries were built, resulting in the error: "Cannot find the tests' local ipfs tool" Each test now depends on the deps. They also depend on a new target for cleaning the test results, so that the tests can write new clean results. The aggregate target also needs to depend on the same test results clean target, as well as the tests themselves, so that the aggregation happens when all tests have finished running. By introducing a separate target for cleaning test results we also ensure that we don't end up removing and rebuilding the binary on each test run. The result is that the tests *can* be run with with -jN > 1, but individual tests may still not supports this, so to get stable test results it's still recommended to run them in sequence. --- test/sharness/Makefile | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/test/sharness/Makefile b/test/sharness/Makefile index 1166df6bb..bc07c0170 100644 --- a/test/sharness/Makefile +++ b/test/sharness/Makefile @@ -14,18 +14,21 @@ IPFS_ROOT = ../.. # User might want to override those on the command line GOFLAGS = -all: clean deps $(T) aggregate +all: aggregate -clean: +clean: clean-test-results @echo "*** $@ ***" - -rm -rf test-results -rm -rf bin/ipfs -$(T): +clean-test-results: + @echo "*** $@ ***" + -rm -rf test-results + +$(T): clean-test-results deps @echo "*** $@ ***" ./$@ -aggregate: +aggregate: clean-test-results $(T) @echo "*** $@ ***" lib/test-aggregate-results.sh From f2dd060e4a34a2106e7a13cb759daca9919e935c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tor=20Arne=20Vestb=C3=B8?= Date: Tue, 7 Apr 2015 16:47:55 +0200 Subject: [PATCH 3/3] Don't use wildcards to look for .go files in tests makefile GNU Make's wildcard function does not recurse into subdirectories when passed the '**' glob, which results in adding a dependency only to .go files in the first level of subdirectories under the source root. We shell out to 'find' instead, which catches all .go files in the given directory. --- test/Makefile | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/test/Makefile b/test/Makefile index 93a287a3f..8974c552b 100644 --- a/test/Makefile +++ b/test/Makefile @@ -18,19 +18,21 @@ clean: bins: $(BINS) -bin/random: $(RANDOM_SRC)/**/*.go IPFS-BUILD-OPTIONS +find_go_files = $(shell find $(1) -name "*.go") + +bin/random: $(call find_go_files, $(RANDOM_SRC)) IPFS-BUILD-OPTIONS @echo "*** installing $@ ***" go build $(GOFLAGS) -o bin/random $(RANDOM_SRC)/random -bin/multihash: $(MULTIHASH_SRC)/**/*.go IPFS-BUILD-OPTIONS +bin/multihash: $(call find_go_files, $(MULTIHASH_SRC)) IPFS-BUILD-OPTIONS @echo "*** installing $@ ***" go build $(GOFLAGS) -o bin/multihash $(MULTIHASH_SRC)/multihash -bin/ipfs: $(IPFS_ROOT)/**/*.go IPFS-BUILD-OPTIONS +bin/ipfs: $(call find_go_files, $(IPFS_ROOT)) IPFS-BUILD-OPTIONS @echo "*** installing $@ ***" go build $(GOFLAGS) -o bin/ipfs $(IPFS_CMD) -bin/pollEndpoint: $(POLLENDPOINT_SRC)/*.go IPFS-BUILD-OPTIONS +bin/pollEndpoint: $(call find_go_files, $(POLLENDPOINT_SRC)) IPFS-BUILD-OPTIONS @echo "*** installing $@ ***" go build $(GOFLAGS) -o bin/pollEndpoint $(POLLENDPOINT_SRC)