Skip to contentSkip to conversation

t9129: Prevent test failure if no UTF-8 locale

PATCH In review applehq 2 participants 2 messages Jun 15, 2016

lore
Share & tools
lore

applehq

author
#0 lore raw

PATCH 1/1 t9129: Prevent test failure if no UTF-8 locale

Commit 16fc08e2d86dad152194829d21bc55b2ef0c8fb1 introduced a test that failed if the en_US.UTF-8 locale was not installed.

Make the test find a UTF-8 locale, and expect failure.

---
 t/t9129-git-svn-i18n-commitencoding.sh |    9 +++++----
 1 files changed, 5 insertions(+), 4 deletions(-)
t/t9129-git-svn-i18n-commitencoding.sh +5 -4
index 938b7fe..87ecdd0 100755
@@ -15,8 +15,9 @@ compare_git_head_with () {
 }
 
 compare_svn_head_with () {
-	LC_ALL=en_US.UTF-8 svn log --limit 1 `git svn info --url` | \
-		sed -e 1,3d -e "/^-\{1,\}\$/d" >current &&
+	LC_ALL=`locale -a | grep -i utf | head -1` \
+		svn log --limit 1 `git svn info --url` | \
+			sed -e 1,3d -e "/^-\{1,\}\$/d" >current &&
 	test_cmp current "$1"
 }
 
@@ -60,7 +61,7 @@ do
 	'
 done
 
-test_expect_success 'ISO-8859-1 should match UTF-8 in svn' '
+test_expect_failure 'ISO-8859-1 should match UTF-8 in svn' '
 (
 	cd ISO-8859-1 &&
 	compare_svn_head_with "$TEST_DIRECTORY"/t3900/1-UTF-8.txt
@@ -69,7 +70,7 @@ test_expect_success 'ISO-8859-1 should match UTF-8 in svn' '
 
 for H in EUCJP ISO-2022-JP
 do
-	test_expect_success '$H should match UTF-8 in svn' '
+	test_expect_failure '$H should match UTF-8 in svn' '
 	(
 		cd $H &&
 		compare_svn_head_with "$TEST_DIRECTORY"/t3900/2-UTF-8.txt
Signature · 1 line
1.6.1.rc1.53.g455b
#1 lore raw
Quoted 4 lines · applehq

Commit 16fc08e2d86dad152194829d21bc55b2ef0c8fb1 introduced a test that failed if the en_US.UTF-8 locale was not installed.

Make the test find a UTF-8 locale, and expect failure.

NAK on the latter one.

test_expect_failure does not mean "This might, and it is Ok to, fail", as you seem to think. It means "This should succeed if our software is not buggy, but there is a known breakage to cause it to fail, so this test is marked as such until the bug is fixed."

Skipping the test on a platform that lacks necessary locale is fine, but if you run the test, they should expect success. Otherwise you cannot tell if it is a platform issue (i.e. not having any UTF-8 locale) or a bug in the software (i.e. git-svn not working as expected).

Quoted 1 line

Sign off with an unreal name, hmm..., what good would that give us...?

t/t9129-git-svn-i18n-commitencoding.sh compare_git_head_with () { · line 20

Quoted 9 lines
t/t9129-git-svn-i18n-commitencoding.sh +3 -2
@@ -15,8 +15,9 @@ compare_git_head_with () {
 }
 
 compare_svn_head_with () {
-	LC_ALL=en_US.UTF-8 svn log --limit 1 `git svn info --url` | \
-		sed -e 1,3d -e "/^-\{1,\}\$/d" >current &&
+	LC_ALL=`locale -a | grep -i utf | head -1` \
+		svn log --limit 1 `git svn info --url` | \
+			sed -e 1,3d -e "/^-\{1,\}\$/d" >current &&

I think what this part tries to do is good, in that we do not care if it is en_US UTF-8 or any other UTF-8. But cramming that logic all in one pipeline (and an inefficient one at that) makes it harder to read.

Do something like this upfront:

	a_utf8_locale=$(locale -a | sed -ne '/[Uu][Tt][Ff]-*8/{
        	p
                q
	'})

and if that variable is empty then skip the test that relies on having a UTF-8 locale on the platform. Then the function can say:

	LC_ALL="$a_utf8_locale" svn log --limit 1 ...