summaryrefslogtreecommitdiffstats
path: root/test/util/pacsorttest.sh
diff options
context:
space:
mode:
authorAndrew Gregory <andrew.gregory.8@gmail.com>2014-12-23 22:09:58 +0100
committerAllan McRae <allan@archlinux.org>2014-12-28 04:06:28 +0100
commit29c0d8233b32ab3ad1dcd7c3bf1161449a386dea (patch)
treea25ac6b4006b706cd65465bfd5f23eda1b1f687d /test/util/pacsorttest.sh
parent4c4890dd1cad52a420788e6c30a8e6eca8f83c38 (diff)
downloadpacman-29c0d8233b32ab3ad1dcd7c3bf1161449a386dea.tar.gz
pacman-29c0d8233b32ab3ad1dcd7c3bf1161449a386dea.tar.xz
use tap.sh for bash tests
tap.sh is a reusable TAP library that handles test counting and provides useful diagnostic messages on test failures. Signed-off-by: Andrew Gregory <andrew.gregory.8@gmail.com> Signed-off-by: Allan McRae <allan@archlinux.org>
Diffstat (limited to 'test/util/pacsorttest.sh')
-rwxr-xr-xtest/util/pacsorttest.sh36
1 files changed, 6 insertions, 30 deletions
diff --git a/test/util/pacsorttest.sh b/test/util/pacsorttest.sh
index a29d8f19..3414e767 100755
--- a/test/util/pacsorttest.sh
+++ b/test/util/pacsorttest.sh
@@ -18,15 +18,13 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
+source "$(dirname "$0")"/../tap.sh || exit 1
+
# default binary if one was not specified as $1
bin=${1:-${PMTEST_UTIL_DIR}pacsort}
-# holds counts of tests
-total=26
-run=0
-failure=0
if ! type -p "$bin" &>/dev/null; then
- echo "Bail out! pacsort binary ($bin) could not be located"
+ tap_bail "pacsort binary ($bin) could not be located"
exit 1
fi
@@ -34,24 +32,10 @@ fi
# runtest input expected test_description optional_opts
runtest() {
# run the test
- ((run++))
- out=$(diff -u <(printf "$1" | $bin $4) <(printf "$2"))
- if [[ $? -eq 0 ]]; then
- echo "ok $run - $3"
- else
- ((failure++))
- echo "not ok $run - $3"
- while read line; do
- echo " # $line"
- done <<<"$out"
- fi
+ tap_diff <(printf "$1" | $bin $4) <(printf "$2") "$3"
}
-echo "# Running pacsort tests..."
-
-echo "1..$total"
-
-# BEGIN TESTS
+tap_plan 26
in="1\n2\n3\n4\n"
runtest $in $in "already ordered"
@@ -124,14 +108,6 @@ runtest "$separator_reverse" "$separator" "really long input, sort key, separato
runtest "$separator_reverse" "$separator_reverse" "really long input, sort key, separator, reversed" "-k 3 -t| -r"
runtest "$separator" "$separator_reverse" "really long input, sort key, separator, reversed" "-k 3 -t| -r"
-#END TESTS
-
-if [[ $failure -eq 0 ]]; then
- echo "# All $run tests successful"
- exit 0
-fi
-
-echo "# $failure of $run tests failed"
-exit 1
+tap_finish
# vim: set noet: