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

Use Sharness as our shell test framework, version 2 #204

Merged
merged 5 commits into from
Oct 25, 2014
Merged
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
20 changes: 20 additions & 0 deletions test/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Run tests
#
# Copyright (c) 2014 Christian Couder
# MIT Licensed; see the LICENSE file in this repository.
#

T = $(sort $(wildcard t[0-9][0-9][0-9][0-9]-*.sh))

all: clean $(T) aggregate

clean:
-rm -r test-results

$(T):
@echo "*** $@ ***"; ./$@

aggregate:
./test-aggregate-results.sh

.PHONY: all clean $(T) aggregate
32 changes: 32 additions & 0 deletions test/t0010-basic-commands.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
#!/bin/sh
#
# Copyright (c) 2014 Christian Couder
# MIT Licensed; see the LICENSE file in this repository.
#

test_description="Test installation and some basic commands"

. ./test-lib.sh

test_expect_success "current dir is writable" '
echo "It works!" >test.txt
'

test_expect_success "ipfs version succeeds" '
ipfs version >version.txt
'

test_expect_success "ipfs version output looks good" '
cat version.txt | egrep "^ipfs version [0-9]+\.[0-9]+\.[0-9]"
'

test_expect_success "ipfs help succeeds" '
ipfs help >help.txt
'

test_expect_success "ipfs help output looks good" '
cat help.txt | egrep "^Usage: +ipfs"
'

test_done

19 changes: 19 additions & 0 deletions test/test-aggregate-results.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#!/bin/sh
#
# Script to aggregate results using Sharness
#
# Copyright (c) 2014 Christian Couder
# MIT Licensed; see the LICENSE file in this repository.
#

. ./test-sharness-config.sh

SHARNESS_AGGREGATE="$SHARNESS_DIRECTORY/aggregate-results.sh"

test -f "$SHARNESS_AGGREGATE" || {
echo >&2 "Cannot find: $SHARNESS_AGGREGATE"
echo >&2 "Please check Sharness installation."
exit 1
}

ls test-results/t*-*.sh.*.counts | "$SHARNESS_AGGREGATE"
18 changes: 18 additions & 0 deletions test/test-lib.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Test framework for go-ipfs
#
# 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.

. ./test-sharness-config.sh

. "$SHARNESS_LIB" || {
echo >&2 "Cannot source: $SHARNESS_LIB"
echo >&2 "Please check Sharness installation."
exit 1
}

# Please put go-ipfs specific shell functions below

23 changes: 23 additions & 0 deletions test/test-sharness-config.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# 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
}