Merge branch 'ab/tap'
authorJunio C Hamano <gitster@pobox.com>
Wed, 7 Jul 2010 18:18:44 +0000 (11:18 -0700)
committerJunio C Hamano <gitster@pobox.com>
Wed, 7 Jul 2010 18:18:44 +0000 (11:18 -0700)
* ab/tap:
t/README: document more test helpers
t/README: proposed rewording...
t/README: Document the do's and don'ts of tests
t/README: Add a section about skipping tests
t/README: Document test_expect_code
t/README: Document test_external*
t/README: Document the prereq functions, and 3-arg test_*
t/README: Typo: paralell -> parallel
t/README: The trash is in 't/trash directory.$name'
t/t9700/test.pl: don't access private object members, use public access methods
t9700: Use Test::More->builder, not $Test::Builder::Test
tests: Say "pass" rather than "ok" on empty lines for TAP
tests: Skip tests in a way that makes sense under TAP
test-lib: output a newline before "ok" under a TAP harness
test-lib: Make the test_external_* functions TAP-aware
test-lib: Adjust output to be valid TAP format

1  2 
t/t7006-pager.sh
t/t9001-send-email.sh
diff --combined t/t7006-pager.sh
index c2a3c8e2e7351ba5c49fa363a1856ec82904d444,171a754e53786bc94d248527bf995a15fa34e99b..eb9651da895f8f520c82aeab7a5406bcf9c09478
@@@ -3,7 -3,6 +3,7 @@@
  test_description='Test automatic use of a pager.'
  
  . ./test-lib.sh
 +. "$TEST_DIRECTORY"/lib-pager.sh
  
  cleanup_fail() {
        echo >&2 cleanup failed
@@@ -37,7 -36,7 +37,7 @@@ the
        }
        test_set_prereq TTY
  else
-       say no usable terminal, so skipping some tests
+       say "# no usable terminal, so skipping some tests"
  fi
  
  test_expect_success 'setup' '
@@@ -159,12 -158,21 +159,12 @@@ test_expect_success 'color when writin
        colorful colorful.log
  '
  
 -test_expect_success 'determine default pager' '
 -      unset PAGER GIT_PAGER;
 -      test_might_fail git config --unset core.pager ||
 -      cleanup_fail &&
 -
 -      less=$(git var GIT_PAGER) &&
 -      test -n "$less"
 -'
 -
 -if expr "$less" : '[a-z][a-z]*$' >/dev/null && test_have_prereq TTY
 +if test_have_prereq SIMPLEPAGER && test_have_prereq TTY
  then
 -      test_set_prereq SIMPLEPAGER
 +      test_set_prereq SIMPLEPAGERTTY
  fi
  
 -test_expect_success SIMPLEPAGER 'default pager is used by default' '
 +test_expect_success SIMPLEPAGERTTY 'default pager is used by default' '
        unset PAGER GIT_PAGER;
        test_might_fail git config --unset core.pager &&
        rm -f default_pager_used ||
diff --combined t/t9001-send-email.sh
index 382ab6c98a932925db838b29d452b36cfea0dba5,ddc3d8db9f3b025d902fd0adc31e2467df3f31c8..23597cc40751addd1473acd2edf7563e0a517c9e
@@@ -4,7 -4,7 +4,7 @@@ test_description='git send-email
  . ./test-lib.sh
  
  if ! test_have_prereq PERL; then
-       say 'skipping git send-email tests, perl not available'
+       skip_all='skipping git send-email tests, perl not available'
        test_done
  fi
  
@@@ -58,7 -58,7 +58,7 @@@ test_no_confirm () 
  # Exit immediately to prevent hang if a no-confirm test fails
  check_no_confirm () {
        test -f no_confirm_okay || {
-               say 'No confirm test failed; skipping remaining tests to prevent hanging'
+               skip_all='confirm test failed; skipping remaining tests to prevent hanging'
                test_done
        }
  }
@@@ -918,81 -918,4 +918,81 @@@ test_expect_success '--no-bcc override
        ! grep "RCPT TO:<other@ex.com>" stdout
  '
  
 +cat >email-using-8bit <<EOF
 +From fe6ecc66ece37198fe5db91fa2fc41d9f4fe5cc4 Mon Sep 17 00:00:00 2001
 +Message-Id: <bogus-message-id@example.com>
 +From: author@example.com
 +Date: Sat, 12 Jun 2010 15:53:58 +0200
 +Subject: subject goes here
 +
 +Dieser deutsche Text enthält einen Umlaut!
 +EOF
 +
 +cat >content-type-decl <<EOF
 +MIME-Version: 1.0
 +Content-Type: text/plain; charset=UTF-8
 +Content-Transfer-Encoding: 8bit
 +EOF
 +
 +test_expect_success 'asks about and fixes 8bit encodings' '
 +      clean_fake_sendmail &&
 +      echo |
 +      git send-email --from=author@example.com --to=nobody@example.com \
 +                      --smtp-server="$(pwd)/fake.sendmail" \
 +                      email-using-8bit >stdout &&
 +      grep "do not declare a Content-Transfer-Encoding" stdout &&
 +      grep email-using-8bit stdout &&
 +      grep "Which 8bit encoding" stdout &&
 +      egrep "Content|MIME" msgtxt1 >actual &&
 +      test_cmp actual content-type-decl
 +'
 +
 +test_expect_success 'sendemail.8bitEncoding works' '
 +      clean_fake_sendmail &&
 +      git config sendemail.assume8bitEncoding UTF-8 &&
 +      echo bogus |
 +      git send-email --from=author@example.com --to=nobody@example.com \
 +                      --smtp-server="$(pwd)/fake.sendmail" \
 +                      email-using-8bit >stdout &&
 +      egrep "Content|MIME" msgtxt1 >actual &&
 +      test_cmp actual content-type-decl
 +'
 +
 +test_expect_success '--8bit-encoding overrides sendemail.8bitEncoding' '
 +      clean_fake_sendmail &&
 +      git config sendemail.assume8bitEncoding "bogus too" &&
 +      echo bogus |
 +      git send-email --from=author@example.com --to=nobody@example.com \
 +                      --smtp-server="$(pwd)/fake.sendmail" \
 +                      --8bit-encoding=UTF-8 \
 +                      email-using-8bit >stdout &&
 +      egrep "Content|MIME" msgtxt1 >actual &&
 +      test_cmp actual content-type-decl
 +'
 +
 +cat >email-using-8bit <<EOF
 +From fe6ecc66ece37198fe5db91fa2fc41d9f4fe5cc4 Mon Sep 17 00:00:00 2001
 +Message-Id: <bogus-message-id@example.com>
 +From: author@example.com
 +Date: Sat, 12 Jun 2010 15:53:58 +0200
 +Subject: Dieser Betreff enthält auch einen Umlaut!
 +
 +Nothing to see here.
 +EOF
 +
 +cat >expected <<EOF
 +Subject: =?UTF-8?q?Dieser=20Betreff=20enth=C3=A4lt=20auch=20einen=20Umlaut!?=
 +EOF
 +
 +test_expect_success '--8bit-encoding also treats subject' '
 +      clean_fake_sendmail &&
 +      echo bogus |
 +      git send-email --from=author@example.com --to=nobody@example.com \
 +                      --smtp-server="$(pwd)/fake.sendmail" \
 +                      --8bit-encoding=UTF-8 \
 +                      email-using-8bit >stdout &&
 +      grep "Subject" msgtxt1 >actual &&
 +      test_cmp expected actual
 +'
 +
  test_done