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

[PATCH v3 2/4] t4015: separate common setup and per-test expectation

From
Junio C Hamano <gitster@pobox.com>
Date
May 27, 2015, 06:30 UTC
Message-ID
<1432708232-29892-3-git-send-email-gitster@pobox.com>
In-Reply-To
<1432708232-29892-1-git-send-email-gitster@pobox.com>
The last two tests in the script were to
 - set up color.diff.* slots
 - set up an expectation for a single test
 - run that test and check the result

but split in a wrong way. It did the first two in the first test and the third one in the second test. The latter two belong to each other. This matters when you plan to add more of these tests that share the common coloring.

While at it, make sure we use a color different from old, which is also red.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
---
 t/t4015-diff-whitespace.sh | 25 +++++++++++++------------
 1 file changed, 13 insertions(+), 12 deletions(-)
diff --git a/t/t4015-diff-whitespace.sh b/t/t4015-diff-whitespace.sh
index 0bfc7ff..4da30e5 100755
--- a/t/t4015-diff-whitespace.sh
+++ b/t/t4015-diff-whitespace.sh
@@ -810,11 +810,20 @@ test_expect_success 'setup diff colors' '
 	git config color.diff.old red &&
 	git config color.diff.new green &&
 	git config color.diff.commit yellow &&
-	git config color.diff.whitespace "normal red" &&
+	git config color.diff.whitespace blue &&
 
-	git config core.autocrlf false &&
+	git config core.autocrlf false
+'
+
+test_expect_success 'diff that introduces a line with only tabs' '
+	git config core.whitespace blank-at-eol &&
+	git reset --hard &&
+	echo "test" >x &&
+	git commit -m "initial" x &&
+	echo "{NTN}" | tr "NT" "\n\t" >>x &&
+	git -c color.diff=always diff | test_decode_color >current &&
 
-	cat >expected <<-\EOF
+	cat >expected <<-\EOF &&
 	<BOLD>diff --git a/x b/x<RESET>
 	<BOLD>index 9daeafb..2874b91 100644<RESET>
 	<BOLD>--- a/x<RESET>
@@ -822,18 +831,10 @@ test_expect_success 'setup diff colors' '
 	<CYAN>@@ -1 +1,4 @@<RESET>
 	 test<RESET>
 	<GREEN>+<RESET><GREEN>{<RESET>
-	<GREEN>+<RESET><BRED>	<RESET>
+	<GREEN>+<RESET><BLUE>	<RESET>
 	<GREEN>+<RESET><GREEN>}<RESET>
 	EOF
-'
 
-test_expect_success 'diff that introduces a line with only tabs' '
-	git config core.whitespace blank-at-eol &&
-	git reset --hard &&
-	echo "test" >x &&
-	git commit -m "initial" x &&
-	echo "{NTN}" | tr "NT" "\n\t" >>x &&
-	git -c color.diff=always diff | test_decode_color >current &&
 	test_cmp expected current
 '
 
-- 
2.4.2-503-g3e4528a
Previous: Junio C HamanoNext: Junio C Hamano
Message 18 of 30 in “Mark trailing whitespace error in del lines of diff”
  1. Christian BrabandtMay 25, 2015
  2. brian m. carlsonMay 25, 2015
  3. Junio C HamanoMay 25, 2015
  4. brian m. carlsonMay 25, 2015
  5. Christian BrabandtMay 26, 2015
  6. Junio C HamanoMay 26, 2015
  7. Junio C HamanoMay 26, 2015
  8. Christian BrabandtMay 26, 2015
  9. Junio C HamanoMay 26, 2015
  10. Christian BrabandtMay 26, 2015
  11. 0/5 showing existing ws breakageJunio C Hamano, May 26, 2015
  12. 1/4 t4015: modernise styleJunio C Hamano, May 26, 2015
  13. 2/4 t4015: separate common setup and per-test expectationJunio C Hamano, May 26, 2015
  14. 3/4 diff.c: add emit_del_line() and update callers of emit_line_0()Junio C Hamano, May 26, 2015
  15. 4/4 diff.c: --ws-check-deleted optionJunio C Hamano, May 26, 2015
  16. 0/4 showing existing ws breakageJunio C Hamano, May 27, 2015
  17. 1/4 t4015: modernise styleJunio C Hamano, May 27, 2015
  18. 2/4 t4015: separate common setup and per-test expectationJunio C Hamano, May 27, 2015
  19. 3/4 diff.c: add emit_del_line() and emit_context_line()Junio C Hamano, May 27, 2015
  20. 4/4 diff.c: --ws-error-highlight=<kind> optionJunio C Hamano, May 27, 2015
  21. Jeff KingMay 27, 2015
  22. Junio C HamanoMay 27, 2015
  23. Jeff KingMay 27, 2015
  24. Junio C HamanoMay 27, 2015
  25. Jeff KingMay 27, 2015
  26. Junio C HamanoMay 27, 2015
  27. Jeff KingMay 27, 2015
  28. Junio C HamanoMay 26, 2015
  29. Christian BrabandtMay 26, 2015
  30. Junio C HamanoMay 26, 2015

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.