From c165f65461b53d79ca47d53535d7c64b0cbf2e18 Mon Sep 17 00:00:00 2001 From: Konstantin Shuplenkov Date: Fri, 4 Sep 2020 20:02:48 +0300 Subject: [PATCH] feat: new test timeout option (#71) --- bin/test.sh | 46 +++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 45 insertions(+), 1 deletion(-) diff --git a/bin/test.sh b/bin/test.sh index f5fda07..a5ff676 100755 --- a/bin/test.sh +++ b/bin/test.sh @@ -16,6 +16,7 @@ Usage: test [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: @@ -63,6 +64,9 @@ case ${i} in --dpns-contract-id=*) contract_id="${i#*=}" ;; + -t=*|--timeout=*) + timeout="${i#*=}" + ;; esac done @@ -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" @@ -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