t3910: use the UTF8_NFD_TO_NFC test prereq

Besides reusing the new test prerequisite, this fixes also the issue
that the current output is not TAP compliant and produces the output "no
reason given" [for skipping].

Signed-off-by: Michael J Gruber <git@drmicha.warpmail.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
Michael J Gruber 2012-07-30 11:57:18 +02:00 committed by Junio C Hamano
parent 5b0b5dd49b
commit 308566eb8b

View file

@ -7,158 +7,147 @@ test_description='utf-8 decomposed (nfd) converted to precomposed (nfc)'
. ./test-lib.sh . ./test-lib.sh
if ! test_have_prereq UTF8_NFD_TO_NFC
then
skip_all="filesystem does not corrupt utf-8"
test_done
fi
# create utf-8 variables
Adiarnfc=`printf '\303\204'` Adiarnfc=`printf '\303\204'`
Adiarnfd=`printf 'A\314\210'` Adiarnfd=`printf 'A\314\210'`
# check if the feature is compiled in Odiarnfc=`printf '\303\226'`
mkdir junk && Odiarnfd=`printf 'O\314\210'`
>junk/"$Adiarnfc" && AEligatu=`printf '\303\206'`
case "$(cd junk && echo *)" in Invalidu=`printf '\303\377'`
"$Adiarnfd")
test_nfd=1
;;
*) ;;
esac
rm -rf junk
if test "$test_nfd" #Create a string with 255 bytes (decomposed)
then Alongd=$Adiarnfd$Adiarnfd$Adiarnfd$Adiarnfd$Adiarnfd$Adiarnfd$Adiarnfd #21 Byte
# create more utf-8 variables Alongd=$Alongd$Alongd$Alongd #63 Byte
Odiarnfc=`printf '\303\226'` Alongd=$Alongd$Alongd$Alongd$Alongd$Adiarnfd #255 Byte
Odiarnfd=`printf 'O\314\210'`
AEligatu=`printf '\303\206'`
Invalidu=`printf '\303\377'`
#Create a string with 254 bytes (precomposed)
Alongc=$AEligatu$AEligatu$AEligatu$AEligatu$AEligatu #10 Byte
Alongc=$Alongc$Alongc$Alongc$Alongc$Alongc #50 Byte
Alongc=$Alongc$Alongc$Alongc$Alongc$Alongc #250 Byte
Alongc=$Alongc$AEligatu$AEligatu #254 Byte
#Create a string with 255 bytes (decomposed) test_expect_success "detect if nfd needed" '
Alongd=$Adiarnfd$Adiarnfd$Adiarnfd$Adiarnfd$Adiarnfd$Adiarnfd$Adiarnfd #21 Byte precomposeunicode=`git config core.precomposeunicode` &&
Alongd=$Alongd$Alongd$Alongd #63 Byte test "$precomposeunicode" = false &&
Alongd=$Alongd$Alongd$Alongd$Alongd$Adiarnfd #255 Byte git config core.precomposeunicode true
'
#Create a string with 254 bytes (precomposed) test_expect_success "setup" '
Alongc=$AEligatu$AEligatu$AEligatu$AEligatu$AEligatu #10 Byte >x &&
Alongc=$Alongc$Alongc$Alongc$Alongc$Alongc #50 Byte git add x &&
Alongc=$Alongc$Alongc$Alongc$Alongc$Alongc #250 Byte git commit -m "1st commit" &&
Alongc=$Alongc$AEligatu$AEligatu #254 Byte git rm x &&
git commit -m "rm x"
test_expect_success "detect if nfd needed" ' '
precomposeunicode=`git config core.precomposeunicode` && test_expect_success "setup case mac" '
test "$precomposeunicode" = false && git checkout -b mac_os
git config core.precomposeunicode true '
' # This will test nfd2nfc in readdir()
test_expect_success "setup" ' test_expect_success "add file Adiarnfc" '
>x && echo f.Adiarnfc >f.$Adiarnfc &&
git add x && git add f.$Adiarnfc &&
git commit -m "1st commit" && git commit -m "add f.$Adiarnfc"
git rm x && '
git commit -m "rm x" # This will test nfd2nfc in git stage()
' test_expect_success "stage file d.Adiarnfd/f.Adiarnfd" '
test_expect_success "setup case mac" ' mkdir d.$Adiarnfd &&
git checkout -b mac_os echo d.$Adiarnfd/f.$Adiarnfd >d.$Adiarnfd/f.$Adiarnfd &&
' git stage d.$Adiarnfd/f.$Adiarnfd &&
# This will test nfd2nfc in readdir() git commit -m "add d.$Adiarnfd/f.$Adiarnfd"
test_expect_success "add file Adiarnfc" ' '
echo f.Adiarnfc >f.$Adiarnfc && test_expect_success "add link Adiarnfc" '
git add f.$Adiarnfc && ln -s d.$Adiarnfd/f.$Adiarnfd l.$Adiarnfc &&
git commit -m "add f.$Adiarnfc" git add l.$Adiarnfc &&
' git commit -m "add l.Adiarnfc"
# This will test nfd2nfc in git stage() '
test_expect_success "stage file d.Adiarnfd/f.Adiarnfd" ' # This will test git log
mkdir d.$Adiarnfd && test_expect_success "git log f.Adiar" '
echo d.$Adiarnfd/f.$Adiarnfd >d.$Adiarnfd/f.$Adiarnfd && git log f.$Adiarnfc > f.Adiarnfc.log &&
git stage d.$Adiarnfd/f.$Adiarnfd && git log f.$Adiarnfd > f.Adiarnfd.log &&
git commit -m "add d.$Adiarnfd/f.$Adiarnfd" test -s f.Adiarnfc.log &&
' test -s f.Adiarnfd.log &&
test_expect_success "add link Adiarnfc" ' test_cmp f.Adiarnfc.log f.Adiarnfd.log &&
ln -s d.$Adiarnfd/f.$Adiarnfd l.$Adiarnfc && rm f.Adiarnfc.log f.Adiarnfd.log
git add l.$Adiarnfc && '
git commit -m "add l.Adiarnfc" # This will test git ls-files
' test_expect_success "git lsfiles f.Adiar" '
# This will test git log git ls-files f.$Adiarnfc > f.Adiarnfc.log &&
test_expect_success "git log f.Adiar" ' git ls-files f.$Adiarnfd > f.Adiarnfd.log &&
git log f.$Adiarnfc > f.Adiarnfc.log && test -s f.Adiarnfc.log &&
git log f.$Adiarnfd > f.Adiarnfd.log && test -s f.Adiarnfd.log &&
test -s f.Adiarnfc.log && test_cmp f.Adiarnfc.log f.Adiarnfd.log &&
test -s f.Adiarnfd.log && rm f.Adiarnfc.log f.Adiarnfd.log
test_cmp f.Adiarnfc.log f.Adiarnfd.log && '
rm f.Adiarnfc.log f.Adiarnfd.log # This will test git mv
' test_expect_success "git mv" '
# This will test git ls-files git mv f.$Adiarnfd f.$Odiarnfc &&
test_expect_success "git lsfiles f.Adiar" ' git mv d.$Adiarnfd d.$Odiarnfc &&
git ls-files f.$Adiarnfc > f.Adiarnfc.log && git mv l.$Adiarnfd l.$Odiarnfc &&
git ls-files f.$Adiarnfd > f.Adiarnfd.log && git commit -m "mv Adiarnfd Odiarnfc"
test -s f.Adiarnfc.log && '
test -s f.Adiarnfd.log && # Files can be checked out as nfc
test_cmp f.Adiarnfc.log f.Adiarnfd.log && # And the link has been corrected from nfd to nfc
rm f.Adiarnfc.log f.Adiarnfd.log test_expect_success "git checkout nfc" '
' rm f.$Odiarnfc &&
# This will test git mv git checkout f.$Odiarnfc
test_expect_success "git mv" ' '
git mv f.$Adiarnfd f.$Odiarnfc && # Make it possible to checkout files with their NFD names
git mv d.$Adiarnfd d.$Odiarnfc && test_expect_success "git checkout file nfd" '
git mv l.$Adiarnfd l.$Odiarnfc && rm -f f.* &&
git commit -m "mv Adiarnfd Odiarnfc" git checkout f.$Odiarnfd
' '
# Files can be checked out as nfc # Make it possible to checkout links with their NFD names
# And the link has been corrected from nfd to nfc test_expect_success "git checkout link nfd" '
test_expect_success "git checkout nfc" ' rm l.* &&
rm f.$Odiarnfc && git checkout l.$Odiarnfd
git checkout f.$Odiarnfc '
' test_expect_success "setup case mac2" '
# Make it possible to checkout files with their NFD names git checkout master &&
test_expect_success "git checkout file nfd" ' git reset --hard &&
rm -f f.* && git checkout -b mac_os_2
git checkout f.$Odiarnfd '
' # This will test nfd2nfc in git commit
# Make it possible to checkout links with their NFD names test_expect_success "commit file d2.Adiarnfd/f.Adiarnfd" '
test_expect_success "git checkout link nfd" ' mkdir d2.$Adiarnfd &&
rm l.* && echo d2.$Adiarnfd/f.$Adiarnfd >d2.$Adiarnfd/f.$Adiarnfd &&
git checkout l.$Odiarnfd git add d2.$Adiarnfd/f.$Adiarnfd &&
' git commit -m "add d2.$Adiarnfd/f.$Adiarnfd" -- d2.$Adiarnfd/f.$Adiarnfd
test_expect_success "setup case mac2" ' '
git checkout master && test_expect_success "setup for long decomposed filename" '
git reset --hard && git checkout master &&
git checkout -b mac_os_2 git reset --hard &&
' git checkout -b mac_os_long_nfd_fn
# This will test nfd2nfc in git commit '
test_expect_success "commit file d2.Adiarnfd/f.Adiarnfd" ' test_expect_success "Add long decomposed filename" '
mkdir d2.$Adiarnfd && echo longd >$Alongd &&
echo d2.$Adiarnfd/f.$Adiarnfd >d2.$Adiarnfd/f.$Adiarnfd && git add * &&
git add d2.$Adiarnfd/f.$Adiarnfd && git commit -m "Long filename"
git commit -m "add d2.$Adiarnfd/f.$Adiarnfd" -- d2.$Adiarnfd/f.$Adiarnfd '
' test_expect_success "setup for long precomposed filename" '
test_expect_success "setup for long decomposed filename" ' git checkout master &&
git checkout master && git reset --hard &&
git reset --hard && git checkout -b mac_os_long_nfc_fn
git checkout -b mac_os_long_nfd_fn '
' test_expect_success "Add long precomposed filename" '
test_expect_success "Add long decomposed filename" ' echo longc >$Alongc &&
echo longd >$Alongd && git add * &&
git add * && git commit -m "Long filename"
git commit -m "Long filename" '
' # Test if the global core.precomposeunicode stops autosensing
test_expect_success "setup for long precomposed filename" ' # Must be the last test case
git checkout master && test_expect_success "respect git config --global core.precomposeunicode" '
git reset --hard && git config --global core.precomposeunicode true &&
git checkout -b mac_os_long_nfc_fn rm -rf .git &&
' git init &&
test_expect_success "Add long precomposed filename" ' precomposeunicode=`git config core.precomposeunicode` &&
echo longc >$Alongc && test "$precomposeunicode" = "true"
git add * && '
git commit -m "Long filename"
'
# Test if the global core.precomposeunicode stops autosensing
# Must be the last test case
test_expect_success "respect git config --global core.precomposeunicode" '
git config --global core.precomposeunicode true &&
rm -rf .git &&
git init &&
precomposeunicode=`git config core.precomposeunicode` &&
test "$precomposeunicode" = "true"
'
else
say "Skipping nfc/nfd tests"
fi
test_done test_done