tendermint/tests/test_cli/test.sh

43 lines
848 B
Bash
Raw Normal View History

2016-07-23 15:54:58 -07:00
#! /bin/bash
2017-11-27 23:24:17 -08:00
set -e
2016-07-23 15:54:58 -07:00
# 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
APP="$3 $4"
echo "Example $N: $APP"
$APP &> /dev/null &
sleep 2
abci-cli --log_level=error --verbose batch < "$INPUT" > "${INPUT}.out.new"
killall "$3"
pre=$(shasum < "${INPUT}.out")
post=$(shasum < "${INPUT}.out.new")
if [[ "$pre" != "$post" ]]; then
echo "You broke the tutorial"
echo "Got:"
cat "${INPUT}.out.new"
echo "Expected:"
cat "${INPUT}.out"
exit 1
fi
rm "${INPUT}".out.new
2016-07-23 15:54:58 -07:00
}
2018-02-19 12:43:36 -08:00
testExample 1 tests/test_cli/ex1.abci abci-cli kvstore
2017-10-18 12:32:34 -07:00
testExample 2 tests/test_cli/ex2.abci abci-cli counter
2016-07-23 15:54:58 -07:00
echo ""
echo "PASS"