gbranden pushed a commit to branch master
in repository groff.
commit 1a3aa0ff00e2830974cb2094c12c751818775fe6
Author: G. Branden Robinson <[email protected]>
AuthorDate: Wed Jul 10 09:40:52 2024 -0500
[tests]: Handle missing locale(1) command better.
* src/devices/grotty/tests/basic_latin_glyphs_map_correctly.sh:
* src/roff/groff/tests/smoke-test_html_device.sh: Revise tests to better
handle non-glibc environments. For example, Bionic libc offers no
"locale" command to query the locale's character set from the shell.
When that is the case, skip the test and describe the failure more
accurately. Fixes test failures on Termux.
---
ChangeLog | 10 +++++++
.../tests/basic_latin_glyphs_map_correctly.sh | 23 ++++++++++++----
src/roff/groff/tests/smoke-test_html_device.sh | 31 ++++++++++++++++++----
3 files changed, 54 insertions(+), 10 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 354d1f7e2..5f0594507 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,13 @@
+2024-07-10 G. Branden Robinson <[email protected]>
+
+ * src/devices/grotty/tests/basic_latin_glyphs_map_correctly.sh:
+ * src/roff/groff/tests/smoke-test_html_device.sh: Revise tests
+ to better handle non-glibc environments. For example, Bionic
+ libc offers no "locale" command to query the locale's character
+ set from the shell. When that is the case, skip the test and
+ describe the failure more accurately. Fixes test failures on
+ Termux.
+
2024-05-14 Dave Kemper <[email protected]>
* tmac/e.tmac: Add debugging advice for developers.
diff --git a/src/devices/grotty/tests/basic_latin_glyphs_map_correctly.sh
b/src/devices/grotty/tests/basic_latin_glyphs_map_correctly.sh
index 6333b4d26..5067e4b6a 100755
--- a/src/devices/grotty/tests/basic_latin_glyphs_map_correctly.sh
+++ b/src/devices/grotty/tests/basic_latin_glyphs_map_correctly.sh
@@ -1,6 +1,6 @@
#!/bin/sh
#
-# Copyright (C) 2022 Free Software Foundation, Inc.
+# Copyright (C) 2022-2024 Free Software Foundation, Inc.
#
# This file is part of groff.
#
@@ -120,16 +120,29 @@ for D in ascii latin1 utf8
do
if [ "$D" = "utf8" ]
then
- # We can't test UTF-8 if the environment doesn't support it.
- if [ "$(locale charmap)" != UTF-8 ]
+ give_up=
+ message=
+ # We can't test UTF-8 if we can't inquire what the locale's
+ # character set is.
+ if ! command -v locale
+ then
+ message="no 'locale' command available"
+ give_up=yes
+ # ...or if the environment doesn't support UTF-8.
+ elif [ "$(locale charmap)" != UTF-8 ]
+ then
+ message="environment does not support UTF-8"
+ give_up=yes
+ fi
+
+ if [ -n "$give_up" ]
then
# If we've already seen a failure case, report it.
if [ -n "$fail" ]
then
exit 1 # fail
else
- echo "environment does not support UTF-8;" \
- "skipping test" >&2
+ echo "$message; skipping test" >&2
exit 77 # skip
fi
fi
diff --git a/src/roff/groff/tests/smoke-test_html_device.sh
b/src/roff/groff/tests/smoke-test_html_device.sh
index df9709e77..7a70a300b 100755
--- a/src/roff/groff/tests/smoke-test_html_device.sh
+++ b/src/roff/groff/tests/smoke-test_html_device.sh
@@ -1,6 +1,6 @@
#!/bin/sh
#
-# Copyright (C) 2020, 2022 Free Software Foundation, Inc.
+# Copyright (C) 2020-2024 Free Software Foundation, Inc.
#
# This file is part of groff.
#
@@ -67,11 +67,32 @@ echo "$output" | grep -q '<img src="grohtml-[0-9]\+-2.png"'
|| wail
cleanup
-# We can't run remaining tests if the environment doesn't support UTF-8.
-if [ "$(locale charmap)" != UTF-8 ]
+give_up=
+message=
+
+# We can't run remaining tests if we can't inquire what the locale's
+# character set is.
+if ! command -v locale
+then
+ message="no 'locale' command available"
+ give_up=yes
+# ...or if the environment doesn't support UTF-8.
+elif [ "$(locale charmap)" != UTF-8 ]
+then
+ message="environment does not support UTF-8"
+ give_up=yes
+fi
+
+if [ -n "$give_up" ]
then
- echo "environment does not support UTF-8; skipping test" >&2
- exit 77 # skip
+ # If we've already seen a failure case, report it.
+ if [ -n "$fail" ]
+ then
+ exit 1 # fail
+ else
+ echo "$message; skipping test" >&2
+ exit 77 # skip
+ fi
fi
# Check two forms of character transformation.
_______________________________________________
Groff-commit mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/groff-commit