git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH 2/5] send-email: fix broken transferEncoding tests

From
Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Date
May 17, 2019, 19:55 UTC
Message-ID
<20190517195545.29729-3-avarab@gmail.com>
In-Reply-To
<xmqqsgtd3fw3.fsf@gitster-ct.c.googlers.com>

I fixed a bug that had broken the reading of sendmail.transferEncoding in 3494dfd3ee ("send-email: do defaults -> config -> getopt in that order", 2019-05-09), but the test I added in that commit did nothing to assert the bug had been fixed.

That issue originates in 8d81408435 ("git-send-email: add --transfer-encoding option", 2014-11-25) which first added the "sendemail.transferencoding=8bit".

That test has never done anything meaningful. It tested that the "--transfer-encoding=8bit" option would turn on the 8bit Transfer-Encoding, but that was the default at the time (and now). As checking out 8d81408435 and editing the test to remove that option will reveal, supplying it never did anything.

So when I copied it thinking it would work in 3494dfd3ee I copied a previously broken test, although I was making sure it did the right thing via da-hoc debugger inspection, so the bug was fixed.

So fix the test I added in 3494dfd3ee, as well as the long-standing test added in 8d81408435. To test if we're actually setting the Transfer-Encoding let's set it to 7bit, not 8bit, as 7bit will error out on "email-using-8bit".

This means that we can remove the "sendemail.transferencoding=7bit fails on 8bit data" test, since it was redundant, we now have other tests that assert that that'll fail.

While I'm at it convert "git config <key> <value>" in the test setup to just "-c <key>=<value>" on the command-line. Then we don't need to cleanup after these tests, and there's no sense in asserting where config values come from in these tests, we can take that as a given.

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
---
 t/t9001-send-email.sh | 35 +++++++++++------------------------
 1 file changed, 11 insertions(+), 24 deletions(-)
diff --git a/t/t9001-send-email.sh b/t/t9001-send-email.sh
index 13de44686b..61d484d1a6 100755
--- a/t/t9001-send-email.sh
+++ b/t/t9001-send-email.sh
@@ -1437,10 +1437,10 @@ test_expect_success $PREREQ 'setup expect' '
 	EOF
 '
 
-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 7bit &&
-	test_must_fail git send-email \
+	test_must_fail git -c sendemail.transferEncoding=8bit \
+		send-email \
 		--transfer-encoding=7bit \
 		--smtp-server="$(pwd)/fake.sendmail" \
 		email-using-8bit \
@@ -1449,11 +1449,10 @@ test_expect_success $PREREQ 'sendemail.transferencoding=7bit fails on 8bit data'
 	test -z "$(ls msgtxt*)"
 '
 
-test_expect_success $PREREQ '--transfer-encoding overrides sendemail.transferEncoding' '
+test_expect_success $PREREQ 'sendemail.transferEncoding via config' '
 	clean_fake_sendmail &&
-	git config sendemail.transferEncoding 8bit &&
-	test_must_fail git send-email \
-		--transfer-encoding=7bit \
+	test_must_fail git -c sendemail.transferEncoding=7bit \
+		send-email \
 		--smtp-server="$(pwd)/fake.sendmail" \
 		email-using-8bit \
 		2>errors >out &&
@@ -1461,27 +1460,15 @@ test_expect_success $PREREQ '--transfer-encoding overrides sendemail.transferEnc
 	test -z "$(ls msgtxt*)"
 '
 
-test_expect_success $PREREQ 'sendemail.transferencoding=8bit via config' '
+test_expect_success $PREREQ 'sendemail.transferEncoding via cli' '
 	clean_fake_sendmail &&
-	git -c sendemail.transferencoding=8bit send-email \
-		--smtp-server="$(pwd)/fake.sendmail" \
-		email-using-8bit \
-		2>errors >out &&
-	sed '1,/^$/d' msgtxt1 >actual &&
-	sed '1,/^$/d' email-using-8bit >expected &&
-	test_cmp expected actual
-'
-
-test_expect_success $PREREQ 'sendemail.transferencoding=8bit via cli' '
-	clean_fake_sendmail &&
-	git send-email \
-		--transfer-encoding=8bit \
+	test_must_fail git send-email \
+		--transfer-encoding=7bit \
 		--smtp-server="$(pwd)/fake.sendmail" \
 		email-using-8bit \
 		2>errors >out &&
-	sed '1,/^$/d' msgtxt1 >actual &&
-	sed '1,/^$/d' email-using-8bit >expected &&
-	test_cmp expected actual
+	grep "cannot send message as 7bit" errors &&
+	test -z "$(ls msgtxt*)"
 '
 
 test_expect_success $PREREQ 'setup expect' '
-- 
2.21.0.1020.gf2820cf01a
Previous: Ævar Arnfjörð BjarmasonNext: Ævar Arnfjörð Bjarmason
Message 26 of 39 in “send-email: fix transferencoding config option”
  1. 1/1 send-email: fix transferencoding config optionHeinrich Schuchardt, Apr 9, 2019
  2. Jonathan NiederApr 9, 2019
  3. Heinrich SchuchardtApr 9, 2019
  4. Junio C HamanoApr 10, 2019
  5. Heinrich SchuchardtApr 10, 2019
  6. brian m. carlsonApr 10, 2019
  7. Re* [PATCH 1/1] send-email: fix transferencoding config optionJunio C Hamano, May 8, 2019
  8. 2/2 send-email: honor transferencoding config option againJunio C Hamano, May 8, 2019
  9. Junio C HamanoMay 8, 2019
  10. 0/2 send-email: set xfer encoding correctlyJunio C Hamano, May 8, 2019
  11. 0/3 send-email: fix cli->config parsing crazynessÆvar Arnfjörð Bjarmason, May 9, 2019
  12. Junio C HamanoMay 10, 2019
  13. 1/3 send-email: move the read_config() function above getoptsÆvar Arnfjörð Bjarmason, May 9, 2019
  14. 2/3 send-email: rename the @bcclist variable for consistencyÆvar Arnfjörð Bjarmason, May 9, 2019
  15. 3/3 send-email: do defaults -> config -> getopt in that orderÆvar Arnfjörð Bjarmason, May 9, 2019
  16. Eric SunshineMay 9, 2019
  17. Junio C HamanoMay 13, 2019
  18. brian m. carlsonMay 9, 2019
  19. Junio C HamanoMay 13, 2019
  20. Ævar Arnfjörð BjarmasonMay 13, 2019
  21. Stephen BoydMay 16, 2019
  22. Junio C HamanoMay 16, 2019
  23. Junio C HamanoMay 17, 2019
  24. 0/5 ab/send-email-transferencoding-fix-for-the-fixÆvar Arnfjörð Bjarmason, May 17, 2019
  25. 1/5 send-email: remove cargo-culted multi-patch pattern in testsÆvar Arnfjörð Bjarmason, May 17, 2019
  26. 2/5 send-email: fix broken transferEncoding testsÆvar Arnfjörð Bjarmason, May 17, 2019
  27. 3/5 send-email: document --no-[to|cc|bcc]Ævar Arnfjörð Bjarmason, May 17, 2019
  28. 4/5 send-email: fix regression in sendemail.identity parsingÆvar Arnfjörð Bjarmason, May 17, 2019
  29. Junio C HamanoMay 19, 2019
  30. Johannes SchindelinMay 22, 2019
  31. Johannes SchindelinMay 29, 2019
  32. 5/5 send-email: remove support for deprecated sendemail.smtpsslÆvar Arnfjörð Bjarmason, May 17, 2019
  33. 2/2 send-email: honor transferencoding config option againJunio C Hamano, May 8, 2019
  34. Eric SunshineMay 8, 2019
  35. Junio C HamanoMay 9, 2019
  36. brian m. carlsonMay 8, 2019
  37. 1/2 send-email: update the mechanism to set default configuration valuesJunio C Hamano, May 8, 2019
  38. brian m. carlsonApr 9, 2019
  39. Heinrich SchuchardtApr 9, 2019

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.