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 #201

Closed
wants to merge 2 commits into from
Closed
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
28 changes: 28 additions & 0 deletions test/t0010-basic-commands.sh
Original file line number Diff line number Diff line change
@@ -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

33 changes: 33 additions & 0 deletions test/test-lib.sh
Original file line number Diff line number Diff line change
@@ -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