Lines Matching +full:run +full:- +full:shellcheck
6 # Copyright 2008-2020 Kate Ward. All Rights Reserved.
12 ### ShellCheck (http://www.shellcheck.net/)
14 # shellcheck disable=SC1090,SC1091
20 stdoutF="${TMPDIR:-/tmp}/STDOUT"
21 stderrF="${TMPDIR:-/tmp}/STDERR"
27 if ! _flags_getoptStandard '-b' >"${stdoutF}" 2>"${stderrF}"; then
28 fail "error parsing -b flag"
32 if _flags_getoptStandard '-x' >"${stdoutF}" 2>"${stderrF}"; then
33 fail "expected error parsing invalid -x flag"
43 if ! _flags_getoptEnhanced '-b' >"${stdoutF}" 2>"${stderrF}"; then
44 fail "error parsing -b flag"
47 if ! _flags_getoptEnhanced '--bool' >"${stdoutF}" 2>"${stderrF}"; then
48 fail "error parsing --bool flag"
52 if _flags_getoptEnhanced '-x' >"${stdoutF}" 2>"${stderrF}"; then
53 fail "expected error parsing invalid -x flag"
56 if _flags_getoptEnhanced '--xyz' >"${stdoutF}" 2>"${stderrF}"; then
57 fail "expected error parsing invalid --xyz flag"
64 if FLAGS -b >"${stdoutF}" 2>"${stderrF}"; then
65 assertTrue "${desc}: expected true value" "${FLAGS_bool:-}"
67 fail "${desc}: FLAGS returned a non-zero result ($?)"
74 assertTrue "${desc}: expected true value" "${FLAGS_bool2:-}"
76 fail "${desc}: FLAGS returned a non-zero result ($?)"
81 if FLAGS -B >"${stdoutF}" 2>"${stderrF}"; then
82 assertFalse "${desc}: expected false value" "${FLAGS_bool2:-}"
84 fail "${desc}: FLAGS returned a non-zero result ($?)"
92 [ $? -eq "${FLAGS_FALSE}" ] && return
97 FLAGS --nobool >"${stdoutF}" 2>"${stderrF}"
99 assertTrue "FLAGS returned a non-zero result (${r3turn})" ${r3turn}
100 assertFalse '--noXX flag resulted in true value.' "${FLAGS_bool:-}"
101 assertFalse 'expected no output to STDERR' "[ -s '${stderrF}' ]"
105 FLAGS --bool >"${stdoutF}" 2>"${stderrF}"
107 assertTrue "FLAGS returned a non-zero result (${r3turn})" ${r3turn}
108 assertTrue '--XX flag resulted in false value.' "${FLAGS_bool:-}"
109 assertFalse 'expected no output to STDERR' "[ -s '${stderrF}' ]"
113 FLAGS --nobool >"${stdoutF}" 2>"${stderrF}"
115 assertTrue "FLAGS returned a non-zero result (${r3turn})" ${r3turn}
116 assertFalse '--noXX flag resulted in true value.' "${FLAGS_bool:-}"
117 assertFalse 'expected no output to STDERR' "[ -s '${stderrF}' ]"
122 _testFloats '-f'
124 _testFloats '--float'
133 # shellcheck disable=SC2154
136 fail "${flag}: unexpected non-zero result ($?)"
144 fail "${flag}: expected a non-zero result"
153 _testIntegers '-i'
155 _testIntegers '--int'
164 # shellcheck disable=SC2154
167 fail "${flag}: unexpected non-zero result ($?)"
175 fail "${flag}: expected a non-zero result"
184 _testStrings 'std_single_word' -s single_word
186 _testStrings 'enh_single_word' --str single_word
187 _testStrings 'enh_multi_word' --str 'string with spaces'
197 # shellcheck disable=SC2154
200 fail "${desc}: unexpected non-zero result ($?)"
208 _testMultipleFlags '-b' '-i' '-f' '-s'
210 [ $? -eq "${FLAGS_FALSE}" ] && return
211 _testMultipleFlags '--bool' '--int' '--float' '--str'
227 assertTrue "use of multiple flags returned a non-zero result" ${r3turn}
232 assertFalse 'expected no output to STDERR' "[ -s '${stderrF}' ]"
242 assertTrue 'parse returned non-zero value.' ${r3turn}
245 eval set -- "${FLAGS_ARGV}"
263 FLAGS --str='str_flag' 'non_flag' >"${stdoutF}" 2>"${stderrF}"
264 assertTrue 'FLAGS returned a non-zero result' $?
268 eval set -- "${FLAGS_ARGV}"
274 [ $? -eq "${FLAGS_TRUE}" ] && return
276 # Note: standard getopt stops parsing after first non-flag argument, which
278 FLAGS -i 1 non_flag_1 -s 'two' non_flag_2 -f 3 non_flag_3 \
281 assertTrue 'FLAGS returned a non-zero result' ${r3turn}
285 eval set -- "${FLAGS_ARGV}"
291 [ $? -eq "${FLAGS_FALSE}" ] && return
293 FLAGS -i 1 non_flag_1 --str='two' non_flag_2 --float 3 'non flag 3' \
296 assertTrue 'FLAGS returned a non-zero result' ${r3turn}
302 eval set -- "${FLAGS_ARGV}"
327 # showTestOutput for the most recently run test.
330 # Load and run shUnit2.
331 # shellcheck disable=SC2034
332 [ -n "${ZSH_VERSION:-}" ] && SHUNIT_PARENT=$0