t: use test_expect_code instead of hand-rolled comparison
[gitweb.git] / t / t9001-send-email.sh
index a8773bdf379ad858b252be8045b42cec99af546b..37caa183e0020f2aef14d0f957ea0b064d11271d 100755 (executable)
@@ -392,7 +392,7 @@ test_expect_success $PREREQ 'allow long lines with --no-validate' '
                --from="Example <nobody@example.com>" \
                --to=nobody@example.com \
                --smtp-server="$(pwd)/fake.sendmail" \
-               --novalidate \
+               --no-validate \
                $patches longline.patch \
                2>errors
 '
@@ -426,7 +426,7 @@ test_expect_success $PREREQ 'In-Reply-To without --chain-reply-to' '
        git send-email \
                --from="Example <nobody@example.com>" \
                --to=nobody@example.com \
-               --nochain-reply-to \
+               --no-chain-reply-to \
                --in-reply-to="$(cat expect)" \
                --smtp-server="$(pwd)/fake.sendmail" \
                $patches $patches $patches \
@@ -1067,7 +1067,7 @@ test_expect_success $PREREQ 'in-reply-to but no threading' '
                --from="Example <nobody@example.com>" \
                --to=nobody@example.com \
                --in-reply-to="<in-reply-id@example.com>" \
-               --nothread \
+               --no-thread \
                $patches |
        grep "In-Reply-To: <in-reply-id@example.com>"
 '
@@ -1077,7 +1077,7 @@ test_expect_success $PREREQ 'no in-reply-to and no threading' '
                --dry-run \
                --from="Example <nobody@example.com>" \
                --to=nobody@example.com \
-               --nothread \
+               --no-thread \
                $patches $patches >stdout &&
        ! grep "In-Reply-To: " stdout
 '
@@ -1088,7 +1088,7 @@ test_expect_success $PREREQ 'threading but no chain-reply-to' '
                --from="Example <nobody@example.com>" \
                --to=nobody@example.com \
                --thread \
-               --nochain-reply-to \
+               --no-chain-reply-to \
                $patches $patches >stdout &&
        grep "In-Reply-To: " stdout
 '
@@ -1325,7 +1325,7 @@ test_expect_success $PREREQ 'sendemail.transferencoding=7bit fails on 8bit data'
 
 test_expect_success $PREREQ '--transfer-encoding overrides sendemail.transferEncoding' '
        clean_fake_sendmail &&
-       git config sendemail.transferEncoding 8bit
+       git config sendemail.transferEncoding 8bit &&
        test_must_fail git send-email \
                --transfer-encoding=7bit \
                --smtp-server="$(pwd)/fake.sendmail" \
@@ -1564,4 +1564,37 @@ test_expect_success $PREREQ 'sendemail.aliasfile=~/.mailrc' '
        grep "^!someone@example\.org!$" commandline1
 '
 
+do_xmailer_test () {
+       expected=$1 params=$2 &&
+       git format-patch -1 &&
+       git send-email \
+               --from="Example <nobody@example.com>" \
+               --to=someone@example.com \
+               --smtp-server="$(pwd)/fake.sendmail" \
+               $params \
+               0001-*.patch \
+               2>errors >out &&
+       { grep '^X-Mailer:' out || :; } >mailer &&
+       test_line_count = $expected mailer
+}
+
+test_expect_success $PREREQ '--[no-]xmailer without any configuration' '
+       do_xmailer_test 1 "--xmailer" &&
+       do_xmailer_test 0 "--no-xmailer"
+'
+
+test_expect_success $PREREQ '--[no-]xmailer with sendemail.xmailer=true' '
+       test_config sendemail.xmailer true &&
+       do_xmailer_test 1 "" &&
+       do_xmailer_test 0 "--no-xmailer" &&
+       do_xmailer_test 1 "--xmailer"
+'
+
+test_expect_success $PREREQ '--[no-]xmailer with sendemail.xmailer=false' '
+       test_config sendemail.xmailer false &&
+       do_xmailer_test 0 "" &&
+       do_xmailer_test 0 "--no-xmailer" &&
+       do_xmailer_test 1 "--xmailer"
+'
+
 test_done