Skip to content

Commit

Permalink
Add a Makefile and fix up binary tests
Browse files Browse the repository at this point in the history
  • Loading branch information
bcl authored and atodorov committed Jul 3, 2017
1 parent 8444684 commit 38a4d26
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 3 deletions.
29 changes: 29 additions & 0 deletions Makefile
@@ -0,0 +1,29 @@
default: all

all: bdcs-cli

sandbox:
[ -d .cabal-sandbox ] || cabal sandbox init

bdcs-cli: sandbox
cabal update
cabal install --dependencies-only
cabal configure
cabal build

clean:
cabal clean

hlint: sandbox
[ -x .cabal-sandbox/bin/happy ] || cabal install happy
[ -x .cabal-sandbox/bin/hlint ] || cabal install hlint
cabal exec hlint .

tests: sandbox
cabal install --dependencies-only --enable-tests
cabal configure --enable-tests --enable-coverage
cabal build
cabal test
./tests/test_binary.sh

.PHONY: sandbox bdcs-cli clean test hlint
11 changes: 8 additions & 3 deletions tests/test_binary.sh
Expand Up @@ -6,16 +6,21 @@ set -x
bdcscli="./dist/build/bdcs-cli/bdcs-cli"

# When called without parameters returns Unknown Command
if [[ `$bdcscli` != "Unknown Command" ]]; then
if [[ $($bdcscli 2>&1 | head -n 1) != "Usage: bdcs-cli [OPTIONS...] commands..." ]]; then
exit 1
fi

# --help option is not recognized
if [[ `$bdcscli --help 2>&1 | head -n 1` != "bdcs-cli: user error (unrecognized option \`--help'" ]]; then
if [[ $($bdcscli --help 2>&1 | head -n 1) != "bdcs-cli: user error (unrecognized option \`--help'" ]]; then
exit 1
fi

# -? returns version only
if [[ `$bdcscli -? | cut -f1 -d' '` != "bdcs-cli" ]]; then
if [[ $($bdcscli -? | head -n 1 | cut -f1 -d' ') != "bdcs-cli" ]]; then
exit 1
fi

# bdcs-cli help returns the help text
if [[ $($bdcscli help 2>&1 | wc -l) != "21" ]]; then
exit 1
fi

0 comments on commit 38a4d26

Please sign in to comment.