From 1fa6e7f3b100760d788f0bbb15e178ca33f45130 Mon Sep 17 00:00:00 2001 From: Ethan Buchman Date: Mon, 20 Feb 2017 18:51:00 -0500 Subject: [PATCH] test: shellcheck --- test/persist/test.sh | 2 +- test/persist/test_failure_indices.sh | 38 ++++++++++++++-------------- test/run_test.sh | 4 +-- test/test_cover.sh | 2 +- test/test_libs.sh | 12 ++++----- 5 files changed, 29 insertions(+), 29 deletions(-) diff --git a/test/persist/test.sh b/test/persist/test.sh index b27394c51..e24e81deb 100644 --- a/test/persist/test.sh +++ b/test/persist/test.sh @@ -1,5 +1,5 @@ #! /bin/bash -cd $GOPATH/src/github.com/tendermint/tendermint +cd "$GOPATH/src/github.com/tendermint/tendermint" bash ./test/persist/test_failure_indices.sh diff --git a/test/persist/test_failure_indices.sh b/test/persist/test_failure_indices.sh index b24412352..8feb0005c 100644 --- a/test/persist/test_failure_indices.sh +++ b/test/persist/test_failure_indices.sh @@ -3,7 +3,7 @@ export TMROOT=$HOME/.tendermint_persist -rm -rf $TMROOT +rm -rf "$TMROOT" tendermint init TM_CMD="tendermint node --log_level=debug" # &> tendermint_${name}.log" @@ -40,9 +40,9 @@ function start_procs(){ } function kill_procs(){ - kill -9 $PID_DUMMY $PID_TENDERMINT - wait $PID_DUMMY - wait $PID_TENDERMINT + kill -9 "$PID_DUMMY" "$PID_TENDERMINT" + wait "$PID_DUMMY" + wait "$PID_TENDERMINT" } @@ -59,10 +59,10 @@ function send_txs(){ # send a bunch of txs over a few blocks echo "Node is up, sending txs" - for i in `seq 1 5`; do - for j in `seq 1 100`; do - tx=`head -c 8 /dev/urandom | hexdump -ve '1/1 "%.2X"'` - curl -s $addr/broadcast_tx_async?tx=0x$tx &> /dev/null + for i in $(seq 1 5); do + for _ in $(seq 1 100); do + tx=$(head -c 8 /dev/urandom | hexdump -ve '1/1 "%.2X"') + curl -s "$addr/broadcast_tx_async?tx=0x$tx" &> /dev/null done sleep 1 done @@ -70,33 +70,33 @@ function send_txs(){ failsStart=0 -fails=`grep -r "fail.Fail" --include \*.go . | wc -l` -failsEnd=$(($fails-1)) +fails=$(grep -r "fail.Fail" --include \*.go . | wc -l) +failsEnd=$((fails-1)) -for failIndex in `seq $failsStart $failsEnd`; do +for failIndex in $(seq $failsStart $failsEnd); do echo "" echo "* Test FailIndex $failIndex" # test failure at failIndex send_txs & - start_procs 1 $failIndex + start_procs 1 "$failIndex" # tendermint should fail when it hits the fail index - kill -9 $PID_DUMMY - wait $PID_DUMMY + kill -9 "$PID_DUMMY" + wait "$PID_DUMMY" start_procs 2 # wait for node to handshake and make a new block addr="localhost:46657" - curl -s $addr/status > /dev/null + curl -s "$addr/status" > /dev/null ERR=$? i=0 while [ "$ERR" != 0 ]; do sleep 1 - curl -s $addr/status > /dev/null + curl -s "$addr/status" > /dev/null ERR=$? - i=$(($i + 1)) + i=$((i + 1)) if [[ $i == 10 ]]; then echo "Timed out waiting for tendermint to start" exit 1 @@ -104,11 +104,11 @@ for failIndex in `seq $failsStart $failsEnd`; do done # wait for a new block - h1=`curl -s $addr/status | jq .result[1].latest_block_height` + h1=$(curl -s $addr/status | jq .result[1].latest_block_height) h2=$h1 while [ "$h2" == "$h1" ]; do sleep 1 - h2=`curl -s $addr/status | jq .result[1].latest_block_height` + h2=$(curl -s $addr/status | jq .result[1].latest_block_height) done kill_procs diff --git a/test/run_test.sh b/test/run_test.sh index ba4e1b0e4..fcc82d984 100644 --- a/test/run_test.sh +++ b/test/run_test.sh @@ -1,9 +1,9 @@ #! /bin/bash set -e -echo `pwd` +pwd -BRANCH=`git rev-parse --abbrev-ref HEAD` +BRANCH=$(git rev-parse --abbrev-ref HEAD) echo "Current branch: $BRANCH" bash test/test_cover.sh diff --git a/test/test_cover.sh b/test/test_cover.sh index 60c84284d..b1b754ba4 100644 --- a/test/test_cover.sh +++ b/test/test_cover.sh @@ -5,7 +5,7 @@ PKGS=$(go list github.com/tendermint/tendermint/... | grep -v /vendor/) set -e echo "mode: atomic" > coverage.txt for pkg in ${PKGS[@]}; do - go test -v -timeout 30m -race -coverprofile=profile.out -covermode=atomic $pkg + go test -v -timeout 30m -race -coverprofile=profile.out -covermode=atomic "$pkg" if [ -f profile.out ]; then tail -n +2 profile.out >> coverage.txt; rm profile.out diff --git a/test/test_libs.sh b/test/test_libs.sh index 28ec07980..4a531bf35 100644 --- a/test/test_libs.sh +++ b/test/test_libs.sh @@ -18,30 +18,30 @@ LIBS_MAKE_TEST=(go-rpc go-wire abci) for lib in "${LIBS_GO_TEST[@]}"; do # checkout vendored version of lib - bash scripts/glide/checkout.sh $GLIDE $lib + bash scripts/glide/checkout.sh "$GLIDE" "$lib" echo "Testing $lib ..." - go test -v --race github.com/tendermint/$lib/... + go test -v --race "github.com/tendermint/$lib/..." if [[ "$?" != 0 ]]; then echo "FAIL" exit 1 fi done -DIR=`pwd` +DIR=$(pwd) for lib in "${LIBS_MAKE_TEST[@]}"; do # checkout vendored version of lib - bash scripts/glide/checkout.sh $GLIDE $lib + bash scripts/glide/checkout.sh "$GLIDE" "$lib" echo "Testing $lib ..." - cd $GOPATH/src/github.com/tendermint/$lib + cd "$GOPATH/src/github.com/tendermint/$lib" make test if [[ "$?" != 0 ]]; then echo "FAIL" exit 1 fi - cd $DIR + cd "$DIR" done echo ""