diff options
author | Kate Ward <kate.ward@forestent.com> | 2020-04-11 14:04:43 +0200 |
---|---|---|
committer | Kate Ward <kate.ward@forestent.com> | 2020-04-11 14:04:43 +0200 |
commit | 804340a8f37722cbf69f6c0ea50fdeecd3806523 (patch) | |
tree | b9f56c8521c9b55305f94f0cfd5efcfc42094a95 /shflags_parsing_test.sh | |
parent | 6bd759f77cde2f7db0925d8f209175d5f730732c (diff) | |
download | platform_external_shflags-804340a8f37722cbf69f6c0ea50fdeecd3806523.tar.gz platform_external_shflags-804340a8f37722cbf69f6c0ea50fdeecd3806523.tar.bz2 platform_external_shflags-804340a8f37722cbf69f6c0ea50fdeecd3806523.zip |
Modernized the testGetoptStandard function.
Diffstat (limited to 'shflags_parsing_test.sh')
-rwxr-xr-x | shflags_parsing_test.sh | 21 |
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() { |