Skip to content

Commit

Permalink
externalTests: Use fail() function to simplify error checks
Browse files Browse the repository at this point in the history
  • Loading branch information
cameel committed Dec 10, 2021
1 parent b14a674 commit 0edbd90
Showing 1 changed file with 4 additions and 14 deletions.
18 changes: 4 additions & 14 deletions test/externalTests/common.sh
Original file line number Diff line number Diff line change
Expand Up @@ -35,18 +35,12 @@ function print_optimizer_levels_or_exit

function verify_input
{
if [ ! -f "$1" ]; then
printError "Usage: $0 <path to soljson.js>"
exit 1
fi
[[ -f "$1" ]] || fail "Usage: $0 <path to soljson.js>"
}

function verify_version_input
{
if [ -z "$1" ] || [ ! -f "$1" ] || [ -z "$2" ]; then
printError "Usage: $0 <path to soljson.js> <version>"
exit 1
fi
[[ $1 != "" && -f "$1" && $2 != "" ]] || fail "Usage: $0 <path to soljson.js> <version>"
}

function setup
Expand Down Expand Up @@ -248,8 +242,7 @@ function optimizer_settings_for_level
2) echo "{enabled: true}" ;;
3) echo "{enabled: true, details: {yul: true}}" ;;
*)
printError "Optimizer level not found. Please define OPTIMIZER_LEVEL=[1, 2, 3]"
exit 1
fail "Optimizer level not found. Please define OPTIMIZER_LEVEL=[1, 2, 3]"
;;
esac
}
Expand Down Expand Up @@ -356,10 +349,7 @@ function external_test
echo "==========================="
DIR=$(mktemp -d -t "ext-test-${name}-XXXXXX")
(
if [ -z "$main_fn" ]; then
printError "Test main function not defined."
exit 1
fi
[[ "$main_fn" != "" ]] || fail "Test main function not defined."
$main_fn
)
rm -rf "$DIR"
Expand Down

0 comments on commit 0edbd90

Please sign in to comment.