Commit 1/2: t0028: fix test for UTF-16-LE-BOM Commit 2/2: t0028: add more tests Please refer to individual commit messages for more information. Alexandr Miloslavskiy (2): t0028: fix test for UTF-16-LE-BOM t0028: add more tests t/t0028-working-tree-encoding.sh | 41 +++++++++++++++++++++++++++++++- 1 file changed, 40 insertions(+), 1 deletion(-) base-commit: 4c86140027f4a0d2caaa3ab4bd8bfc5ce3c11c8a Published-As: https://github.com/gitgitgadget/git/releases/tag/pr-347%2FSyntevoAlex%2F%230189_t0028_fixes-v3 Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-347/SyntevoAlex/#0189_t0028_fixes-v3 Pull-Request: https://github.com/gitgitgadget/git/pull/347 Range-diff vs v2: 1: d717a60932 ! 1: 438ac961a5 t0028: fix test for UTF-16-LE-BOM @@ -3,15 +3,15 @@ t0028: fix test for UTF-16-LE-BOM 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. + However, possibly due to copy&paste oversight, it was using UTF-32. - While the test succeeds (probably interprets extra \x00\x00 as embedded - zero), I myself had an unrelated problem which caused the test to fail. + 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@xxxxxxxxxxxxxx/T/#u - This fix changes the test to follow its original intention. + Fix the test to follow its original intention. Signed-off-by: Alexandr Miloslavskiy <alexandr.miloslavskiy@xxxxxxxxxxx> 2: 40e54cf5ce ! 2: e4410274e6 t0028: add more tests @@ -2,9 +2,9 @@ t0028: add more tests - After I discovered that UTF-16-LE-BOM test was bugged and still - succeeded, I decided that better tests are required. Possibly the best - option here is to compare git results against hardcoded ground truth. + After I discovered that UTF-16-LE-BOM test was bugged, I decided that + better tests are required. Possibly the best option here is to compare + git results against hardcoded ground truth. The new tests also cover more interesting chars where (ANSI != UTF-8). @@ -25,26 +25,26 @@ + orig_string="$2" + expect_bytes="$3" + -+ test_expect_success "Commit utf-8, checkout ${encoding}" ' ++ test_expect_success "Commit UTF-8, checkout $encoding" ' + test_when_finished "git checkout HEAD -- .gitattributes" && + -+ test_ext="commit_utf8_checkout_${encoding}" && -+ test_file="test.${test_ext}" && ++ test_ext="commit_utf8_checkout_$encoding" && ++ test_file="test.$test_ext" && + -+ # Commit as utf-8 -+ echo "*.${test_ext} text working-tree-encoding=utf-8" >.gitattributes && -+ printf "${orig_string}" >"${test_file}" && -+ git add "${test_file}" && ++ # Commit as UTF-8 ++ echo "*.$test_ext text working-tree-encoding=UTF-8" >.gitattributes && ++ printf "$orig_string" >$test_file && ++ git add $test_file && + git commit -m "Test data" && + + # Checkout in tested encoding -+ rm "${test_file}" && -+ echo "*.${test_ext} text working-tree-encoding=${encoding}" >.gitattributes && -+ git checkout HEAD -- "${test_file}" && ++ rm $test_file && ++ echo "*.$test_ext text working-tree-encoding=$encoding" >.gitattributes && ++ git checkout HEAD -- $test_file && + + # Test -+ printf "${expect_bytes}" > "${test_file}.raw" && -+ test_cmp_bin "${test_file}.raw" "${test_file}" ++ printf $expect_bytes >$test_file.raw && ++ test_cmp_bin $test_file.raw $test_file + ' +} + -- gitgitgadget