diff options
author | Andrew Gregory <andrew.gregory.8@gmail.com> | 2014-12-23 16:16:08 -0500 |
---|---|---|
committer | Allan McRae <allan@archlinux.org> | 2014-12-28 13:06:39 +1000 |
commit | f1e010a5a7c562da02a74ffb043520760db49ba3 (patch) | |
tree | 5a9feb4c8d6a23e5410ab9da0cbf43b15e2485e3 /test/scripts | |
parent | 29c0d8233b32ab3ad1dcd7c3bf1161449a386dea (diff) |
add tap_ prefix to test helper functions
Allows tap.sh to show the line number where the helper function was
called on failures.
Signed-off-by: Andrew Gregory <andrew.gregory.8@gmail.com>
Signed-off-by: Allan McRae <allan@archlinux.org>
Diffstat (limited to 'test/scripts')
-rwxr-xr-x | test/scripts/human_to_size_test.sh | 34 | ||||
-rwxr-xr-x | test/scripts/parseopts_test.sh | 56 |
2 files changed, 45 insertions, 45 deletions
diff --git a/test/scripts/human_to_size_test.sh b/test/scripts/human_to_size_test.sh index e412e836..6334495f 100755 --- a/test/scripts/human_to_size_test.sh +++ b/test/scripts/human_to_size_test.sh @@ -15,43 +15,43 @@ if ! type -t human_to_size &>/dev/null; then exit 1 fi -parse_hts() { +tap_parse_hts() { local input=$1 expected=$2 tap_is_str "$(human_to_size "$input")" "$expected" "$input" } tap_plan 15 -# parse_hts <input> <expected output> +# tap_parse_hts <input> <expected output> -parse_hts '1MiB' 1048576 +tap_parse_hts '1MiB' 1048576 -parse_hts '10XiB' '' +tap_parse_hts '10XiB' '' -parse_hts '10 MiB' 10485760 +tap_parse_hts '10 MiB' 10485760 -parse_hts '10 XiB' '' +tap_parse_hts '10 XiB' '' -parse_hts '.1 TiB' 109951162778 +tap_parse_hts '.1 TiB' 109951162778 -parse_hts ' -3 KiB ' -3072 +tap_parse_hts ' -3 KiB ' -3072 -parse_hts 'foo3KiB' '' +tap_parse_hts 'foo3KiB' '' -parse_hts '3KiBfoo' '' +tap_parse_hts '3KiBfoo' '' -parse_hts '3kib' '' +tap_parse_hts '3kib' '' -parse_hts '+1KiB' 1024 +tap_parse_hts '+1KiB' 1024 -parse_hts '+1.0 KiB' 1024 +tap_parse_hts '+1.0 KiB' 1024 -parse_hts '1MB' 1000000 +tap_parse_hts '1MB' 1000000 -parse_hts '1M' 1048576 +tap_parse_hts '1M' 1048576 -parse_hts ' 1 G ' 1073741824 +tap_parse_hts ' 1 G ' 1073741824 -parse_hts '1Q' '' +tap_parse_hts '1Q' '' # vim: set noet: diff --git a/test/scripts/parseopts_test.sh b/test/scripts/parseopts_test.sh index 03e9d0ac..a8738a4c 100755 --- a/test/scripts/parseopts_test.sh +++ b/test/scripts/parseopts_test.sh @@ -23,7 +23,7 @@ OPT_LONG=('allsource' 'asroot' 'ignorearch' 'check' 'clean:' 'cleanall' 'nodeps' 'repackage' 'skipinteg' 'sign' 'source' 'syncdeps' 'version' 'config:' 'noconfirm' 'noprogressbar') -parse() { +tap_parse() { local result=$1 tokencount=$2; shift 2 parseopts "$OPT_SHORT" "${OPT_LONG[@]}" -- "$@" 2>/dev/null tap_is_int "${#OPTRET[@]}" "$tokencount" "$* - tokencount" @@ -33,83 +33,83 @@ parse() { tap_plan 50 -# usage: parse <expected result> <token count> test-params... -# a failed parse will match only the end of options marker '--' +# usage: tap_parse <expected result> <token count> test-params... +# a failed tap_parse will match only the end of options marker '--' # no options -parse '--' 1 +tap_parse '--' 1 # short options -parse '-s -r --' 3 -s -r +tap_parse '-s -r --' 3 -s -r # short options, no spaces -parse '-s -r --' 3 -sr +tap_parse '-s -r --' 3 -sr # short opt missing an opt arg -parse '--' 1 -s -p +tap_parse '--' 1 -s -p # short opt with an opt arg -parse '-p PKGBUILD -L --' 4 -p PKGBUILD -L +tap_parse '-p PKGBUILD -L --' 4 -p PKGBUILD -L # short opt with an opt arg, no space -parse '-p PKGBUILD --' 3 -pPKGBUILD +tap_parse '-p PKGBUILD --' 3 -pPKGBUILD # valid shortopts as a long opt -parse '--' 1 --sir +tap_parse '--' 1 --sir # long opt with no optarg -parse '--log --' 2 --log +tap_parse '--log --' 2 --log # long opt with missing optarg -parse '--' 1 -sr --pkg +tap_parse '--' 1 -sr --pkg # long opt with optarg -parse '--pkg foo --' 3 --pkg foo +tap_parse '--pkg foo --' 3 --pkg foo # long opt with optarg with whitespace -parse '--pkg foo bar -- baz' 4 --pkg "foo bar" baz +tap_parse '--pkg foo bar -- baz' 4 --pkg "foo bar" baz # long opt with optarg with = -parse '--pkg foo=bar -- baz' 4 --pkg foo=bar baz +tap_parse '--pkg foo=bar -- baz' 4 --pkg foo=bar baz # long opt with explicit optarg -parse '--pkg bar -- foo baz' 5 foo --pkg=bar baz +tap_parse '--pkg bar -- foo baz' 5 foo --pkg=bar baz # long opt with explicit optarg, with whitespace -parse '--pkg foo bar -- baz' 4 baz --pkg="foo bar" +tap_parse '--pkg foo bar -- baz' 4 baz --pkg="foo bar" # long opt with explicit optarg that doesn't take optarg -parse '--' 1 --force=always -s +tap_parse '--' 1 --force=always -s # long opt with explicit optarg with = -parse '--pkg foo=bar --' 3 --pkg=foo=bar +tap_parse '--pkg foo=bar --' 3 --pkg=foo=bar # explicit end of options with options after -parse '-s -r -- foo bar baz' 6 -s -r -- foo bar baz +tap_parse '-s -r -- foo bar baz' 6 -s -r -- foo bar baz # non-option parameters mixed in with options -parse '-s -r -- foo baz' 5 -s foo baz -r +tap_parse '-s -r -- foo baz' 5 -s foo baz -r # optarg with whitespace -parse '-p foo bar -s --' 4 -p'foo bar' -s +tap_parse '-p foo bar -s --' 4 -p'foo bar' -s # non-option parameter with whitespace -parse '-i -- foo bar' 3 -i 'foo bar' +tap_parse '-i -- foo bar' 3 -i 'foo bar' # successful stem match (opt has no arg) -parse '--nocolor --' 2 --nocol +tap_parse '--nocolor --' 2 --nocol # successful stem match (opt has arg) -parse '--config foo --' 3 --conf foo +tap_parse '--config foo --' 3 --conf foo # ambiguous long opt -parse '--' 1 '--for' +tap_parse '--' 1 '--for' # exact match on a possible stem (--force & --forcever) -parse '--force --' 2 --force +tap_parse '--force --' 2 --force # exact match on possible stem (opt has optarg) -parse '--clean foo --' 3 --clean=foo +tap_parse '--clean foo --' 3 --clean=foo tap_finish |