diff mbox series

[v2,1/2] t0028: fix test for UTF-16-LE-BOM

Message ID d717a60932223443e95c000f4d17210b07d7b1a9.1569233057.git.gitgitgadget@gmail.com (mailing list archive)
State New, archived
Headers show
Series Update: fixed typos in commit message | expand

Commit Message

Linus Arver via GitGitGadget Sept. 23, 2019, 10:04 a.m. UTC
From: Alexandr Miloslavskiy <alexandr.miloslavskiy@syntevo.com>

According to its name, the test is designed for UTF-16-LE-BOM.
However, possibly due to copy&paste oversight, it was using UTF-32 file.

While the test succeeds (probably interprets extra \x00\x00 as embedded
zero), I myself had an unrelated problem which caused the test to fail.
When analyzing the failure I was quite puzzled by the fact that the
test is obviously bugged. And it seems that I'm not alone:
https://public-inbox.org/git/CAH8yC8kSakS807d4jc_BtcUJOrcVT4No37AXSz=jePxhw-o9Dg@mail.gmail.com/T/#u

This fix changes the test to follow its original intention.

Signed-off-by: Alexandr Miloslavskiy <alexandr.miloslavskiy@syntevo.com>
---
 t/t0028-working-tree-encoding.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Torsten Bögershausen Sept. 24, 2019, 3:46 a.m. UTC | #1
On Mon, Sep 23, 2019 at 03:04:19AM -0700, Alexandr Miloslavskiy via GitGitGadget wrote:
> From: Alexandr Miloslavskiy <alexandr.miloslavskiy@syntevo.com>
>
> According to its name, the test is designed for UTF-16-LE-BOM.
> However, possibly due to copy&paste oversight, it was using UTF-32 file.
>
> While the test succeeds (probably interprets extra \x00\x00 as embedded

We can probably drop the "probably" ?

> zero), I myself had an unrelated problem which caused the test to fail.

Out of curiosity:
What made the test fail, and does it pass noe ?

> When analyzing the failure I was quite puzzled by the fact that the
> test is obviously bugged. And it seems that I'm not alone:
> https://public-inbox.org/git/CAH8yC8kSakS807d4jc_BtcUJOrcVT4No37AXSz=jePxhw-o9Dg@mail.gmail.com/T/#u
>
> This fix changes the test to follow its original intention.

Thanks for debugging and cleaning up my mess.
The patch is correct, and I have one or two small improvements in the
wording.

How about the following:

According to its name, the test is designed for UTF-16-LE-BOM.
However, possibly due to copy&paste oversight, it was using UTF-32.

While the test succeeds (extra \000\000 are interpreted as NUL),
I myself had an unrelated problem which caused the test to fail.
When analyzing the failure I was quite puzzled by the fact that the
test is obviously bugged. And it seems that I'm not alone:
https://public-inbox.org/git/CAH8yC8kSakS807d4jc_BtcUJOrcVT4No37AXSz=jePxhw-o9Dg@mail.gmail.com/T/#u

Fix the test to follow its original intention.

>
> Signed-off-by: Alexandr Miloslavskiy <alexandr.miloslavskiy@syntevo.com>
> ---
>  t/t0028-working-tree-encoding.sh | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/t/t0028-working-tree-encoding.sh b/t/t0028-working-tree-encoding.sh
> index 1090e650ed..5493cf3ca9 100755
> --- a/t/t0028-working-tree-encoding.sh
> +++ b/t/t0028-working-tree-encoding.sh
> @@ -40,7 +40,7 @@ test_expect_success 'setup test files' '
>  	printf "$text" | write_utf16 >test.utf16.raw &&
>  	printf "$text" | write_utf32 >test.utf32.raw &&
>  	printf "\377\376"                         >test.utf16lebom.raw &&
> -	printf "$text" | iconv -f UTF-8 -t UTF-32LE >>test.utf16lebom.raw &&
> +	printf "$text" | iconv -f UTF-8 -t UTF-16LE >>test.utf16lebom.raw &&
>
>  	# Line ending tests
>  	printf "one\ntwo\nthree\n" >lf.utf8.raw &&
> --
> gitgitgadget
>
>
Alexandr Miloslavskiy Sept. 24, 2019, 9:53 a.m. UTC | #2
On 24.09.2019 5:46, Torsten Bögershausen wrote:
> Out of curiosity:
> What made the test fail, and does it pass noe ?

It failed to a bug in Windows Debug build, which caused iconv() to fail
in most cases, see:
https://public-inbox.org/git/pull.348.git.gitgitgadget@gmail.com/

> How about the following:

Sure thing, I will use the wording you suggested.
diff mbox series

Patch

diff --git a/t/t0028-working-tree-encoding.sh b/t/t0028-working-tree-encoding.sh
index 1090e650ed..5493cf3ca9 100755
--- a/t/t0028-working-tree-encoding.sh
+++ b/t/t0028-working-tree-encoding.sh
@@ -40,7 +40,7 @@  test_expect_success 'setup test files' '
 	printf "$text" | write_utf16 >test.utf16.raw &&
 	printf "$text" | write_utf32 >test.utf32.raw &&
 	printf "\377\376"                         >test.utf16lebom.raw &&
-	printf "$text" | iconv -f UTF-8 -t UTF-32LE >>test.utf16lebom.raw &&
+	printf "$text" | iconv -f UTF-8 -t UTF-16LE >>test.utf16lebom.raw &&
 
 	# Line ending tests
 	printf "one\ntwo\nthree\n" >lf.utf8.raw &&