summaryrefslogtreecommitdiffstats
path: root/test/scripts
diff options
context:
space:
mode:
authorAndrew Gregory <andrew.gregory.8@gmail.com>2013-07-18 03:41:08 -0400
committerAllan McRae <allan@archlinux.org>2013-08-21 11:00:18 +1000
commitd3726bbd26769b1ab7cdbedda109db31bdfb0f78 (patch)
treea9a610096ea32ffa8d0d6e7a064ddc46a5a47d2c /test/scripts
parent2e2c614f0e35dfbf80c17d55377418c1ded3f065 (diff)
downloadpacman-d3726bbd26769b1ab7cdbedda109db31bdfb0f78.tar.xz
convert test scripts to tap output
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-xtest/scripts/human_to_size_test.sh24
-rwxr-xr-xtest/scripts/parseopts_test.sh25
2 files changed, 29 insertions, 20 deletions
diff --git a/test/scripts/human_to_size_test.sh b/test/scripts/human_to_size_test.sh
index dbf1997a..678fa876 100755
--- a/test/scripts/human_to_size_test.sh
+++ b/test/scripts/human_to_size_test.sh
@@ -1,14 +1,16 @@
#!/bin/bash
+declare -i testcount=0 fail=0 pass=0 total=15
+
# source the library function
if [[ -z $1 || ! -f $1 ]]; then
- printf "error: path to human_to_size library not provided or does not exist\n"
+ printf "Bail out! path to human_to_size library not provided or does not exist\n"
exit 1
fi
. "$1"
if ! type -t human_to_size >/dev/null; then
- printf 'human_to_size function not found\n'
+ printf 'Bail out! human_to_size function not found\n'
exit 1
fi
@@ -20,27 +22,31 @@ parse_hts() {
result=$(human_to_size "$1")
if [[ $result = "$expected" ]]; then
(( ++pass ))
+ printf "ok %d - %s\n" "$testcount" "$input"
else
(( ++fail ))
- printf '[TEST %3s]: FAIL\n' "$testcount"
- printf ' input: %s\n' "$input"
- printf ' output: %s\n' "$result"
- printf ' expected: %s\n' "$expected"
+ printf "not ok %d - %s\n" "$testcount" "$input"
+ printf '# [TEST %3s]: FAIL\n' "$testcount"
+ printf '# input: %s\n' "$input"
+ printf '# output: %s\n' "$result"
+ printf '# expected: %s\n' "$expected"
fi
}
summarize() {
if (( !fail )); then
- printf 'All %s tests successful\n\n' "$testcount"
+ printf '# All %s tests successful\n\n' "$testcount"
exit 0
else
- printf '%s of %s tests failed\n\n' "$fail" "$testcount"
+ printf '# %s of %s tests failed\n\n' "$fail" "$testcount"
exit 1
fi
}
trap 'summarize' EXIT
-printf 'Beginning human_to_size tests\n'
+printf '# Beginning human_to_size tests\n'
+
+echo "1..$total"
# parse_hts <input> <expected output>
diff --git a/test/scripts/parseopts_test.sh b/test/scripts/parseopts_test.sh
index b7e5d08a..8df1908b 100755
--- a/test/scripts/parseopts_test.sh
+++ b/test/scripts/parseopts_test.sh
@@ -1,16 +1,16 @@
#!/bin/bash
-declare -i testcount=0 pass=0 fail=0
+declare -i testcount=0 pass=0 fail=0 total=25
# source the library function
if [[ -z $1 || ! -f $1 ]]; then
- printf "error: path to parseopts library not provided or does not exist\n"
+ printf "Bail out! path to parseopts library not provided or does not exist\n"
exit 1
fi
. "$1"
if ! type -t parseopts >/dev/null; then
- printf 'parseopts function not found\n'
+ printf 'Bail out! parseopts function not found\n'
exit 1
fi
@@ -36,28 +36,31 @@ test_result() {
if [[ $result = "$*" ]] && (( tokencount == $# )); then
(( ++pass ))
+ printf 'ok %d - %s\n' "$testcount" "$input"
else
- printf '[TEST %3s]: FAIL\n' "$testcount"
- printf ' input: %s\n' "$input"
- printf ' output: %s (%s tokens)\n' "$*" "$#"
- printf ' expected: %s (%s tokens)\n' "$result" "$tokencount"
- echo
+ printf 'not ok %d - %s\n' "$testcount" "$input"
+ printf '# [TEST %3s]: FAIL\n' "$testcount"
+ printf '# input: %s\n' "$input"
+ printf '# output: %s (%s tokens)\n' "$*" "$#"
+ printf '# expected: %s (%s tokens)\n' "$result" "$tokencount"
(( ++fail ))
fi
}
summarize() {
if (( !fail )); then
- printf 'All %s tests successful\n\n' "$testcount"
+ printf '# All %s tests successful\n\n' "$testcount"
exit 0
else
- printf '%s of %s tests failed\n\n' "$fail" "$testcount"
+ printf '# %s of %s tests failed\n\n' "$fail" "$testcount"
exit 1
fi
}
trap 'summarize' EXIT
-printf 'Beginning parseopts tests\n'
+printf '# Beginning parseopts tests\n'
+
+echo "1..$total"
# usage: parse <expected result> <token count> test-params...
# a failed parse will match only the end of options marker '--'