Commit 39c1930e authored by Juan Batiz-Benet's avatar Juan Batiz-Benet

Merge pull request #274 from jbenet/install-sharness

Install sharness + add to tests to coverage
parents 350b8333 04efbb9a
......@@ -6,6 +6,6 @@ go:
- tip
script:
- go test -v ./...
- make test
env: TEST_NO_FUSE=1
......@@ -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:
cd test/ && make
......@@ -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)
......
......@@ -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,21 @@ aggregate:
@echo "*** $@ ***"
./test-aggregate-results.sh
.PHONY: all clean $(T) aggregate
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 ipfs
random:
@echo "*** installing $@ ***"
go get github.com/jbenet/go-random/random
go install github.com/jbenet/go-random/random
cp `which random` random
#!/bin/sh
# install sharness.sh
#
# Copyright (c) 2014 Juan Batiz-Benet
# MIT Licensed; see the LICENSE file in this repository.
#
# settings
version=50229a79ba22b2f13ccd82451d86570fecbd194c
urlprefix=https://raw.githubusercontent.com/mlafeldt/sharness/$version
# files to download
sfile=sharness.sh
shash=eeaf96630fc25ec58fb678b64ef9772d5eb92f64
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 things into place
mv $sfile.test $sfile
mv $afile.test $afile
chmod +x $sfile
chmod +x $afile
exit 0
......@@ -8,6 +8,13 @@ test_description="Test mount command"
. ./test-lib.sh
# if in travis CI, dont test mount (no fuse)
if ! test_have_prereq FUSE; then
skip_all='skipping mount tests, fuse not available'
test_done
fi
test_launch_ipfs_mount
test_kill_ipfs_mount
......
......@@ -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
'
......
......@@ -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"
......
......@@ -6,7 +6,19 @@
# We are using sharness (https://github.com/mlafeldt/sharness)
# which was extracted from the Git test framework.
. ./test-sharness-config.sh
# use the ipfs tool to test against
# 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"
......@@ -16,6 +28,8 @@
# 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 +52,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 +66,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
......
# 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
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment