From 9535cb5802b486013cc48df0bb099e9141bbe9e1 Mon Sep 17 00:00:00 2001 From: Juan Batiz-Benet Date: Thu, 6 Nov 2014 15:37:38 -0800 Subject: [PATCH 01/15] install sharness --- test/Makefile | 8 +++++++- test/install-sharness.sh | 28 ++++++++++++++++++++++++++++ 2 files changed, 35 insertions(+), 1 deletion(-) create mode 100755 test/install-sharness.sh diff --git a/test/Makefile b/test/Makefile index 7e6381794..a1cbc8f55 100644 --- a/test/Makefile +++ b/test/Makefile @@ -6,7 +6,7 @@ T = $(sort $(wildcard t[0-9][0-9][0-9][0-9]-*.sh)) -all: clean $(T) aggregate +all: clean deps $(T) aggregate clean: @echo "*** $@ ***" @@ -20,4 +20,10 @@ aggregate: @echo "*** $@ ***" ./test-aggregate-results.sh +deps: sharness.sh + +sharness.sh: + @echo "*** installing $@ ***" + ./install-sharness.sh + .PHONY: all clean $(T) aggregate diff --git a/test/install-sharness.sh b/test/install-sharness.sh new file mode 100755 index 000000000..47438637f --- /dev/null +++ b/test/install-sharness.sh @@ -0,0 +1,28 @@ +#!/bin/sh +# install sharness.sh +# +# Copyright (c) 2014 Juan Batiz-Benet +# MIT Licensed; see the LICENSE file in this repository. +# + +# settings +version=50229a79ba22b2f13ccd82451d86570fecbd194c +hash1=eeaf96630fc25ec58fb678b64ef9772d5eb92f64 +url=https://raw.githubusercontent.com/mlafeldt/sharness/$version/sharness.sh +file=sharness.sh + +# download it +wget -q $url -O $file.test + +# verify it's the right file +hash2=`cat $file.test | shasum | cut -c1-40` +if test "$hash1" != "$hash2"; then + echo "$file verification failed" + echo "$hash1 != $hash2" + rm $file.test + exit -1 +fi + +# ok, move it into place +mv $file.test $file +exit 0 From 8198ba94d6f4cd032071251bbd052be1a4615b83 Mon Sep 17 00:00:00 2001 From: Juan Batiz-Benet Date: Thu, 6 Nov 2014 15:45:44 -0800 Subject: [PATCH 02/15] add sharness tests to travis --- .travis.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.travis.yml b/.travis.yml index ecf595da0..3c156985f 100644 --- a/.travis.yml +++ b/.travis.yml @@ -7,5 +7,8 @@ go: script: - go test -v ./... + - cd test/ + - make + - cd .. env: TEST_NO_FUSE=1 From 54651618e8e51e2a2abaea7abd861a7a2bf1189c Mon Sep 17 00:00:00 2001 From: Juan Batiz-Benet Date: Thu, 6 Nov 2014 16:32:14 -0800 Subject: [PATCH 03/15] install aggregate-results.sh too --- test/install-sharness.sh | 47 +++++++++++++++++++++++++++++----------- 1 file changed, 34 insertions(+), 13 deletions(-) diff --git a/test/install-sharness.sh b/test/install-sharness.sh index 47438637f..659c332a1 100755 --- a/test/install-sharness.sh +++ b/test/install-sharness.sh @@ -7,22 +7,43 @@ # settings version=50229a79ba22b2f13ccd82451d86570fecbd194c -hash1=eeaf96630fc25ec58fb678b64ef9772d5eb92f64 -url=https://raw.githubusercontent.com/mlafeldt/sharness/$version/sharness.sh -file=sharness.sh +urlprefix=https://raw.githubusercontent.com/mlafeldt/sharness/$version -# download it -wget -q $url -O $file.test +# files to download +sfile=sharness.sh +shash=eeaf96630fc25ec58fb678b64ef9772d5eb92f64 -# verify it's the right file -hash2=`cat $file.test | shasum | cut -c1-40` -if test "$hash1" != "$hash2"; then - echo "$file verification failed" - echo "$hash1 != $hash2" - rm $file.test +afile=aggregate-results.sh +ahash=948d6bc03222c5c00a1ed048068508d5ea1cce59 + +verified_download() { + file=$1 + hash1=$2 + url=$urlprefix/$file + + # download it + wget -q $url -O $file.test + + # verify it's the right file + hash2=`cat $file.test | shasum | cut -c1-40` + if test "$hash1" != "$hash2"; then + echo "$file verification failed:" + echo " $hash1 != $hash2" + return -1 + fi + return 0 +} + + +verified_download "$sfile" "$shash"; sok=$? +verified_download "$afile" "$ahash"; aok=$? +if test "$sok" != 0 || test "$aok" != 0; then + rm $afile.test + rm $sfile.test exit -1 fi -# ok, move it into place -mv $file.test $file +# ok, move things into place +mv $sfile.test $sfile +mv $afile.test $afile exit 0 From eee15baeb657803f267584b0331262c37791627f Mon Sep 17 00:00:00 2001 From: Juan Batiz-Benet Date: Thu, 6 Nov 2014 16:49:45 -0800 Subject: [PATCH 04/15] remove test-sharness-config --- test/install-sharness.sh | 2 ++ test/test-aggregate-results.sh | 4 +--- test/test-lib.sh | 2 +- test/test-sharness-config.sh | 23 ----------------------- 4 files changed, 4 insertions(+), 27 deletions(-) delete mode 100644 test/test-sharness-config.sh diff --git a/test/install-sharness.sh b/test/install-sharness.sh index 659c332a1..871ebb690 100755 --- a/test/install-sharness.sh +++ b/test/install-sharness.sh @@ -46,4 +46,6 @@ fi # ok, move things into place mv $sfile.test $sfile mv $afile.test $afile +chmod +x $sfile +chmod +x $afile exit 0 diff --git a/test/test-aggregate-results.sh b/test/test-aggregate-results.sh index fdac06dea..eea4b7154 100755 --- a/test/test-aggregate-results.sh +++ b/test/test-aggregate-results.sh @@ -6,9 +6,7 @@ # MIT Licensed; see the LICENSE file in this repository. # -. ./test-sharness-config.sh - -SHARNESS_AGGREGATE="$SHARNESS_DIRECTORY/aggregate-results.sh" +SHARNESS_AGGREGATE="./aggregate-results.sh" test -f "$SHARNESS_AGGREGATE" || { echo >&2 "Cannot find: $SHARNESS_AGGREGATE" diff --git a/test/test-lib.sh b/test/test-lib.sh index ee860f855..40e5cc9ab 100644 --- a/test/test-lib.sh +++ b/test/test-lib.sh @@ -6,7 +6,7 @@ # We are using sharness (https://github.com/mlafeldt/sharness) # which was extracted from the Git test framework. -. ./test-sharness-config.sh +SHARNESS_LIB="./sharness.sh" . "$SHARNESS_LIB" || { echo >&2 "Cannot source: $SHARNESS_LIB" diff --git a/test/test-sharness-config.sh b/test/test-sharness-config.sh deleted file mode 100644 index 4c26c8985..000000000 --- a/test/test-sharness-config.sh +++ /dev/null @@ -1,23 +0,0 @@ -# Copyright (c) 2014 Christian Couder -# MIT Licensed; see the LICENSE file in this repository. -# -# We are using sharness (https://github.com/mlafeldt/sharness) -# which was extracted from the Git test framework. - -# You need either sharness to be installed system-wide or -# to set the SHARNESS_DIRECTORY environment variable properly. - -if test -z "$SHARNESS_DIRECTORY" -then - SHARNESS_DIRECTORY=/usr/local/share/sharness -fi - -SHARNESS_LIB="$SHARNESS_DIRECTORY/sharness.sh" - -test -f "$SHARNESS_LIB" || { - echo >&2 "Cannot find sharness.sh in: $SHARNESS_DIRECTORY" - echo >&2 "Please install Sharness system-wide or set the" - echo >&2 "SHARNESS_DIRECTORY environment variable." - echo >&2 "See: https://github.com/mlafeldt/sharness" - exit 1 -} From 728d977b099cb327966dcf14fdab5486d2195618 Mon Sep 17 00:00:00 2001 From: Juan Batiz-Benet Date: Thu, 6 Nov 2014 17:56:03 -0800 Subject: [PATCH 05/15] go install in travis test --- .travis.yml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index 3c156985f..7d699a742 100644 --- a/.travis.yml +++ b/.travis.yml @@ -7,8 +7,9 @@ go: script: - go test -v ./... - - cd test/ - - make + - cd cmd/ipfs && go install # test it can be compiled + - cd ../../test/ + - make # sharness tests - cd .. env: TEST_NO_FUSE=1 From e5198b1446faf479b81b164fa47b03cf43650f37 Mon Sep 17 00:00:00 2001 From: Juan Batiz-Benet Date: Thu, 6 Nov 2014 18:03:10 -0800 Subject: [PATCH 06/15] bitswap error -> debug (use IPFS_LOGGING=debug) --- exchange/bitswap/bitswap.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/exchange/bitswap/bitswap.go b/exchange/bitswap/bitswap.go index 369fcee75..ed444b100 100644 --- a/exchange/bitswap/bitswap.go +++ b/exchange/bitswap/bitswap.go @@ -82,7 +82,7 @@ func (bs *bitswap) Block(parent context.Context, k u.Key) (*blocks.Block, error) log.Debugf("Get Block %v", k) now := time.Now() defer func() { - log.Errorf("GetBlock took %f secs", time.Now().Sub(now).Seconds()) + log.Debugf("GetBlock took %f secs", time.Now().Sub(now).Seconds()) }() ctx, cancelFunc := context.WithCancel(parent) From fc6213db096aa058d8076315348b6a5d22aee807 Mon Sep 17 00:00:00 2001 From: Juan Batiz-Benet Date: Thu, 6 Nov 2014 18:13:19 -0800 Subject: [PATCH 07/15] dont test mount when no fuse --- test/t0030-mount.sh | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/test/t0030-mount.sh b/test/t0030-mount.sh index cca3fc1b2..567cb01d9 100755 --- a/test/t0030-mount.sh +++ b/test/t0030-mount.sh @@ -8,6 +8,13 @@ test_description="Test mount command" . ./test-lib.sh +# if in travis CI, dont test mount (no fuse) +if test "$TEST_NO_FUSE" = 1; then + skip_all='skipping mount tests, fuse not available' + + test_done +fi + test_launch_ipfs_mount test_kill_ipfs_mount From 7e46d9514544625730c6104c4e368bfbe196c26b Mon Sep 17 00:00:00 2001 From: Christian Couder Date: Fri, 7 Nov 2014 22:41:28 +0100 Subject: [PATCH 08/15] Use a FUSE prerequisite to skip mount tests When there is no fuse we should skip all mount tests and using a FUSE prerequisite is a good way to do that. --- test/t0030-mount.sh | 6 +++--- test/t0040-add-and-cat.sh | 8 ++++---- test/test-lib.sh | 10 ++++++---- 3 files changed, 13 insertions(+), 11 deletions(-) diff --git a/test/t0030-mount.sh b/test/t0030-mount.sh index 567cb01d9..ddb187f72 100755 --- a/test/t0030-mount.sh +++ b/test/t0030-mount.sh @@ -9,10 +9,10 @@ test_description="Test mount command" . ./test-lib.sh # if in travis CI, dont test mount (no fuse) -if test "$TEST_NO_FUSE" = 1; then - skip_all='skipping mount tests, fuse not available' +if ! test_have_prereq FUSE; then + skip_all='skipping mount tests, fuse not available' - test_done + test_done fi test_launch_ipfs_mount diff --git a/test/t0040-add-and-cat.sh b/test/t0040-add-and-cat.sh index 34036f9da..3091afc2e 100755 --- a/test/t0040-add-and-cat.sh +++ b/test/t0040-add-and-cat.sh @@ -30,11 +30,11 @@ test_expect_success "ipfs cat output looks good" ' test_cmp expected actual ' -test_expect_success "cat ipfs/stuff succeeds" ' +test_expect_success FUSE "cat ipfs/stuff succeeds" ' cat ipfs/$HASH >actual ' -test_expect_success "cat ipfs/stuff looks good" ' +test_expect_success FUSE "cat ipfs/stuff looks good" ' test_cmp expected actual ' @@ -71,11 +71,11 @@ test_expect_success "ipfs cat output looks good" ' test_cmp sha1_expected sha1_actual ' -test_expect_success "cat ipfs/bigfile succeeds" ' +test_expect_success FUSE "cat ipfs/bigfile succeeds" ' cat ipfs/$HASH | shasum >sha1_actual ' -test_expect_success "cat ipfs/bigfile looks good" ' +test_expect_success FUSE "cat ipfs/bigfile looks good" ' test_cmp sha1_expected sha1_actual ' diff --git a/test/test-lib.sh b/test/test-lib.sh index 40e5cc9ab..33b368ee6 100644 --- a/test/test-lib.sh +++ b/test/test-lib.sh @@ -16,6 +16,8 @@ SHARNESS_LIB="./sharness.sh" # Please put go-ipfs specific shell functions below +test "$TEST_NO_FUSE" != 1 && test_set_prereq FUSE + test_cmp_repeat_10_sec() { for i in 1 2 3 4 5 6 7 8 9 10 do @@ -38,11 +40,11 @@ test_launch_ipfs_mount() { ipfs config Mounts.IPNS "$(pwd)/ipns" ' - test_expect_success "ipfs mount succeeds" ' + test_expect_success FUSE "ipfs mount succeeds" ' ipfs mount mountdir >actual & ' - test_expect_success "ipfs mount output looks good" ' + test_expect_success FUSE "ipfs mount output looks good" ' IPFS_PID=$! && echo "mounting ipfs at $(pwd)/ipfs" >expected && echo "mounting ipns at $(pwd)/ipns" >>expected && @@ -52,11 +54,11 @@ test_launch_ipfs_mount() { test_kill_ipfs_mount() { - test_expect_success "ipfs mount is still running" ' + test_expect_success FUSE "ipfs mount is still running" ' kill -0 $IPFS_PID ' - test_expect_success "ipfs mount can be killed" ' + test_expect_success FUSE "ipfs mount can be killed" ' kill $IPFS_PID && sleep 1 && ! kill -0 $IPFS_PID 2>/dev/null From efe4e05665db0327cc6fc12c91fc50fe8c629ab7 Mon Sep 17 00:00:00 2001 From: Juan Batiz-Benet Date: Fri, 7 Nov 2014 14:46:15 -0800 Subject: [PATCH 09/15] added install + tests to toplevel --- Makefile | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/Makefile b/Makefile index a6496bd45..1b6b93e52 100644 --- a/Makefile +++ b/Makefile @@ -9,3 +9,15 @@ godep: # ./... performs operation on all packages in tree vendor: godep godep save -r ./... + + +install: + cd cmd/ipfs && go install + +test: test_go test_sharness + +test_go: + go test ./... + +test_sharness: install + cd test/ && make From 37279d55ca64c1c0e1eb2dea7b51808070efb437 Mon Sep 17 00:00:00 2001 From: Juan Batiz-Benet Date: Fri, 7 Nov 2014 14:50:44 -0800 Subject: [PATCH 10/15] install go-random --- test/Makefile | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/test/Makefile b/test/Makefile index a1cbc8f55..10cd0a4f1 100644 --- a/test/Makefile +++ b/test/Makefile @@ -5,6 +5,7 @@ # T = $(sort $(wildcard t[0-9][0-9][0-9][0-9]-*.sh)) +RANDOM=$(GOPATH)/bin/random all: clean deps $(T) aggregate @@ -20,10 +21,14 @@ aggregate: @echo "*** $@ ***" ./test-aggregate-results.sh -deps: sharness.sh +deps: sharness.sh $(RANDOM) sharness.sh: @echo "*** installing $@ ***" ./install-sharness.sh .PHONY: all clean $(T) aggregate + +$(RANDOM): + go get github.com/jbenet/go-random/random + go install github.com/jbenet/go-random/random From 53c2cacdd09893531e1b526fe8901a5fd99c74a9 Mon Sep 17 00:00:00 2001 From: Juan Batiz-Benet Date: Fri, 7 Nov 2014 14:56:09 -0800 Subject: [PATCH 11/15] travis: use make test --- .travis.yml | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/.travis.yml b/.travis.yml index 7d699a742..117f3bc1d 100644 --- a/.travis.yml +++ b/.travis.yml @@ -6,10 +6,6 @@ go: - tip script: - - go test -v ./... - - cd cmd/ipfs && go install # test it can be compiled - - cd ../../test/ - - make # sharness tests - - cd .. + - make test env: TEST_NO_FUSE=1 From 7e14f1737d146cb45f3d788f229dae9fd964e524 Mon Sep 17 00:00:00 2001 From: Juan Batiz-Benet Date: Fri, 7 Nov 2014 15:14:50 -0800 Subject: [PATCH 12/15] test/: build own ipfs tool to test The tests were using the globally installed ipfs. This commit changes it to build + use its own ipfs binary. --- Makefile | 2 +- test/Makefile | 9 +++++++-- test/t0010-basic-commands.sh | 4 ++-- test/t0020-init.sh | 4 ++-- test/t0040-add-and-cat.sh | 8 ++++---- test/test-lib.sh | 12 ++++++++---- 6 files changed, 24 insertions(+), 15 deletions(-) diff --git a/Makefile b/Makefile index 1b6b93e52..dcb369941 100644 --- a/Makefile +++ b/Makefile @@ -19,5 +19,5 @@ test: test_go test_sharness test_go: go test ./... -test_sharness: install +test_sharness: cd test/ && make diff --git a/test/Makefile b/test/Makefile index 10cd0a4f1..5ed8bca1b 100644 --- a/test/Makefile +++ b/test/Makefile @@ -21,13 +21,18 @@ aggregate: @echo "*** $@ ***" ./test-aggregate-results.sh -deps: sharness.sh $(RANDOM) +deps: ipfs sharness.sh $(RANDOM) + +# phony to ensure we re-build it every time we run tests +ipfs: + cd ../cmd/ipfs && go build + cp ../cmd/ipfs/ipfs ipfs sharness.sh: @echo "*** installing $@ ***" ./install-sharness.sh -.PHONY: all clean $(T) aggregate +.PHONY: all clean $(T) aggregate ipfs $(RANDOM): go get github.com/jbenet/go-random/random diff --git a/test/t0010-basic-commands.sh b/test/t0010-basic-commands.sh index dd63dd2c4..677ef6887 100755 --- a/test/t0010-basic-commands.sh +++ b/test/t0010-basic-commands.sh @@ -13,7 +13,7 @@ test_expect_success "current dir is writable" ' ' test_expect_success "ipfs version succeeds" ' - ipfs version >version.txt + $ipfs version >version.txt ' test_expect_success "ipfs version output looks good" ' @@ -21,7 +21,7 @@ test_expect_success "ipfs version output looks good" ' ' test_expect_success "ipfs help succeeds" ' - ipfs help >help.txt + $ipfs help >help.txt ' test_expect_success "ipfs help output looks good" ' diff --git a/test/t0020-init.sh b/test/t0020-init.sh index 01601420c..20e0f6f4e 100755 --- a/test/t0020-init.sh +++ b/test/t0020-init.sh @@ -10,7 +10,7 @@ test_description="Test init command" test_expect_success "ipfs init succeeds" ' export IPFS_DIR="$(pwd)/.go-ipfs" && - ipfs init + $ipfs init ' test_expect_success ".go-ipfs/ has been created" ' @@ -21,7 +21,7 @@ test_expect_success ".go-ipfs/ has been created" ' test_expect_success "ipfs config succeeds" ' echo leveldb >expected && - ipfs config Datastore.Type >actual && + $ipfs config Datastore.Type >actual && test_cmp expected actual ' diff --git a/test/t0040-add-and-cat.sh b/test/t0040-add-and-cat.sh index 3091afc2e..2a45cac01 100755 --- a/test/t0040-add-and-cat.sh +++ b/test/t0040-add-and-cat.sh @@ -12,7 +12,7 @@ test_launch_ipfs_mount test_expect_success "ipfs add succeeds" ' echo "Hello Worlds!" >mountdir/hello.txt && - ipfs add mountdir/hello.txt >actual + $ipfs add mountdir/hello.txt >actual ' test_expect_success "ipfs add output looks good" ' @@ -22,7 +22,7 @@ test_expect_success "ipfs add output looks good" ' ' test_expect_success "ipfs cat succeeds" ' - ipfs cat $HASH >actual + $ipfs cat $HASH >actual ' test_expect_success "ipfs cat output looks good" ' @@ -53,7 +53,7 @@ test_expect_success "sha1 of the file looks ok" ' ' test_expect_success "ipfs add bigfile succeeds" ' - ipfs add mountdir/bigfile >actual + $ipfs add mountdir/bigfile >actual ' test_expect_success "ipfs add bigfile output looks good" ' @@ -63,7 +63,7 @@ test_expect_success "ipfs add bigfile output looks good" ' ' test_expect_success "ipfs cat succeeds" ' - ipfs cat $HASH | shasum >sha1_actual + $ipfs cat $HASH | shasum >sha1_actual ' test_expect_success "ipfs cat output looks good" ' diff --git a/test/test-lib.sh b/test/test-lib.sh index 33b368ee6..804f53daa 100644 --- a/test/test-lib.sh +++ b/test/test-lib.sh @@ -8,6 +8,10 @@ SHARNESS_LIB="./sharness.sh" +# the ipfs tool to test against +# ../ipfs because it will be one level above during test exec +ipfs="../ipfs" + . "$SHARNESS_LIB" || { echo >&2 "Cannot source: $SHARNESS_LIB" echo >&2 "Please check Sharness installation." @@ -31,17 +35,17 @@ test_launch_ipfs_mount() { test_expect_success "ipfs init succeeds" ' export IPFS_DIR="$(pwd)/.go-ipfs" && - ipfs init -b=2048 + $ipfs init -b=2048 ' test_expect_success "prepare config" ' mkdir mountdir ipfs ipns && - ipfs config Mounts.IPFS "$(pwd)/ipfs" && - ipfs config Mounts.IPNS "$(pwd)/ipns" + $ipfs config Mounts.IPFS "$(pwd)/ipfs" && + $ipfs config Mounts.IPNS "$(pwd)/ipns" ' test_expect_success FUSE "ipfs mount succeeds" ' - ipfs mount mountdir >actual & + $ipfs mount mountdir >actual & ' test_expect_success FUSE "ipfs mount output looks good" ' From 7ab38696f692fc124574495e97eb264564e0a02e Mon Sep 17 00:00:00 2001 From: Juan Batiz-Benet Date: Fri, 7 Nov 2014 15:24:31 -0800 Subject: [PATCH 13/15] travis: fix install random error --- test/Makefile | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/test/Makefile b/test/Makefile index 5ed8bca1b..1b89b405e 100644 --- a/test/Makefile +++ b/test/Makefile @@ -5,7 +5,7 @@ # T = $(sort $(wildcard t[0-9][0-9][0-9][0-9]-*.sh)) -RANDOM=$(GOPATH)/bin/random +RANDOM=${GOPATH}/bin/random all: clean deps $(T) aggregate @@ -21,7 +21,7 @@ aggregate: @echo "*** $@ ***" ./test-aggregate-results.sh -deps: ipfs sharness.sh $(RANDOM) +deps: ipfs sharness.sh ${RANDOM} # phony to ensure we re-build it every time we run tests ipfs: @@ -34,6 +34,7 @@ sharness.sh: .PHONY: all clean $(T) aggregate ipfs -$(RANDOM): +${RANDOM}: + @echo "*** installing $@ ***" go get github.com/jbenet/go-random/random go install github.com/jbenet/go-random/random From c9ffe1a281088d633c7878909a53fdd63f1a81c5 Mon Sep 17 00:00:00 2001 From: Juan Batiz-Benet Date: Fri, 7 Nov 2014 16:24:40 -0800 Subject: [PATCH 14/15] tests: use `ipfs` but with the right tool Addresses comments in: https://github.com/jbenet/go-ipfs/commit/7e14f1737d146cb45f3d788f229dae9fd964e524 --- test/t0010-basic-commands.sh | 4 ++-- test/t0020-init.sh | 4 ++-- test/t0040-add-and-cat.sh | 8 ++++---- test/test-lib.sh | 24 ++++++++++++++++-------- 4 files changed, 24 insertions(+), 16 deletions(-) diff --git a/test/t0010-basic-commands.sh b/test/t0010-basic-commands.sh index 677ef6887..dd63dd2c4 100755 --- a/test/t0010-basic-commands.sh +++ b/test/t0010-basic-commands.sh @@ -13,7 +13,7 @@ test_expect_success "current dir is writable" ' ' test_expect_success "ipfs version succeeds" ' - $ipfs version >version.txt + ipfs version >version.txt ' test_expect_success "ipfs version output looks good" ' @@ -21,7 +21,7 @@ test_expect_success "ipfs version output looks good" ' ' test_expect_success "ipfs help succeeds" ' - $ipfs help >help.txt + ipfs help >help.txt ' test_expect_success "ipfs help output looks good" ' diff --git a/test/t0020-init.sh b/test/t0020-init.sh index 20e0f6f4e..01601420c 100755 --- a/test/t0020-init.sh +++ b/test/t0020-init.sh @@ -10,7 +10,7 @@ test_description="Test init command" test_expect_success "ipfs init succeeds" ' export IPFS_DIR="$(pwd)/.go-ipfs" && - $ipfs init + ipfs init ' test_expect_success ".go-ipfs/ has been created" ' @@ -21,7 +21,7 @@ test_expect_success ".go-ipfs/ has been created" ' test_expect_success "ipfs config succeeds" ' echo leveldb >expected && - $ipfs config Datastore.Type >actual && + ipfs config Datastore.Type >actual && test_cmp expected actual ' diff --git a/test/t0040-add-and-cat.sh b/test/t0040-add-and-cat.sh index 2a45cac01..3091afc2e 100755 --- a/test/t0040-add-and-cat.sh +++ b/test/t0040-add-and-cat.sh @@ -12,7 +12,7 @@ test_launch_ipfs_mount test_expect_success "ipfs add succeeds" ' echo "Hello Worlds!" >mountdir/hello.txt && - $ipfs add mountdir/hello.txt >actual + ipfs add mountdir/hello.txt >actual ' test_expect_success "ipfs add output looks good" ' @@ -22,7 +22,7 @@ test_expect_success "ipfs add output looks good" ' ' test_expect_success "ipfs cat succeeds" ' - $ipfs cat $HASH >actual + ipfs cat $HASH >actual ' test_expect_success "ipfs cat output looks good" ' @@ -53,7 +53,7 @@ test_expect_success "sha1 of the file looks ok" ' ' test_expect_success "ipfs add bigfile succeeds" ' - $ipfs add mountdir/bigfile >actual + ipfs add mountdir/bigfile >actual ' test_expect_success "ipfs add bigfile output looks good" ' @@ -63,7 +63,7 @@ test_expect_success "ipfs add bigfile output looks good" ' ' test_expect_success "ipfs cat succeeds" ' - $ipfs cat $HASH | shasum >sha1_actual + ipfs cat $HASH | shasum >sha1_actual ' test_expect_success "ipfs cat output looks good" ' diff --git a/test/test-lib.sh b/test/test-lib.sh index 804f53daa..d9c19395f 100644 --- a/test/test-lib.sh +++ b/test/test-lib.sh @@ -6,11 +6,19 @@ # We are using sharness (https://github.com/mlafeldt/sharness) # which was extracted from the Git test framework. -SHARNESS_LIB="./sharness.sh" +# use the ipfs tool to test against -# the ipfs tool to test against -# ../ipfs because it will be one level above during test exec -ipfs="../ipfs" +# add current directory to path, for ipfs tool. +PATH=$(pwd):${PATH} + +# assert the `ipfs` we're using is the right one. +if test `which ipfs` != $(pwd)/ipfs; then + echo >&2 "Cannot find the tests' local ipfs tool." + echo >&2 "Please check test and ipfs tool installation." + exit 1 +fi + +SHARNESS_LIB="./sharness.sh" . "$SHARNESS_LIB" || { echo >&2 "Cannot source: $SHARNESS_LIB" @@ -35,17 +43,17 @@ test_launch_ipfs_mount() { test_expect_success "ipfs init succeeds" ' export IPFS_DIR="$(pwd)/.go-ipfs" && - $ipfs init -b=2048 + ipfs init -b=2048 ' test_expect_success "prepare config" ' mkdir mountdir ipfs ipns && - $ipfs config Mounts.IPFS "$(pwd)/ipfs" && - $ipfs config Mounts.IPNS "$(pwd)/ipns" + ipfs config Mounts.IPFS "$(pwd)/ipfs" && + ipfs config Mounts.IPNS "$(pwd)/ipns" ' test_expect_success FUSE "ipfs mount succeeds" ' - $ipfs mount mountdir >actual & + ipfs mount mountdir >actual & ' test_expect_success FUSE "ipfs mount output looks good" ' From 04efbb9a5526d71ed7dcd30b04983f9753db7821 Mon Sep 17 00:00:00 2001 From: Juan Batiz-Benet Date: Fri, 7 Nov 2014 16:33:53 -0800 Subject: [PATCH 15/15] test: install random locally for travis. --- test/Makefile | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/test/Makefile b/test/Makefile index 1b89b405e..85be73662 100644 --- a/test/Makefile +++ b/test/Makefile @@ -5,7 +5,6 @@ # T = $(sort $(wildcard t[0-9][0-9][0-9][0-9]-*.sh)) -RANDOM=${GOPATH}/bin/random all: clean deps $(T) aggregate @@ -21,7 +20,7 @@ aggregate: @echo "*** $@ ***" ./test-aggregate-results.sh -deps: ipfs sharness.sh ${RANDOM} +deps: ipfs sharness.sh random # phony to ensure we re-build it every time we run tests ipfs: @@ -34,7 +33,8 @@ sharness.sh: .PHONY: all clean $(T) aggregate ipfs -${RANDOM}: +random: @echo "*** installing $@ ***" go get github.com/jbenet/go-random/random go install github.com/jbenet/go-random/random + cp `which random` random