tendermint/tests/test_cli/test.sh

42 lines
821 B
Bash
Raw Normal View History

2016-07-23 15:54:58 -07:00
#! /bin/bash
# Get the root directory.
SOURCE="${BASH_SOURCE[0]}"
while [ -h "$SOURCE" ] ; do SOURCE="$(readlink "$SOURCE")"; done
DIR="$( cd -P "$( dirname "$SOURCE" )/../.." && pwd )"
# Change into that dir because we expect that.
cd "$DIR" || exit
2017-01-12 12:47:55 -08:00
2016-07-23 15:54:58 -07:00
function testExample() {
N=$1
INPUT=$2
2017-10-18 12:32:34 -07:00
APP="$3 $4"
2016-07-23 15:54:58 -07:00
2017-10-18 12:32:34 -07:00
echo "Example $N: $APP"
2016-07-23 15:54:58 -07:00
$APP &> /dev/null &
sleep 2
abci-cli --verbose batch < "$INPUT" > "${INPUT}.out.new"
2017-11-14 10:53:40 -08:00
killall "$3"
2016-07-23 15:54:58 -07:00
pre=$(shasum < "${INPUT}.out")
post=$(shasum < "${INPUT}.out.new")
2016-07-23 15:54:58 -07:00
if [[ "$pre" != "$post" ]]; then
echo "You broke the tutorial"
echo "Got:"
2016-09-10 17:10:59 -07:00
cat "${INPUT}.out.new"
echo "Expected:"
2016-09-10 17:10:59 -07:00
cat "${INPUT}.out"
2016-07-23 15:54:58 -07:00
exit 1
fi
rm "${INPUT}".out.new
}
2017-10-18 12:32:34 -07:00
testExample 1 tests/test_cli/ex1.abci abci-cli dummy
testExample 2 tests/test_cli/ex2.abci abci-cli counter
2016-07-23 15:54:58 -07:00
echo ""
echo "PASS"