From 4ca59b2496725c6b45904ce5d5d852e5703adc36 Mon Sep 17 00:00:00 2001 From: Xiretza Date: Tue, 27 Apr 2021 18:15:20 +0200 Subject: testsuite: add die() function --- testsuite/testsuite.sh | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'testsuite') diff --git a/testsuite/testsuite.sh b/testsuite/testsuite.sh index 947cc7d6f..4c454d35c 100755 --- a/testsuite/testsuite.sh +++ b/testsuite/testsuite.sh @@ -19,6 +19,11 @@ enable_color() { disable_color() { unset ENABLECOLOR ANSI_RED ANSI_GREEN ANSI_YELLOW ANSI_BLUE ANSI_MAGENTA ANSI_CYAN ANSI_DARKCYAN ANSI_NOCOLOR; } enable_color +die() { + printf "${ANSI_RED}%s${ANSI_NOCOLOR}\n" "$@" >&2 + exit 1 +} + print_start() { COL="$ANSI_YELLOW" if [ "x$2" != "x" ]; then @@ -78,8 +83,7 @@ if [ "x$GHDL" = "x" ]; then elif [ "x$(command -v which)" != "x" ]; then export GHDL="$(which ghdl)" else - printf "${ANSI_RED}error: GHDL environment variable is not defined${ANSI_NOCOLOR}\n" - exit 1 + die "error: GHDL environment variable is not defined" fi fi @@ -125,8 +129,8 @@ do_test() { _vests ;; *) - printf "${ANSI_RED}$0: test name '$1' is unknown${ANSI_NOCOLOR}\n" - exit 1;; + die "$0: test name '$1' is unknown" + ;; esac } -- cgit v1.2.3