Merge branch 'jk/send-email-sender-prompt'

General clean-ups in various areas, originally written to support a
patch that later turned out to be unneeded.

* jk/send-email-sender-prompt:
  t9001: check send-email behavior with implicit sender
  t: add tests for "git var"
  ident: keep separate "explicit" flags for author and committer
  ident: make user_ident_explicitly_given static
  t7502: factor out autoident prerequisite
  test-lib: allow negation of prerequisites
This commit is contained in:
Junio C Hamano
2012-11-29 12:52:45 -08:00
9 changed files with 169 additions and 26 deletions

View File

@@ -115,6 +115,38 @@ then
exit 1
fi
test_lazy_prereq LAZY_TRUE true
havetrue=no
test_expect_success LAZY_TRUE 'test runs if lazy prereq is satisfied' '
havetrue=yes
'
donthavetrue=yes
test_expect_success !LAZY_TRUE 'missing lazy prereqs skip tests' '
donthavetrue=no
'
if test "$havetrue$donthavetrue" != yesyes
then
say 'bug in test framework: lazy prerequisites do not work'
exit 1
fi
test_lazy_prereq LAZY_FALSE false
nothavefalse=no
test_expect_success !LAZY_FALSE 'negative lazy prereqs checked' '
nothavefalse=yes
'
havefalse=yes
test_expect_success LAZY_FALSE 'missing negative lazy prereqs will skip' '
havefalse=no
'
if test "$nothavefalse$havefalse" != yesyes
then
say 'bug in test framework: negative lazy prerequisites do not work'
exit 1
fi
clean=no
test_expect_success 'tests clean up after themselves' '
test_when_finished clean=yes

49
t/t0007-git-var.sh Executable file
View File

@@ -0,0 +1,49 @@
#!/bin/sh
test_description='basic sanity checks for git var'
. ./test-lib.sh
test_expect_success 'get GIT_AUTHOR_IDENT' '
test_tick &&
echo "$GIT_AUTHOR_NAME <$GIT_AUTHOR_EMAIL> $GIT_AUTHOR_DATE" >expect &&
git var GIT_AUTHOR_IDENT >actual &&
test_cmp expect actual
'
test_expect_success 'get GIT_COMMITTER_IDENT' '
test_tick &&
echo "$GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE" >expect &&
git var GIT_COMMITTER_IDENT >actual &&
test_cmp expect actual
'
test_expect_success !AUTOIDENT 'requested identites are strict' '
(
sane_unset GIT_COMMITTER_NAME &&
sane_unset GIT_COMMITTER_EMAIL &&
test_must_fail git var GIT_COMMITTER_IDENT
)
'
# For git var -l, we check only a representative variable;
# testing the whole output would make our test too brittle with
# respect to unrelated changes in the test suite's environment.
test_expect_success 'git var -l lists variables' '
git var -l >actual &&
echo "$GIT_AUTHOR_NAME <$GIT_AUTHOR_EMAIL> $GIT_AUTHOR_DATE" >expect &&
sed -n s/GIT_AUTHOR_IDENT=//p <actual >actual.author &&
test_cmp expect actual.author
'
test_expect_success 'git var -l lists config' '
git var -l >actual &&
echo false >expect &&
sed -n s/core\\.bare=//p <actual >actual.bare &&
test_cmp expect actual.bare
'
test_expect_success 'listing and asking for variables are exclusive' '
test_must_fail git var -l GIT_COMMITTER_IDENT
'
test_done

View File

@@ -243,16 +243,6 @@ test_expect_success 'message shows author when it is not equal to committer' '
.git/COMMIT_EDITMSG
'
test_expect_success 'setup auto-ident prerequisite' '
if (sane_unset GIT_COMMITTER_EMAIL &&
sane_unset GIT_COMMITTER_NAME &&
git var GIT_COMMITTER_IDENT); then
test_set_prereq AUTOIDENT
else
test_set_prereq NOAUTOIDENT
fi
'
test_expect_success AUTOIDENT 'message shows committer when it is automatic' '
echo >>negative &&
@@ -271,7 +261,7 @@ echo editor started > "$(pwd)/.git/result"
exit 0
EOF
test_expect_success NOAUTOIDENT 'do not fire editor when committer is bogus' '
test_expect_success !AUTOIDENT 'do not fire editor when committer is bogus' '
>.git/result
>expect &&

View File

@@ -201,6 +201,34 @@ test_expect_success $PREREQ 'Prompting works' '
grep "^To: to@example.com\$" msgtxt1
'
test_expect_success $PREREQ,AUTOIDENT 'implicit ident is allowed' '
clean_fake_sendmail &&
(sane_unset GIT_AUTHOR_NAME &&
sane_unset GIT_AUTHOR_EMAIL &&
sane_unset GIT_COMMITTER_NAME &&
sane_unset GIT_COMMITTER_EMAIL &&
GIT_SEND_EMAIL_NOTTY=1 git send-email \
--smtp-server="$(pwd)/fake.sendmail" \
--to=to@example.com \
$patches </dev/null 2>errors
)
'
test_expect_success $PREREQ,!AUTOIDENT 'broken implicit ident aborts send-email' '
clean_fake_sendmail &&
(sane_unset GIT_AUTHOR_NAME &&
sane_unset GIT_AUTHOR_EMAIL &&
sane_unset GIT_COMMITTER_NAME &&
sane_unset GIT_COMMITTER_EMAIL &&
GIT_SEND_EMAIL_NOTTY=1 && export GIT_SEND_EMAIL_NOTTY &&
test_must_fail git send-email \
--smtp-server="$(pwd)/fake.sendmail" \
--to=to@example.com \
$patches </dev/null 2>errors &&
test_i18ngrep "tell me who you are" errors
)
'
test_expect_success $PREREQ 'tocmd works' '
clean_fake_sendmail &&
cp $patches tocmd.patch &&

View File

@@ -275,6 +275,15 @@ test_have_prereq () {
for prerequisite
do
case "$prerequisite" in
!*)
negative_prereq=t
prerequisite=${prerequisite#!}
;;
*)
negative_prereq=
esac
case " $lazily_tested_prereq " in
*" $prerequisite "*)
;;
@@ -294,10 +303,20 @@ test_have_prereq () {
total_prereq=$(($total_prereq + 1))
case "$satisfied_prereq" in
*" $prerequisite "*)
satisfied_this_prereq=t
;;
*)
satisfied_this_prereq=
esac
case "$satisfied_this_prereq,$negative_prereq" in
t,|,t)
ok_prereq=$(($ok_prereq + 1))
;;
*)
# Keep a list of missing prerequisites
# Keep a list of missing prerequisites; restore
# the negative marker if necessary.
prerequisite=${negative_prereq:+!}$prerequisite
if test -z "$missing_prereq"
then
missing_prereq=$prerequisite

View File

@@ -738,6 +738,12 @@ test_lazy_prereq UTF8_NFD_TO_NFC '
esac
'
test_lazy_prereq AUTOIDENT '
sane_unset GIT_AUTHOR_NAME &&
sane_unset GIT_AUTHOR_EMAIL &&
git var GIT_AUTHOR_IDENT
'
# 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