From 495928de002d2cd487e34370ce88fe805a659877 Mon Sep 17 00:00:00 2001 From: Christian Couder Date: Fri, 24 Oct 2014 21:23:02 +0200 Subject: [PATCH 1/2] Add test-lib.sh for our shell test framework Our test framework is based on Sharness. So the first thing to do is to source it. --- test/test-lib.sh | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 test/test-lib.sh diff --git a/test/test-lib.sh b/test/test-lib.sh new file mode 100644 index 00000000000..149a3d583ed --- /dev/null +++ b/test/test-lib.sh @@ -0,0 +1,33 @@ +# Test framework for go-ipfs +# +# Copyright (c) 2014 Christian Couder +# +# 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 SHARNESS_DIRECTORY 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 +} + +. "$SHARNESS_LIB" || { + echo >&2 "Cannot source: $SHARNESS_LIB" + echo >&2 "Please check Sharness installation." + exit 1 +} + +# Please put go-ipfs specific shell functions below + From 4ee6f55ae3832e62958bba102ccbae498a7c0eb9 Mon Sep 17 00:00:00 2001 From: Christian Couder Date: Sat, 25 Oct 2014 09:58:41 +0200 Subject: [PATCH 2/2] Add t0010-basic-commands.sh This checks a little bit the installation and some basic commands. You can run it like that: $ cd test $ ./t0010-basic-commands.sh ok 1 - current dir is writable ok 2 - ipfs version succeeds ok 3 - ipfs version output looks good ok 4 - ipfs help succeeds ok 5 - ipfs help output looks good # passed all 5 test(s) 1..5 --- test/t0010-basic-commands.sh | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100755 test/t0010-basic-commands.sh diff --git a/test/t0010-basic-commands.sh b/test/t0010-basic-commands.sh new file mode 100755 index 00000000000..7d378383526 --- /dev/null +++ b/test/t0010-basic-commands.sh @@ -0,0 +1,28 @@ +#!/bin/sh + +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 +