aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKate Ward <kate.ward@forestent.com>2020-04-11 14:04:43 +0200
committerKate Ward <kate.ward@forestent.com>2020-04-11 14:04:43 +0200
commit804340a8f37722cbf69f6c0ea50fdeecd3806523 (patch)
treeb9f56c8521c9b55305f94f0cfd5efcfc42094a95
parent6bd759f77cde2f7db0925d8f209175d5f730732c (diff)
downloadshflags-804340a8f37722cbf69f6c0ea50fdeecd3806523.tar.gz
Modernized the testGetoptStandard function.
-rwxr-xr-xshflags_parsing_test.sh21
1 files changed, 8 insertions, 13 deletions
diff --git a/shflags_parsing_test.sh b/shflags_parsing_test.sh
index 1623434..87846f9 100755
--- a/shflags_parsing_test.sh
+++ b/shflags_parsing_test.sh
@@ -3,7 +3,7 @@
#
# shFlags unit test for the flag definition methods
#
-# Copyright 2008-2017 Kate Ward. All Rights Reserved.
+# Copyright 2008-2020 Kate Ward. All Rights Reserved.
# Released under the Apache 2.0 license.
#
# Author: kate.ward@forestent.com (Kate Ward)
@@ -16,12 +16,6 @@
# TODO(kward): assert on FLAGS errors
# TODO(kward): testNonStandardIFS()
-# Exit immediately if a pipeline or subshell exits with a non-zero status.
-#set -e
-
-# Treat unset variables as an error.
-set -u
-
# These variables will be overridden by the test helpers.
returnF="${TMPDIR:-/tmp}/return"
stdoutF="${TMPDIR:-/tmp}/STDOUT"
@@ -31,13 +25,14 @@ stderrF="${TMPDIR:-/tmp}/STDERR"
. ./shflags_test_helpers
testGetoptStandard() {
- _flags_getoptStandard '-b' >"${stdoutF}" 2>"${stderrF}"
- rslt=$?
- assertTrue "didn't parse valid flag 'b'" ${rslt}
- th_showOutput ${rslt} "${stdoutF}" "${stderrF}"
+ if ! _flags_getoptStandard '-b' >"${stdoutF}" 2>"${stderrF}"; then
+ fail "didn't parse valid flag 'b'"
+ th_showOutput ${rslt} "${stdoutF}" "${stderrF}"
+ fi
- _flags_getoptStandard '-x' >"${stdoutF}" 2>"${stderrF}"
- assertFalse "parsed invalid flag 'x'" $?
+ if _flags_getoptStandard '-x' >"${stdoutF}" 2>"${stderrF}"; then
+ fail "parsed invalid flag 'x'"
+ fi
}
testGetoptEnhanced() {