{"thread":{"id":"16607","subject":"[PATCH] t9129: Prevent test failure if no UTF-8 locale","startedAt":"2008-12-06T01:31:52Z","lastAt":"2008-12-06T02:05:50Z","messageCount":2,"participants":["applehq","Junio C Hamano"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"97235","messageId":"20081206013152.GA6129@cumin","threadId":"16607","inReplyTo":null,"subject":"[PATCH] t9129: Prevent test failure if no UTF-8 locale","fromName":"applehq","fromEmail":"theappleman@gmail.com","sentAt":"2008-12-06T01:31:52Z","receivedAt":"2008-12-06T01:31:52Z","isPatch":true,"sender":{"key":"theappleman@gmail.com","avatar":null},"body":"Commit 16fc08e2d86dad152194829d21bc55b2ef0c8fb1 introduced a\ntest that failed if the en_US.UTF-8 locale was not installed.\n\nMake the test find a UTF-8 locale, and expect failure.\n\nSigned-off-by: applehq <theappleman@gmail.com>\n---\n t/t9129-git-svn-i18n-commitencoding.sh |    9 +++++----\n 1 files changed, 5 insertions(+), 4 deletions(-)\n\ndiff --git a/t/t9129-git-svn-i18n-commitencoding.sh b/t/t9129-git-svn-i18n-commitencoding.sh\nindex 938b7fe..87ecdd0 100755\n--- a/t/t9129-git-svn-i18n-commitencoding.sh\n+++ b/t/t9129-git-svn-i18n-commitencoding.sh\n@@ -15,8 +15,9 @@ compare_git_head_with () {\n }\n \n compare_svn_head_with () {\n-\tLC_ALL=en_US.UTF-8 svn log --limit 1 `git svn info --url` | \\\n-\t\tsed -e 1,3d -e \"/^-\\{1,\\}\\$/d\" >current &&\n+\tLC_ALL=`locale -a | grep -i utf | head -1` \\\n+\t\tsvn log --limit 1 `git svn info --url` | \\\n+\t\t\tsed -e 1,3d -e \"/^-\\{1,\\}\\$/d\" >current &&\n \ttest_cmp current \"$1\"\n }\n \n@@ -60,7 +61,7 @@ do\n \t'\n done\n \n-test_expect_success 'ISO-8859-1 should match UTF-8 in svn' '\n+test_expect_failure 'ISO-8859-1 should match UTF-8 in svn' '\n (\n \tcd ISO-8859-1 &&\n \tcompare_svn_head_with \"$TEST_DIRECTORY\"/t3900/1-UTF-8.txt\n@@ -69,7 +70,7 @@ test_expect_success 'ISO-8859-1 should match UTF-8 in svn' '\n \n for H in EUCJP ISO-2022-JP\n do\n-\ttest_expect_success '$H should match UTF-8 in svn' '\n+\ttest_expect_failure '$H should match UTF-8 in svn' '\n \t(\n \t\tcd $H &&\n \t\tcompare_svn_head_with \"$TEST_DIRECTORY\"/t3900/2-UTF-8.txt\n-- \n1.6.1.rc1.53.g455b\n"},{"id":"97243","messageId":"7vk5aevz0h.fsf@gitster.siamese.dyndns.org","threadId":"16607","inReplyTo":"20081206013152.GA6129@cumin","subject":"Re: [PATCH] t9129: Prevent test failure if no UTF-8 locale","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2008-12-06T02:05:50Z","receivedAt":"2008-12-06T02:05:50Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"applehq <theappleman@gmail.com> writes:\n\n> Commit 16fc08e2d86dad152194829d21bc55b2ef0c8fb1 introduced a\n> test that failed if the en_US.UTF-8 locale was not installed.\n>\n> Make the test find a UTF-8 locale, and expect failure.\n\nNAK on the latter one.\n\ntest_expect_failure does not mean \"This might, and it is Ok to, fail\", as\nyou seem to think.  It means \"This should succeed if our software is not\nbuggy, but there is a known breakage to cause it to fail, so this test is\nmarked as such until the bug is fixed.\"\n\nSkipping the test on a platform that lacks necessary locale is fine, but\nif you run the test, they should expect success.  Otherwise you cannot\ntell if it is a platform issue (i.e. not having any UTF-8 locale) or\na bug in the software (i.e. git-svn not working as expected).\n\n> Signed-off-by: applehq <theappleman@gmail.com>\n\nSign off with an unreal name, hmm..., what good would that give us...?\n\n> @@ -15,8 +15,9 @@ compare_git_head_with () {\n>  }\n>  \n>  compare_svn_head_with () {\n> -\tLC_ALL=en_US.UTF-8 svn log --limit 1 `git svn info --url` | \\\n> -\t\tsed -e 1,3d -e \"/^-\\{1,\\}\\$/d\" >current &&\n> +\tLC_ALL=`locale -a | grep -i utf | head -1` \\\n> +\t\tsvn log --limit 1 `git svn info --url` | \\\n> +\t\t\tsed -e 1,3d -e \"/^-\\{1,\\}\\$/d\" >current &&\n\nI think what this part tries to do is good, in that we do not care if it\nis en_US UTF-8 or any other UTF-8.  But cramming that logic all in one\npipeline (and an inefficient one at that) makes it harder to read.\n\nDo something like this upfront:\n\n\ta_utf8_locale=$(locale -a | sed -ne '/[Uu][Tt][Ff]-*8/{\n        \tp\n                q\n\t'})\n\nand if that variable is empty then skip the test that relies on having a\nUTF-8 locale on the platform.  Then the function can say:\n\n\tLC_ALL=\"$a_utf8_locale\" svn log --limit 1 ...\n"}]}