refactor test script
- fix status code (script exited with success even with failing tests) - clean up and explain things
This commit is contained in:
@ -1,10 +1,24 @@
|
|||||||
#! /bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
output=$(nc -z localhost 8545; echo $?)
|
# Executes cleanup function at script exit.
|
||||||
[ $output -eq "0" ] && trpc_running=true
|
trap cleanup EXIT
|
||||||
if [ ! $trpc_running ]; then
|
|
||||||
echo "Starting our own testrpc node instance"
|
cleanup() {
|
||||||
# we give each account 1M ether, needed for high-value tests
|
# Kill the testrpc instance that we started (if we started one).
|
||||||
|
if [ -n "$testrpc_pid" ]; then
|
||||||
|
kill -9 $testrpc_pid
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
testrpc_running() {
|
||||||
|
nc -z localhost 8545
|
||||||
|
}
|
||||||
|
|
||||||
|
if testrpc_running; then
|
||||||
|
echo "Using existing testrpc instance"
|
||||||
|
else
|
||||||
|
echo "Starting our own testrpc instance"
|
||||||
|
# We define 10 accounts with balance 1M ether, needed for high-value tests.
|
||||||
testrpc \
|
testrpc \
|
||||||
--account="0x2bdd21761a483f71054e14f5b827213567971c676928d9a1808cbfa4b7501200,1000000000000000000000000" \
|
--account="0x2bdd21761a483f71054e14f5b827213567971c676928d9a1808cbfa4b7501200,1000000000000000000000000" \
|
||||||
--account="0x2bdd21761a483f71054e14f5b827213567971c676928d9a1808cbfa4b7501201,1000000000000000000000000" \
|
--account="0x2bdd21761a483f71054e14f5b827213567971c676928d9a1808cbfa4b7501201,1000000000000000000000000" \
|
||||||
@ -17,9 +31,7 @@ if [ ! $trpc_running ]; then
|
|||||||
--account="0x2bdd21761a483f71054e14f5b827213567971c676928d9a1808cbfa4b7501208,1000000000000000000000000" \
|
--account="0x2bdd21761a483f71054e14f5b827213567971c676928d9a1808cbfa4b7501208,1000000000000000000000000" \
|
||||||
--account="0x2bdd21761a483f71054e14f5b827213567971c676928d9a1808cbfa4b7501209,1000000000000000000000000" \
|
--account="0x2bdd21761a483f71054e14f5b827213567971c676928d9a1808cbfa4b7501209,1000000000000000000000000" \
|
||||||
> /dev/null &
|
> /dev/null &
|
||||||
trpc_pid=$!
|
testrpc_pid=$!
|
||||||
fi
|
|
||||||
./node_modules/truffle/cli.js test "$@"
|
|
||||||
if [ ! $trpc_running ]; then
|
|
||||||
kill -9 $trpc_pid
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
node_modules/.bin/truffle test "$@"
|
||||||
|
|||||||
Reference in New Issue
Block a user