From f3cfc3b27168a085d4ca7ab5801814c4f419b54d Mon Sep 17 00:00:00 2001 From: Junio C Hamano Date: Thu, 26 Jul 2012 13:57:56 -0700 Subject: test: rename $satisfied to $satisfied_prereq All other shell variables that are used to globally keep track of states related to prerequisite have "prereq" somewhere in their names. Be consistent and avoid potential name crashes with other kinds of satisfaction in the future. Signed-off-by: Junio C Hamano --- t/test-lib-functions.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/t/test-lib-functions.sh b/t/test-lib-functions.sh index 80daaca780..4dc027d406 100644 --- a/t/test-lib-functions.sh +++ b/t/test-lib-functions.sh @@ -221,9 +221,9 @@ write_script () { # capital letters by convention). test_set_prereq () { - satisfied="$satisfied$1 " + satisfied_prereq="$satisfied_prereq$1 " } -satisfied=" " +satisfied_prereq=" " test_have_prereq () { # prerequisites can be concatenated with ',' @@ -239,7 +239,7 @@ test_have_prereq () { for prerequisite do total_prereq=$(($total_prereq + 1)) - case $satisfied in + case "$satisfied_prereq" in *" $prerequisite "*) ok_prereq=$(($ok_prereq + 1)) ;; -- cgit v1.2.3 From 04083f278d19998e0e3f26627791ab54886ac12a Mon Sep 17 00:00:00 2001 From: Junio C Hamano Date: Thu, 26 Jul 2012 15:50:45 -0700 Subject: test: allow prerequisite to be evaluated lazily The test prerequisite mechanism is a useful way to allow some tests in a test script to be skipped in environments that do not support certain features (e.g. it is pointless to attempt checking how well symbolic links are handled by Git on filesystems that do not support them). It is OK for commonly used prerequisites to be always tested during start-up of a test script by having a codeblock that tests a feature and calls test_set_prereq, but for an uncommon feature, forcing 90% of scripts to pay the same probing overhead for prerequisite they do not care about is wasteful. Introduce a mechanism to probe the prerequiste lazily. Changes are: - test_lazy_prereq () function, which takes the name of the prerequisite it probes and the script to probe for it, is added. This only registers the name of the prerequiste that can be lazily probed and the script to eval (without running). - test_have_prereq() function (which is used by test_expect_success and also can be called directly by test scripts) learns to look at the list of prerequisites that can be lazily probed, and the prerequisites that have already been probed that way. When asked for a prerequiste that can be but haven't been probed, the script registered with an earlier call to test_lazy_prereq is evaluated and the prerequisite is set. - test_run_lazy_prereq_() function is a helper to run the probe script with the same kind of sandbox as regular tests, helped by Jeff King. Update the codeblock to probe and set SYMLINKS prerequisite using the new mechanism as an example. Signed-off-by: Junio C Hamano --- t/test-lib-functions.sh | 42 ++++++++++++++++++++++++++++++++++++++++++ t/test-lib.sh | 7 ++++--- 2 files changed, 46 insertions(+), 3 deletions(-) diff --git a/t/test-lib-functions.sh b/t/test-lib-functions.sh index 4dc027d406..04b1a43ef2 100644 --- a/t/test-lib-functions.sh +++ b/t/test-lib-functions.sh @@ -224,6 +224,32 @@ test_set_prereq () { satisfied_prereq="$satisfied_prereq$1 " } satisfied_prereq=" " +lazily_testable_prereq= lazily_tested_prereq= + +# Usage: test_lazy_prereq PREREQ 'script' +test_lazy_prereq () { + lazily_testable_prereq="$lazily_testable_prereq$1 " + eval test_prereq_lazily_$1=\$2 +} + +test_run_lazy_prereq_ () { + script=' +mkdir -p "$TRASH_DIRECTORY/prereq-test-dir" && +( + cd "$TRASH_DIRECTORY/prereq-test-dir" &&'"$2"' +)' + say >&3 "checking prerequisite: $1" + say >&3 "$script" + test_eval_ "$script" + eval_ret=$? + rm -rf "$TRASH_DIRECTORY/prereq-test-dir" + if test "$eval_ret" = 0; then + say >&3 "prerequisite $1 ok" + else + say >&3 "prerequisite $1 not satisfied" + fi + return $eval_ret +} test_have_prereq () { # prerequisites can be concatenated with ',' @@ -238,6 +264,22 @@ test_have_prereq () { for prerequisite do + case " $lazily_tested_prereq " in + *" $prerequisite "*) + ;; + *) + case " $lazily_testable_prereq " in + *" $prerequisite "*) + eval "script=\$test_prereq_lazily_$prerequisite" && + if test_run_lazy_prereq_ "$prerequisite" "$script" + then + test_set_prereq $prerequisite + fi + lazily_tested_prereq="$lazily_tested_prereq$prerequisite " + esac + ;; + esac + total_prereq=$(($total_prereq + 1)) case "$satisfied_prereq" in *" $prerequisite "*) diff --git a/t/test-lib.sh b/t/test-lib.sh index bb4f8865b2..35739b9fbe 100644 --- a/t/test-lib.sh +++ b/t/test-lib.sh @@ -659,9 +659,10 @@ test_i18ngrep () { fi } -# test whether the filesystem supports symbolic links -ln -s x y 2>/dev/null && test -h y 2>/dev/null && test_set_prereq SYMLINKS -rm -f y +test_lazy_prereq SYMLINKS ' + # test whether the filesystem supports symbolic links + ln -s x y && test -h y +' # When the tests are run as root, permission tests will report that # things are writable when they shouldn't be. -- cgit v1.2.3 From ac39aa612147b595e02876a4c9d6ca7e8063ba3d Mon Sep 17 00:00:00 2001 From: Michael J Gruber Date: Thu, 26 Jul 2012 15:39:53 +0200 Subject: test-lib: provide case insensitivity as a prerequisite Case insensitivity plays a role in several tests and is tested in several tests. Therefore, move the test from t003 into the test lib and use the prerequisite in t0003. Signed-off-by: Michael J Gruber Signed-off-by: Junio C Hamano --- t/README | 4 ++++ t/t0003-attributes.sh | 10 ---------- t/test-lib.sh | 6 ++++++ 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/t/README b/t/README index 4c3ea25e66..5725607448 100644 --- a/t/README +++ b/t/README @@ -625,6 +625,10 @@ use these, and "test_set_prereq" for how to define your own. Git was compiled with USE_LIBPCRE=YesPlease. Wrap any tests that use git-grep --perl-regexp or git-grep -P in these. + - CASE_INSENSITIVE_FS + + Test is run on a case insensitive file system. + Tips for Writing Tests ---------------------- diff --git a/t/t0003-attributes.sh b/t/t0003-attributes.sh index 51f3045ba4..febc45c9cc 100755 --- a/t/t0003-attributes.sh +++ b/t/t0003-attributes.sh @@ -123,16 +123,6 @@ test_expect_success 'attribute matching is case insensitive when core.ignorecase ' -test_expect_success 'check whether FS is case-insensitive' ' - mkdir junk && - echo good >junk/CamelCase && - echo bad >junk/camelcase && - if test "$(cat junk/CamelCase)" != good - then - test_set_prereq CASE_INSENSITIVE_FS - fi -' - test_expect_success CASE_INSENSITIVE_FS 'additional case insensitivity tests' ' test_must_fail attr_check a/B/D/g "a/b/d/*" "-c core.ignorecase=0" && test_must_fail attr_check A/B/D/NO "a/b/d/*" "-c core.ignorecase=0" && diff --git a/t/test-lib.sh b/t/test-lib.sh index 35739b9fbe..81cf4dfb04 100644 --- a/t/test-lib.sh +++ b/t/test-lib.sh @@ -664,6 +664,12 @@ test_lazy_prereq SYMLINKS ' ln -s x y && test -h y ' +test_lazy_prereq CASE_INSENSITIVE_FS ' + echo good >CamelCase && + echo bad >camelcase && + test "$(cat CamelCase)" != good +' + # When the tests are run as root, permission tests will report that # things are writable when they shouldn't be. test -w / || test_set_prereq SANITY -- cgit v1.2.3 From 9a3658b97726df53453bd97add50d267f9ab2978 Mon Sep 17 00:00:00 2001 From: Michael J Gruber Date: Thu, 26 Jul 2012 15:39:54 +0200 Subject: t0050: use the CASE_INSENSITIVE_FS test prereq Signed-off-by: Michael J Gruber Signed-off-by: Junio C Hamano --- t/t0050-filesystem.sh | 21 ++++++++------------- 1 file changed, 8 insertions(+), 13 deletions(-) diff --git a/t/t0050-filesystem.sh b/t/t0050-filesystem.sh index 1542cf6a13..df9498b7d0 100755 --- a/t/t0050-filesystem.sh +++ b/t/t0050-filesystem.sh @@ -7,23 +7,12 @@ test_description='Various filesystem issues' auml=$(printf '\303\244') aumlcdiar=$(printf '\141\314\210') -case_insensitive= unibad= no_symlinks= test_expect_success 'see what we expect' ' - test_case=test_expect_success && test_unicode=test_expect_success && mkdir junk && - echo good >junk/CamelCase && - echo bad >junk/camelcase && - if test "$(cat junk/CamelCase)" != good - then - test_case=test_expect_failure && - case_insensitive=t - fi && - rm -fr junk && - mkdir junk && >junk/"$auml" && case "$(cd junk && echo *)" in "$aumlcdiar") @@ -41,14 +30,20 @@ test_expect_success 'see what we expect' ' } ' -test "$case_insensitive" && +if test_have_prereq CASE_INSENSITIVE_FS +then say "will test on a case insensitive filesystem" + test_case=test_expect_failure +else + test_case=test_expect_success +fi + test "$unibad" && say "will test on a unicode corrupting filesystem" test "$no_symlinks" && say "will test on a filesystem lacking symbolic links" -if test "$case_insensitive" +if test_have_prereq CASE_INSENSITIVE_FS then test_expect_success "detection of case insensitive filesystem during repo init" ' -- cgit v1.2.3 From 2b71b5221a66abd881919dd45609285e7af5c56f Mon Sep 17 00:00:00 2001 From: Michael J Gruber Date: Thu, 26 Jul 2012 15:39:55 +0200 Subject: t0050: use the SYMLINKS test prereq Signed-off-by: Michael J Gruber Signed-off-by: Junio C Hamano --- t/t0050-filesystem.sh | 21 +++++++-------------- 1 file changed, 7 insertions(+), 14 deletions(-) diff --git a/t/t0050-filesystem.sh b/t/t0050-filesystem.sh index df9498b7d0..b46ae72eac 100755 --- a/t/t0050-filesystem.sh +++ b/t/t0050-filesystem.sh @@ -8,7 +8,6 @@ auml=$(printf '\303\244') aumlcdiar=$(printf '\141\314\210') unibad= -no_symlinks= test_expect_success 'see what we expect' ' test_unicode=test_expect_success && @@ -21,13 +20,7 @@ test_expect_success 'see what we expect' ' ;; *) ;; esac && - rm -fr junk && - { - ln -s x y 2> /dev/null && - test -h y 2> /dev/null || - no_symlinks=1 && - rm -f y - } + rm -fr junk ' if test_have_prereq CASE_INSENSITIVE_FS @@ -40,7 +33,7 @@ fi test "$unibad" && say "will test on a unicode corrupting filesystem" -test "$no_symlinks" && +test_have_prereq SYMLINKS || say "will test on a filesystem lacking symbolic links" if test_have_prereq CASE_INSENSITIVE_FS @@ -57,18 +50,18 @@ test_expect_success "detection of case insensitive filesystem during repo init" ' fi -if test "$no_symlinks" +if test_have_prereq SYMLINKS then test_expect_success "detection of filesystem w/o symlink support during repo init" ' - v=$(git config --bool core.symlinks) && - test "$v" = false + test_must_fail git config --bool core.symlinks || + test "$(git config --bool core.symlinks)" = true ' else test_expect_success "detection of filesystem w/o symlink support during repo init" ' - test_must_fail git config --bool core.symlinks || - test "$(git config --bool core.symlinks)" = true + v=$(git config --bool core.symlinks) && + test "$v" = false ' fi -- cgit v1.2.3 From 5b0b5dd49b55e474a2df502902682853e2cd6e9d Mon Sep 17 00:00:00 2001 From: Michael J Gruber Date: Thu, 26 Jul 2012 15:39:56 +0200 Subject: test-lib: provide UTF8 behaviour as a prerequisite UTF8 behaviour of the filesystem (conversion from nfd to nfc) plays a role in several tests and is tested in several tests. Therefore, move the test from t0050 into the test lib and use the prerequisite in t0050. Signed-off-by: Michael J Gruber Signed-off-by: Junio C Hamano --- t/README | 5 +++++ t/t0050-filesystem.sh | 24 +++++++----------------- t/test-lib.sh | 13 +++++++++++++ 3 files changed, 25 insertions(+), 17 deletions(-) diff --git a/t/README b/t/README index 5725607448..e4128e5769 100644 --- a/t/README +++ b/t/README @@ -629,6 +629,11 @@ use these, and "test_set_prereq" for how to define your own. Test is run on a case insensitive file system. + - UTF8_NFD_TO_NFC + + Test is run on a filesystem which converts decomposed utf-8 (nfd) + to precomposed utf-8 (nfc). + Tips for Writing Tests ---------------------- diff --git a/t/t0050-filesystem.sh b/t/t0050-filesystem.sh index b46ae72eac..78816d9d93 100755 --- a/t/t0050-filesystem.sh +++ b/t/t0050-filesystem.sh @@ -7,22 +7,6 @@ test_description='Various filesystem issues' auml=$(printf '\303\244') aumlcdiar=$(printf '\141\314\210') -unibad= -test_expect_success 'see what we expect' ' - - test_unicode=test_expect_success && - mkdir junk && - >junk/"$auml" && - case "$(cd junk && echo *)" in - "$aumlcdiar") - test_unicode=test_expect_failure && - unibad=t - ;; - *) ;; - esac && - rm -fr junk -' - if test_have_prereq CASE_INSENSITIVE_FS then say "will test on a case insensitive filesystem" @@ -31,8 +15,14 @@ else test_case=test_expect_success fi -test "$unibad" && +if test_have_prereq UTF8_NFD_TO_NFC +then say "will test on a unicode corrupting filesystem" + test_unicode=test_expect_failure +else + test_unicode=test_expect_success +fi + test_have_prereq SYMLINKS || say "will test on a filesystem lacking symbolic links" diff --git a/t/test-lib.sh b/t/test-lib.sh index 81cf4dfb04..78c428619e 100644 --- a/t/test-lib.sh +++ b/t/test-lib.sh @@ -670,6 +670,19 @@ test_lazy_prereq CASE_INSENSITIVE_FS ' test "$(cat CamelCase)" != good ' +test_lazy_prereq UTF8_NFD_TO_NFC ' + # check whether FS converts nfd unicode to nfc + auml=$(printf "\303\244") + aumlcdiar=$(printf "\141\314\210") + >"$auml" && + case "$(echo *)" in + "$aumlcdiar") + true ;; + *) + false ;; + esac +' + # When the tests are run as root, permission tests will report that # things are writable when they shouldn't be. test -w / || test_set_prereq SANITY -- cgit v1.2.3 From 308566eb8b35b9279082bd5398c4252169d52b22 Mon Sep 17 00:00:00 2001 From: Michael J Gruber Date: Mon, 30 Jul 2012 11:57:18 +0200 Subject: 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 Signed-off-by: Junio C Hamano --- t/t3910-mac-os-precompose.sh | 281 +++++++++++++++++++++---------------------- 1 file changed, 135 insertions(+), 146 deletions(-) diff --git a/t/t3910-mac-os-precompose.sh b/t/t3910-mac-os-precompose.sh index 88b7a20c11..5fe57c5438 100755 --- a/t/t3910-mac-os-precompose.sh +++ b/t/t3910-mac-os-precompose.sh @@ -7,158 +7,147 @@ test_description='utf-8 decomposed (nfd) converted to precomposed (nfc)' . ./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'` Adiarnfd=`printf 'A\314\210'` -# check if the feature is compiled in -mkdir junk && ->junk/"$Adiarnfc" && -case "$(cd junk && echo *)" in - "$Adiarnfd") - test_nfd=1 - ;; - *) ;; -esac -rm -rf junk +Odiarnfc=`printf '\303\226'` +Odiarnfd=`printf 'O\314\210'` +AEligatu=`printf '\303\206'` +Invalidu=`printf '\303\377'` -if test "$test_nfd" -then - # create more utf-8 variables - Odiarnfc=`printf '\303\226'` - Odiarnfd=`printf 'O\314\210'` - AEligatu=`printf '\303\206'` - Invalidu=`printf '\303\377'` +#Create a string with 255 bytes (decomposed) +Alongd=$Adiarnfd$Adiarnfd$Adiarnfd$Adiarnfd$Adiarnfd$Adiarnfd$Adiarnfd #21 Byte +Alongd=$Alongd$Alongd$Alongd #63 Byte +Alongd=$Alongd$Alongd$Alongd$Alongd$Adiarnfd #255 Byte +#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) - Alongd=$Adiarnfd$Adiarnfd$Adiarnfd$Adiarnfd$Adiarnfd$Adiarnfd$Adiarnfd #21 Byte - Alongd=$Alongd$Alongd$Alongd #63 Byte - Alongd=$Alongd$Alongd$Alongd$Alongd$Adiarnfd #255 Byte - - #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 - - test_expect_success "detect if nfd needed" ' - precomposeunicode=`git config core.precomposeunicode` && - test "$precomposeunicode" = false && - git config core.precomposeunicode true - ' - test_expect_success "setup" ' - >x && - git add x && - git commit -m "1st commit" && - git rm x && - git commit -m "rm x" - ' - test_expect_success "setup case mac" ' - git checkout -b mac_os - ' - # This will test nfd2nfc in readdir() - test_expect_success "add file Adiarnfc" ' - echo f.Adiarnfc >f.$Adiarnfc && - git add f.$Adiarnfc && - git commit -m "add f.$Adiarnfc" - ' - # This will test nfd2nfc in git stage() - test_expect_success "stage file d.Adiarnfd/f.Adiarnfd" ' - mkdir d.$Adiarnfd && - echo d.$Adiarnfd/f.$Adiarnfd >d.$Adiarnfd/f.$Adiarnfd && - git stage d.$Adiarnfd/f.$Adiarnfd && - git commit -m "add d.$Adiarnfd/f.$Adiarnfd" - ' - test_expect_success "add link Adiarnfc" ' - ln -s d.$Adiarnfd/f.$Adiarnfd l.$Adiarnfc && - git add l.$Adiarnfc && - git commit -m "add l.Adiarnfc" - ' - # This will test git log - test_expect_success "git log f.Adiar" ' - git log f.$Adiarnfc > f.Adiarnfc.log && - git log f.$Adiarnfd > f.Adiarnfd.log && - test -s f.Adiarnfc.log && - test -s f.Adiarnfd.log && - test_cmp f.Adiarnfc.log f.Adiarnfd.log && - rm f.Adiarnfc.log f.Adiarnfd.log - ' - # This will test git ls-files - test_expect_success "git lsfiles f.Adiar" ' - git ls-files f.$Adiarnfc > f.Adiarnfc.log && - git ls-files f.$Adiarnfd > f.Adiarnfd.log && - test -s f.Adiarnfc.log && - test -s 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" ' - git mv f.$Adiarnfd f.$Odiarnfc && - git mv d.$Adiarnfd d.$Odiarnfc && - git mv l.$Adiarnfd l.$Odiarnfc && - git commit -m "mv Adiarnfd Odiarnfc" - ' - # Files can be checked out as nfc - # And the link has been corrected from nfd to nfc - test_expect_success "git checkout nfc" ' - rm f.$Odiarnfc && - git checkout f.$Odiarnfc - ' - # Make it possible to checkout files with their NFD names - test_expect_success "git checkout file nfd" ' - rm -f f.* && - git checkout f.$Odiarnfd - ' - # Make it possible to checkout links with their NFD names - test_expect_success "git checkout link nfd" ' - rm l.* && - git checkout l.$Odiarnfd - ' - test_expect_success "setup case mac2" ' - git checkout master && - git reset --hard && - git checkout -b mac_os_2 - ' - # This will test nfd2nfc in git commit - test_expect_success "commit file d2.Adiarnfd/f.Adiarnfd" ' - mkdir d2.$Adiarnfd && - echo d2.$Adiarnfd/f.$Adiarnfd >d2.$Adiarnfd/f.$Adiarnfd && - git add d2.$Adiarnfd/f.$Adiarnfd && - git commit -m "add d2.$Adiarnfd/f.$Adiarnfd" -- d2.$Adiarnfd/f.$Adiarnfd - ' - test_expect_success "setup for long decomposed filename" ' - git checkout master && - git reset --hard && - git checkout -b mac_os_long_nfd_fn - ' - test_expect_success "Add long decomposed filename" ' - echo longd >$Alongd && - git add * && - git commit -m "Long filename" - ' - test_expect_success "setup for long precomposed filename" ' - git checkout master && - git reset --hard && - git checkout -b mac_os_long_nfc_fn - ' - test_expect_success "Add long precomposed filename" ' - echo longc >$Alongc && - 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_expect_success "detect if nfd needed" ' + precomposeunicode=`git config core.precomposeunicode` && + test "$precomposeunicode" = false && + git config core.precomposeunicode true +' +test_expect_success "setup" ' + >x && + git add x && + git commit -m "1st commit" && + git rm x && + git commit -m "rm x" +' +test_expect_success "setup case mac" ' + git checkout -b mac_os +' +# This will test nfd2nfc in readdir() +test_expect_success "add file Adiarnfc" ' + echo f.Adiarnfc >f.$Adiarnfc && + git add f.$Adiarnfc && + git commit -m "add f.$Adiarnfc" +' +# This will test nfd2nfc in git stage() +test_expect_success "stage file d.Adiarnfd/f.Adiarnfd" ' + mkdir d.$Adiarnfd && + echo d.$Adiarnfd/f.$Adiarnfd >d.$Adiarnfd/f.$Adiarnfd && + git stage d.$Adiarnfd/f.$Adiarnfd && + git commit -m "add d.$Adiarnfd/f.$Adiarnfd" +' +test_expect_success "add link Adiarnfc" ' + ln -s d.$Adiarnfd/f.$Adiarnfd l.$Adiarnfc && + git add l.$Adiarnfc && + git commit -m "add l.Adiarnfc" +' +# This will test git log +test_expect_success "git log f.Adiar" ' + git log f.$Adiarnfc > f.Adiarnfc.log && + git log f.$Adiarnfd > f.Adiarnfd.log && + test -s f.Adiarnfc.log && + test -s f.Adiarnfd.log && + test_cmp f.Adiarnfc.log f.Adiarnfd.log && + rm f.Adiarnfc.log f.Adiarnfd.log +' +# This will test git ls-files +test_expect_success "git lsfiles f.Adiar" ' + git ls-files f.$Adiarnfc > f.Adiarnfc.log && + git ls-files f.$Adiarnfd > f.Adiarnfd.log && + test -s f.Adiarnfc.log && + test -s 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" ' + git mv f.$Adiarnfd f.$Odiarnfc && + git mv d.$Adiarnfd d.$Odiarnfc && + git mv l.$Adiarnfd l.$Odiarnfc && + git commit -m "mv Adiarnfd Odiarnfc" +' +# Files can be checked out as nfc +# And the link has been corrected from nfd to nfc +test_expect_success "git checkout nfc" ' + rm f.$Odiarnfc && + git checkout f.$Odiarnfc +' +# Make it possible to checkout files with their NFD names +test_expect_success "git checkout file nfd" ' + rm -f f.* && + git checkout f.$Odiarnfd +' +# Make it possible to checkout links with their NFD names +test_expect_success "git checkout link nfd" ' + rm l.* && + git checkout l.$Odiarnfd +' +test_expect_success "setup case mac2" ' + git checkout master && + git reset --hard && + git checkout -b mac_os_2 +' +# This will test nfd2nfc in git commit +test_expect_success "commit file d2.Adiarnfd/f.Adiarnfd" ' + mkdir d2.$Adiarnfd && + echo d2.$Adiarnfd/f.$Adiarnfd >d2.$Adiarnfd/f.$Adiarnfd && + git add d2.$Adiarnfd/f.$Adiarnfd && + git commit -m "add d2.$Adiarnfd/f.$Adiarnfd" -- d2.$Adiarnfd/f.$Adiarnfd +' +test_expect_success "setup for long decomposed filename" ' + git checkout master && + git reset --hard && + git checkout -b mac_os_long_nfd_fn +' +test_expect_success "Add long decomposed filename" ' + echo longd >$Alongd && + git add * && + git commit -m "Long filename" +' +test_expect_success "setup for long precomposed filename" ' + git checkout master && + git reset --hard && + git checkout -b mac_os_long_nfc_fn +' +test_expect_success "Add long precomposed filename" ' + echo longc >$Alongc && + 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" +' test_done -- cgit v1.2.3