mirror of
https://github.com/fish-shell/fish-shell
synced 2024-12-25 12:23:09 +00:00
make printf test resilient to missing locale
Another dev noticed that tests/printf.in was failing because they didn't have the fr_FR.UTF-8 locale installed. Make that test more resilient by trying other locales and if no suitable locale is found skipping the test.
This commit is contained in:
parent
9f6ba5db7a
commit
363fa0a598
1 changed files with 23 additions and 4 deletions
|
@ -13,7 +13,7 @@ printf "%-20d%d\n" 5 10
|
|||
|
||||
printf "%*d\n" 10 100
|
||||
|
||||
printf "%%\"\\\n"
|
||||
printf "%%\"\\\n"
|
||||
printf "%s\b%s\n" x y
|
||||
printf "abc\rdef\n"
|
||||
printf "Msg1\fMsg2\n"
|
||||
|
@ -39,6 +39,25 @@ printf '\376' | xxd -p
|
|||
# #3334. This starts by assuming an locale using english conventions.
|
||||
printf '%e\n' "1.23" # should succeed, output should be 1.230000e+00
|
||||
printf '%e\n' "2,34" # should fail
|
||||
set -x LC_NUMERIC fr_FR.UTF-8
|
||||
printf '%e\n' "3,45" # should succeed, output should be 3,450000e+00
|
||||
printf '%e\n' "4.56" # should succeed, output should be 4,560000e+00
|
||||
|
||||
# Try to use one of several locales that use a comma as the decimal mark
|
||||
# rather than the period used in english speaking locales. If we don't find
|
||||
# one installed we simply don't run this test.
|
||||
set -l locales (locale -a)
|
||||
set -l acceptable_locales bg_BG de_DE es_ES fr_FR ru_RU
|
||||
set -l numeric_locale
|
||||
for locale in {$acceptable_locales}.{UTF-8,UTF8}
|
||||
if string match -i -q $locale $locales
|
||||
set numeric_locale $locale
|
||||
break
|
||||
end
|
||||
end
|
||||
|
||||
if set -q numeric_locale[1]
|
||||
set -x LC_NUMERIC $numeric_locale
|
||||
printf '%e\n' "3,45" # should succeed, output should be 3,450000e+00
|
||||
printf '%e\n' "4.56" # should succeed, output should be 4,560000e+00
|
||||
else
|
||||
echo '3,450000e+00'
|
||||
echo '4,560000e+00'
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue