commit: 02d2824b4daeedd4084da53ebf3633a8b5508a92
Author: Kerin Millar <kfm <AT> plushkava <DOT> net>
AuthorDate: Sat Jun 10 05:40:35 2023 +0000
Commit: Sam James <sam <AT> gentoo <DOT> org>
CommitDate: Sat Jun 10 05:40:35 2023 +0000
URL:
https://gitweb.gentoo.org/proj/gentoo-functions.git/commit/?id=02d2824b
test-functions: Really fix non-conforming TAP output
The previous "fix" was an experimental patch that was not yet intended
for inclusion. This supplemental commit does as little as is necessary
to render the test suite properly functional under meson, given that
meson.build has been configured to expect the use of the TAP protocol.
It also configures meson to be verbose while executing the test suite.
As far as I can gather, the TAP support in meson is weak. Subtests do
not appear to be supported. For that reason, I have dropped the TAP
version from 14 to 13. While meson recognises "# SKIP" as a directive,
it does not report the reason that may follow the text. Another issue is
that no controlling terminal is present under meson. Therefore,
test_update_cursor_coords() is rendered useless, for it will always be
skipped. I have left the test in for the time being, in the hope that
there may yet be a solution.
In any case, this should be enough to render the -9999 ebuild both
testable and usable.
Signed-off-by: Kerin Millar <kfm <AT> plushkava.net>
meson.build | 3 ++-
test-functions | 21 +++++++++++----------
2 files changed, 13 insertions(+), 11 deletions(-)
diff --git a/meson.build b/meson.build
index aa56907..2557168 100644
--- a/meson.build
+++ b/meson.build
@@ -46,6 +46,7 @@ if do_tests
test(
'test-functions', files('test-functions'),
workdir : meson.current_build_dir(),
- protocol : 'tap'
+ protocol : 'tap',
+ verbose : true
)
endif
diff --git a/test-functions b/test-functions
index 5e04c5f..aed6620 100755
--- a/test-functions
+++ b/test-functions
@@ -305,9 +305,8 @@ test_is_visible() {
}
test_update_cursor_coords() {
- printf '%d..%d\n' "${tap_i}" "${tap_i}"
skip() {
- print 'ok %d # SKIP\n' "${tap_i}"
+ printf 'ok %d - _update_cursor_coords # SKIP\n' "$((testnum +=
1))"
}
if _has_dumb_terminal; then
skip
@@ -323,10 +322,10 @@ test_update_cursor_coords() {
# The terminal isn't smart
skip
elif ! _update_cursor_coords <>/dev/tty; then
- printf 'not ok %d - _update_cursor_coords\n' "${tap_i}"
+ printf 'not ok %d - _update_cursor_coords\n' "$((testnum += 1))"
false
else
- printf 'ok %d - _update_cursor_coords (x = %d, y = %d)\n'
"${tap_i}" "${genfun_x}" "${genfun_y}"
+ printf 'ok %d - _update_cursor_coords (x = %d, y = %d)\n'
"$((testnum += 1))" "${genfun_x}" "${genfun_y}"
fi
}
@@ -374,7 +373,6 @@ iterate_tests() {
shift
total=$(( $# / slice_width ))
- printf '%d..%d\n' "${tap_i}" "$((tap_i + total - 1))"
passed=0
i=0
while [ "$((i += 1))" -le "${total}" ]; do
@@ -405,9 +403,8 @@ iterate_tests() {
else
expected=">=$1"
fi
- printf 'ok %d - %s (expecting %s)\n' "${tap_i}"
"${test_description}" "${expected}"
+ printf 'ok %d - %s (expecting %s)\n' "$((testnum += 1))"
"${test_description}" "${expected}"
shift "${slice_width}"
- tap_i=$((tap_i + 1))
done
return "$(( passed < total ))"
}
@@ -429,7 +426,7 @@ print_args() {
printf '%s\n' "$*"
}
-printf 'TAP version 14\n'
+printf 'TAP version 13\n'
unset -v dir
@@ -449,9 +446,9 @@ assign_tmpdir
export TEST_GENFUNCS=1
export TZ=UTC
-tap_i=1
-
+testnum=0
rc=0
+
test_chdir || rc=1
test_chdir_noop || rc=1
test_is_older_than || rc=1
@@ -462,5 +459,9 @@ test_is_int || rc=1
test_is_visible || rc=1
test_update_cursor_coords || rc=1
test_yesno || rc=1
+
cleanup_tmpdir
+
+printf '1..%d\n' "${testnum}"
+
exit "${rc}"