summaryrefslogtreecommitdiff
path: root/tests/kolainst/libtest-core.sh
diff options
context:
space:
mode:
authorColin Walters <walters@verbum.org>2021-09-10 17:07:42 -0400
committerColin Walters <walters@verbum.org>2021-09-10 17:07:42 -0400
commitbc30806c6edc005de9fe32dd645ed9a13469796f (patch)
tree43ce6c497c80377405e03e0558acfd843fa2ffb7 /tests/kolainst/libtest-core.sh
parent213b8608ea579b6cd0fb4140e9689fc814f36c26 (diff)
downloadostree-bc30806c6edc005de9fe32dd645ed9a13469796f.tar.gz
tests: Add new TAP APIs
Having to touch a global test counter when adding tests is a recipe for conflicts between PRs. The TAP protocol allows *ending* with the expected number of tests, so the best way to do this is to have an explicit API like our `tap_ok` which bumps a counter, then end with `tap_end`. I ported one test as a demo.
Diffstat (limited to 'tests/kolainst/libtest-core.sh')
-rw-r--r--tests/kolainst/libtest-core.sh11
1 files changed, 11 insertions, 0 deletions
diff --git a/tests/kolainst/libtest-core.sh b/tests/kolainst/libtest-core.sh
index 9632e905..75b9063a 100644
--- a/tests/kolainst/libtest-core.sh
+++ b/tests/kolainst/libtest-core.sh
@@ -35,6 +35,17 @@ assert_not_reached () {
fatal "$@"
}
+# Output an ok message for TAP
+n_tap_tests=0
+tap_ok() {
+ echo "ok" "$@"
+ n_tap_tests=$(($n_tap_tests+1))
+}
+
+tap_end() {
+ echo "1..${n_tap_tests}"
+}
+
# Some tests look for specific English strings. Use a UTF-8 version
# of the C (POSIX) locale if we have one, or fall back to en_US.UTF-8
# (https://sourceware.org/glibc/wiki/Proposals/C.UTF-8)