Skip to content

Commit 9b9f46f

Browse files
committed
t0204: clarify the "observe undefined behaviour" test
This test asks for an impossible conversion to the system by preparing an UTF-8 translation with characters that cannot be expressed in ISO-8859-1, and then asking the message shown in ISO-8859-1. Even though the behaviour against such a request is undefined, it may be interesting to see what the system does, and the purpose of this test is to see if there are platforms that exhibit behaviour that we haven't seen. The original recognized two known modes of behaviour: - the key used to query the message catalog ("TEST: Old English Runes"), saying "I cannot do that i18n". - impossible characters replaced with ASCII "?", saying "I punt". but they were treated totally differently. The test simply issued an informational message "Your system punts on this one" for the first error mode, while it diagnosed the latter as "Your system is good; you pass!". It turns out that Mac OS X exhibits a third mode of error behaviour, to spew out the raw value stored in the message catalog. The test diagnosed this behaviour as "broken", but it is merely trying to do its best to respond to an impossible request by saying "I punt" in a way that is slightly different from the second one. Update the offending test to make it clear what is (and is not) being tested, update the code structure so that newly discovered error mode can easily be added to it later, and reword the message that comes from a failing case to clarify that it is not the system that is broken when it fails, but merely that the behaviour is not something we have seen. Signed-off-by: Junio C Hamano <[email protected]>
1 parent 69f4e08 commit 9b9f46f

File tree

1 file changed

+23
-14
lines changed

1 file changed

+23
-14
lines changed

t/t0204-gettext-reencode-sanity.sh

Lines changed: 23 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@ test_description="Gettext reencoding of our *.po/*.mo files works"
77

88
. ./lib-gettext.sh
99

10+
# The constants used in a tricky observation for undefined behaviour
11+
RUNES="TILRAUN: ᚻᛖ ᚳᚹᚫᚦ ᚦᚫᛏ ᚻᛖ ᛒᚢᛞᛖ ᚩᚾ ᚦᚫᛗ ᛚᚪᚾᛞᛖ ᚾᚩᚱᚦᚹᛖᚪᚱᛞᚢᛗ ᚹᛁᚦ ᚦᚪ ᚹᛖᛥᚫ"
12+
PUNTS="TILRAUN: ?? ???? ??? ?? ???? ?? ??? ????? ??????????? ??? ?? ????"
13+
MSGKEY="TEST: Old English Runes"
1014

1115
test_expect_success GETTEXT_LOCALE 'gettext: Emitting UTF-8 from our UTF-8 *.mo files / Icelandic' '
1216
printf "TILRAUN: Halló Heimur!" >expect &&
@@ -15,8 +19,8 @@ test_expect_success GETTEXT_LOCALE 'gettext: Emitting UTF-8 from our UTF-8 *.mo
1519
'
1620

1721
test_expect_success GETTEXT_LOCALE 'gettext: Emitting UTF-8 from our UTF-8 *.mo files / Runes' '
18-
printf "TILRAUN: ᚻᛖ ᚳᚹᚫᚦ ᚦᚫᛏ ᚻᛖ ᛒᚢᛞᛖ ᚩᚾ ᚦᚫᛗ ᛚᚪᚾᛞᛖ ᚾᚩᚱᚦᚹᛖᚪᚱᛞᚢᛗ ᚹᛁᚦ ᚦᚪ ᚹᛖᛥᚫ" >expect &&
19-
LANGUAGE=is LC_ALL="$is_IS_locale" gettext "TEST: Old English Runes" >actual &&
22+
printf "%s" "$RUNES" >expect &&
23+
LANGUAGE=is LC_ALL="$is_IS_locale" gettext "$MSGKEY" >actual &&
2024
test_cmp expect actual
2125
'
2226

@@ -26,18 +30,23 @@ test_expect_success GETTEXT_ISO_LOCALE 'gettext: Emitting ISO-8859-1 from our UT
2630
test_cmp expect actual
2731
'
2832

29-
test_expect_success GETTEXT_ISO_LOCALE 'gettext: Emitting ISO-8859-1 from our UTF-8 *.mo files / Runes' '
30-
LANGUAGE=is LC_ALL="$is_IS_iso_locale" gettext "TEST: Old English Runes" >runes &&
31-
32-
if grep "^TEST: Old English Runes$" runes
33-
then
34-
say "Your system can not handle this complexity and returns the string as-is"
35-
else
36-
# Both Solaris and GNU libintl will return this stream of
37-
# question marks, so it is s probably portable enough
38-
printf "TILRAUN: ?? ???? ??? ?? ???? ?? ??? ????? ??????????? ??? ?? ????" >runes-expect &&
39-
test_cmp runes-expect runes
40-
fi
33+
test_expect_success GETTEXT_ISO_LOCALE 'gettext: impossible ISO-8859-1 output' '
34+
LANGUAGE=is LC_ALL="$is_IS_iso_locale" gettext "$MSGKEY" >runes &&
35+
case "$(cat runes)" in
36+
"$MSGKEY")
37+
say "Your system gives back the key to message catalog"
38+
;;
39+
"$PUNTS")
40+
say "Your system replaces an impossible character with ?"
41+
;;
42+
"$RUNES")
43+
say "Your system gives back the raw message for an impossible request"
44+
;;
45+
*)
46+
say "We never saw the error behaviour your system exhibits"
47+
false
48+
;;
49+
esac
4150
'
4251

4352
test_expect_success GETTEXT_LOCALE 'gettext: Fetching a UTF-8 msgid -> UTF-8' '

0 commit comments

Comments
 (0)