Skip to content

Commit 2de03eb

Browse files
committed
t9129: fix UTF-8 locale detection
The UTF-8 prerequisite test checked explicitly for en_US.utf8 in the output from "locale -a", but the tests that are actually protected by the prerequisite were asking LC_ALL=en_US.UTF-8 from the system. This inconsistency leads the tests to fail on platforms that do not know both en_US.UTF-8 and en_US.utf8 (thanks you, Yann Droneaud, for bringing this up with an initial patch). Instead, pick a locale with ".UTF-8" (with or without hyphen, spelled in either upper or lowercase) in its name from "locale -a" output, and use it for running the test. Signed-off-by: Junio C Hamano <[email protected]>
1 parent 6774e2b commit 2de03eb

File tree

1 file changed

+13
-7
lines changed

1 file changed

+13
-7
lines changed

t/t9129-git-svn-i18n-commitencoding.sh

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,22 @@ compare_git_head_with () {
1414
test_cmp current "$1"
1515
}
1616

17+
a_utf8_locale=$(locale -a | sed -n '/\.[uU][tT][fF]-*8$/{
18+
p
19+
q
20+
}')
21+
22+
if test -n "$a_utf8_locale"
23+
then
24+
test_set_prereq UTF8
25+
else
26+
say "UTF-8 locale not available, some tests are skipped"
27+
fi
28+
1729
compare_svn_head_with () {
1830
# extract just the log message and strip out committer info.
1931
# don't use --limit here since svn 1.1.x doesn't have it,
20-
LC_ALL=en_US.UTF-8 svn log `git svn info --url` | perl -w -e '
32+
LC_ALL="$a_utf8_locale" svn log `git svn info --url` | perl -w -e '
2133
use bytes;
2234
$/ = ("-"x72) . "\n";
2335
my @x = <STDIN>;
@@ -69,12 +81,6 @@ do
6981
'
7082
done
7183

72-
if locale -a |grep -q en_US.utf8; then
73-
test_set_prereq UTF8
74-
else
75-
say "UTF-8 locale not available, test skipped"
76-
fi
77-
7884
test_expect_success UTF8 'ISO-8859-1 should match UTF-8 in svn' '
7985
(
8086
cd ISO8859-1 &&

0 commit comments

Comments
 (0)