Merge branch 'jc/test-prereq'
Teaches the test framework to probe rarely used prerequistes lazily, and make use of it for detecting SYMLINKS, CASE_INSENSITIVE_FS and NKD/NKC MacOS x gotcha. * jc/test-prereq: t3910: use the UTF8_NFD_TO_NFC test prereq test-lib: provide UTF8 behaviour as a prerequisite t0050: use the SYMLINKS test prereq t0050: use the CASE_INSENSITIVE_FS test prereq test-lib: provide case insensitivity as a prerequisite test: allow prerequisite to be evaluated lazily test: rename $satisfied to $satisfied_prereq
This commit is contained in:
commit
16a3f91a36
9
t/README
9
t/README
@ -625,6 +625,15 @@ 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.
|
||||
|
||||
- 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
|
||||
----------------------
|
||||
|
||||
|
@ -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" &&
|
||||
|
@ -7,48 +7,26 @@ 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
|
||||
if test_have_prereq CASE_INSENSITIVE_FS
|
||||
then
|
||||
test_case=test_expect_failure &&
|
||||
case_insensitive=t
|
||||
fi &&
|
||||
rm -fr junk &&
|
||||
mkdir junk &&
|
||||
>junk/"$auml" &&
|
||||
case "$(cd junk && echo *)" in
|
||||
"$aumlcdiar")
|
||||
test_unicode=test_expect_failure &&
|
||||
unibad=t
|
||||
;;
|
||||
*) ;;
|
||||
esac &&
|
||||
rm -fr junk &&
|
||||
{
|
||||
ln -s x y 2> /dev/null &&
|
||||
test -h y 2> /dev/null ||
|
||||
no_symlinks=1 &&
|
||||
rm -f y
|
||||
}
|
||||
'
|
||||
|
||||
test "$case_insensitive" &&
|
||||
say "will test on a case insensitive filesystem"
|
||||
test "$unibad" &&
|
||||
test_case=test_expect_failure
|
||||
else
|
||||
test_case=test_expect_success
|
||||
fi
|
||||
|
||||
if test_have_prereq UTF8_NFD_TO_NFC
|
||||
then
|
||||
say "will test on a unicode corrupting filesystem"
|
||||
test "$no_symlinks" &&
|
||||
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"
|
||||
|
||||
if test "$case_insensitive"
|
||||
if test_have_prereq CASE_INSENSITIVE_FS
|
||||
then
|
||||
test_expect_success "detection of case insensitive filesystem during repo init" '
|
||||
|
||||
@ -62,19 +40,19 @@ 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
|
||||
'
|
||||
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
|
||||
'
|
||||
else
|
||||
test_expect_success "detection of filesystem w/o symlink support during repo init" '
|
||||
|
||||
v=$(git config --bool core.symlinks) &&
|
||||
test "$v" = false
|
||||
'
|
||||
fi
|
||||
|
||||
test_expect_success "setup case tests" '
|
||||
|
@ -7,24 +7,16 @@ 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
|
||||
|
||||
|
||||
if test "$test_nfd"
|
||||
then
|
||||
# create more utf-8 variables
|
||||
Odiarnfc=`printf '\303\226'`
|
||||
Odiarnfd=`printf 'O\314\210'`
|
||||
AEligatu=`printf '\303\206'`
|
||||
@ -157,8 +149,5 @@ then
|
||||
precomposeunicode=`git config core.precomposeunicode` &&
|
||||
test "$precomposeunicode" = "true"
|
||||
'
|
||||
else
|
||||
say "Skipping nfc/nfd tests"
|
||||
fi
|
||||
|
||||
test_done
|
||||
|
@ -221,9 +221,35 @@ write_script () {
|
||||
# capital letters by convention).
|
||||
|
||||
test_set_prereq () {
|
||||
satisfied="$satisfied$1 "
|
||||
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
|
||||
}
|
||||
satisfied=" "
|
||||
|
||||
test_have_prereq () {
|
||||
# prerequisites can be concatenated with ','
|
||||
@ -238,8 +264,24 @@ 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 in
|
||||
case "$satisfied_prereq" in
|
||||
*" $prerequisite "*)
|
||||
ok_prereq=$(($ok_prereq + 1))
|
||||
;;
|
||||
|
@ -659,9 +659,29 @@ test_i18ngrep () {
|
||||
fi
|
||||
}
|
||||
|
||||
test_lazy_prereq SYMLINKS '
|
||||
# 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
|
||||
ln -s x y && test -h y
|
||||
'
|
||||
|
||||
test_lazy_prereq CASE_INSENSITIVE_FS '
|
||||
echo good >CamelCase &&
|
||||
echo bad >camelcase &&
|
||||
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.
|
||||
|
Loading…
Reference in New Issue
Block a user