Skip to content
This repository has been archived by the owner on Dec 16, 2021. It is now read-only.

feat: new test timeout option #71

Merged
merged 3 commits into from
Sep 4, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 45 additions & 1 deletion bin/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ Usage: test <seed> [options]
--dpns-tld-identity-private-key=private_key - top level identity private key
--dpns-tld-identity-id=identity_id - top level identity id
--dpns-contract-id=contract_id - dpns contract id
-t --timeout - test timeout in milliseconds
-h --help - show help

Possible scopes:
Expand Down Expand Up @@ -63,6 +64,9 @@ case ${i} in
--dpns-contract-id=*)
contract_id="${i#*=}"
;;
-t=*|--timeout=*)
timeout="${i#*=}"
;;
esac
done

Expand All @@ -74,6 +78,12 @@ then
exit 1
fi

if [ -n "$timeout" ] && ! [[ $timeout =~ ^[0-9]+$ ]]
then
echo "Timeout must be an integer"
exit 1
fi

if [ -n "$npm_package_to_install" ]
then
npm install "$npm_package_to_install"
Expand Down Expand Up @@ -122,4 +132,38 @@ else
scope_dirs="test/functional/**/*.spec.js test/e2e/**/*.spec.js"
fi

DAPI_SEED=${DAPI_SEED} FAUCET_PRIVATE_KEY=${faucet_key} NETWORK=${network} DPNS_CONTRACT_ID=${contract_id} DPNS_TOP_LEVEL_IDENTITY_ID=${identity_id} DPNS_TOP_LEVEL_IDENTITY_PRIVATE_KEY=${identity_private_key} NODE_ENV=test mocha ${scope_dirs}
cmd="DAPI_SEED=${DAPI_SEED}"

if [ -n "$faucet_key" ]
then
cmd="${cmd} FAUCET_PRIVATE_KEY=${faucet_key}"
fi

if [ -n "$network" ]
then
cmd="${cmd} NETWORK=${network}"
fi

if [ -n "$contract_id" ]
then
cmd="${cmd} DPNS_CONTRACT_ID=${contract_id}"
fi

if [ -n "$identity_id" ]
then
cmd="${cmd} DPNS_TOP_LEVEL_IDENTITY_ID=${identity_id}"
fi

if [ -n "$identity_private_key" ]
then
cmd="${cmd} DPNS_TOP_LEVEL_IDENTITY_PRIVATE_KEY=${identity_private_key}"
fi

cmd="${cmd} NODE_ENV=test mocha ${scope_dirs}"

if [ -n "$timeout" ]
then
cmd="${cmd} --timeout ${timeout}"
fi

eval $cmd