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

[PATCH 07/24] t6200 (fmt-merge-msg): style nitpicks

From
Jonathan Nieder <jrnieder@gmail.com>
Date
Aug 17, 2010, 06:57 UTC
Message-ID
<20100817065740.GG22057@burratino>
In-Reply-To
<20100817065147.GA18293@burratino>

Guard setup with test_expect_success. Use test_might_fail instead of ignoring the exit code from git config --unset. Point out setup commands that are shared by multiple tests, to make it easy to write GIT_SKIP_TESTS specifications that work.

Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>
---
 t/t6200-fmt-merge-msg.sh |  278 ++++++++++++++++++++--------------------------
 1 files changed, 119 insertions(+), 159 deletions(-)
diff --git a/t/t6200-fmt-merge-msg.sh b/t/t6200-fmt-merge-msg.sh
index 42f8ece..5553dff 100755
--- a/t/t6200-fmt-merge-msg.sh
+++ b/t/t6200-fmt-merge-msg.sh
@@ -70,14 +70,13 @@ test_expect_success setup '
 		i=$(($i+1))
 	done &&
 
-	git show-branch
+	git show-branch &&
+
+	apos="'\''"
 '
 
-cat >expected <<\EOF
-Merge branch 'left'
-EOF
-
-test_expect_success 'merge-msg test #1' '
+test_expect_success 'message for merging local branch' '
+	echo "Merge branch ${apos}left${apos}" >expected &&
 
 	git checkout master &&
 	git fetch . left &&
@@ -86,11 +85,8 @@ test_expect_success 'merge-msg test #1' '
 	test_cmp expected actual
 '
 
-cat >expected <<EOF
-Merge branch 'left' of $(pwd)
-EOF
-
-test_expect_success 'merge-msg test #2' '
+test_expect_success 'message for merging external branch' '
+	echo "Merge branch ${apos}left${apos} of $(pwd)" >expected &&
 
 	git checkout master &&
 	git fetch "$(pwd)" left &&
@@ -99,139 +95,108 @@ test_expect_success 'merge-msg test #2' '
 	test_cmp expected actual
 '
 
-cat >expected <<\EOF
-Merge branch 'left'
+test_expect_success '[merge] summary/log configuration' '
+	cat >expected <<-EOF &&
+	Merge branch ${apos}left${apos}
+
+	* left:
+	  Left #5
+	  Left #4
+	  Left #3
+	  Common #2
+	  Common #1
+	EOF
 
-* left:
-  Left #5
-  Left #4
-  Left #3
-  Common #2
-  Common #1
-EOF
-
-test_expect_success 'merge-msg test #3-1' '
-
-	git config --unset-all merge.log
-	git config --unset-all merge.summary
 	git config merge.log true &&
+	test_might_fail git config --unset-all merge.summary &&
 
 	git checkout master &&
 	test_tick &&
 	git fetch . left &&
 
-	git fmt-merge-msg <.git/FETCH_HEAD >actual &&
-	test_cmp expected actual
-'
+	git fmt-merge-msg <.git/FETCH_HEAD >actual1 &&
 
-test_expect_success 'merge-msg test #3-2' '
-
-	git config --unset-all merge.log
-	git config --unset-all merge.summary
+	test_might_fail git config --unset-all merge.log &&
 	git config merge.summary true &&
 
 	git checkout master &&
 	test_tick &&
 	git fetch . left &&
 
-	git fmt-merge-msg <.git/FETCH_HEAD >actual &&
-	test_cmp expected actual
-'
+	git fmt-merge-msg <.git/FETCH_HEAD >actual2 &&
 
-cat >expected <<\EOF
-Merge branches 'left' and 'right'
-
-* left:
-  Left #5
-  Left #4
-  Left #3
-  Common #2
-  Common #1
-
-* right:
-  Right #5
-  Right #4
-  Right #3
-  Common #2
-  Common #1
-EOF
+	test_cmp expected actual1 &&
+	test_cmp expected actual2
+'
 
-test_expect_success 'merge-msg test #4-1' '
+test_expect_success 'setup: expected shortlog for two branches' '
+	cat >expected <<-EOF
+	Merge branches ${apos}left${apos} and ${apos}right${apos}
+
+	* left:
+	  Left #5
+	  Left #4
+	  Left #3
+	  Common #2
+	  Common #1
+
+	* right:
+	  Right #5
+	  Right #4
+	  Right #3
+	  Common #2
+	  Common #1
+	EOF
+'
 
-	git config --unset-all merge.log
-	git config --unset-all merge.summary
+test_expect_success 'shortlog for two branches' '
 	git config merge.log true &&
-
+	test_might_fail git config --unset-all merge.summary &&
 	git checkout master &&
 	test_tick &&
 	git fetch . left right &&
+	git fmt-merge-msg <.git/FETCH_HEAD >actual1 &&
 
-	git fmt-merge-msg <.git/FETCH_HEAD >actual &&
-	test_cmp expected actual
-'
-
-test_expect_success 'merge-msg test #4-2' '
-
-	git config --unset-all merge.log
-	git config --unset-all merge.summary
+	test_might_fail git config --unset-all merge.log &&
 	git config merge.summary true &&
-
 	git checkout master &&
 	test_tick &&
 	git fetch . left right &&
+	git fmt-merge-msg <.git/FETCH_HEAD >actual2 &&
 
-	git fmt-merge-msg <.git/FETCH_HEAD >actual &&
-	test_cmp expected actual
-'
-
-test_expect_success 'merge-msg test #5-1' '
-
-	git config --unset-all merge.log
-	git config --unset-all merge.summary
 	git config merge.log yes &&
-
+	test_might_fail git config --unset-all merge.summary &&
 	git checkout master &&
 	test_tick &&
 	git fetch . left right &&
+	git fmt-merge-msg <.git/FETCH_HEAD >actual3 &&
 
-	git fmt-merge-msg <.git/FETCH_HEAD >actual &&
-	test_cmp expected actual
-'
-
-test_expect_success 'merge-msg test #5-2' '
-
-	git config --unset-all merge.log
-	git config --unset-all merge.summary
+	test_might_fail git config --unset-all merge.log &&
 	git config merge.summary yes &&
-
 	git checkout master &&
 	test_tick &&
 	git fetch . left right &&
+	git fmt-merge-msg <.git/FETCH_HEAD >actual4 &&
 
-	git fmt-merge-msg <.git/FETCH_HEAD >actual &&
-	test_cmp expected actual
+	test_cmp expected actual1 &&
+	test_cmp expected actual2 &&
+	test_cmp expected actual3 &&
+	test_cmp expected actual4
 '
 
 test_expect_success 'merge-msg -F' '
-
-	git config --unset-all merge.log
-	git config --unset-all merge.summary
+	test_might_fail git config --unset-all merge.log &&
 	git config merge.summary yes &&
-
 	git checkout master &&
 	test_tick &&
 	git fetch . left right &&
-
 	git fmt-merge-msg -F .git/FETCH_HEAD >actual &&
 	test_cmp expected actual
 '
 
 test_expect_success 'merge-msg -F in subdirectory' '
-
-	git config --unset-all merge.log
-	git config --unset-all merge.summary
+	test_might_fail git config --unset-all merge.log &&
 	git config merge.summary yes &&
-
 	git checkout master &&
 	test_tick &&
 	git fetch . left right &&
@@ -245,11 +210,11 @@ test_expect_success 'merge-msg -F in subdirectory' '
 '
 
 test_expect_success 'merge-msg with nothing to merge' '
-
-	git config --unset-all merge.log
-	git config --unset-all merge.summary
+	test_might_fail git config --unset-all merge.log &&
 	git config merge.summary yes &&
 
+	>empty &&
+
 	(
 		cd remote &&
 		git checkout -b unrelated &&
@@ -258,22 +223,20 @@ test_expect_success 'merge-msg with nothing to merge' '
 		git fmt-merge-msg <.git/FETCH_HEAD >../actual
 	) &&
 
-	test_cmp /dev/null actual
+	test_cmp empty actual
 '
 
-cat >expected <<\EOF
-Merge tag 'tag-r3'
-
-* tag 'tag-r3':
-  Right #3
-  Common #2
-  Common #1
-EOF
-
 test_expect_success 'merge-msg tag' '
+	cat >expected <<-EOF &&
+	Merge tag ${apos}tag-r3${apos}
 
-	git config --unset-all merge.log
-	git config --unset-all merge.summary
+	* tag ${apos}tag-r3${apos}:
+	  Right #3
+	  Common #2
+	  Common #1
+	EOF
+
+	test_might_fail git config --unset-all merge.log &&
 	git config merge.summary yes &&
 
 	git checkout master &&
@@ -284,26 +247,24 @@ test_expect_success 'merge-msg tag' '
 	test_cmp expected actual
 '
 
-cat >expected <<\EOF
-Merge tags 'tag-r3' and 'tag-l5'
-
-* tag 'tag-r3':
-  Right #3
-  Common #2
-  Common #1
-
-* tag 'tag-l5':
-  Left #5
-  Left #4
-  Left #3
-  Common #2
-  Common #1
-EOF
-
 test_expect_success 'merge-msg two tags' '
+	cat >expected <<-EOF &&
+	Merge tags ${apos}tag-r3${apos} and ${apos}tag-l5${apos}
 
-	git config --unset-all merge.log
-	git config --unset-all merge.summary
+	* tag ${apos}tag-r3${apos}:
+	  Right #3
+	  Common #2
+	  Common #1
+
+	* tag ${apos}tag-l5${apos}:
+	  Left #5
+	  Left #4
+	  Left #3
+	  Common #2
+	  Common #1
+	EOF
+
+	test_might_fail git config --unset-all merge.log &&
 	git config merge.summary yes &&
 
 	git checkout master &&
@@ -314,26 +275,24 @@ test_expect_success 'merge-msg two tags' '
 	test_cmp expected actual
 '
 
-cat >expected <<\EOF
-Merge branch 'left', tag 'tag-r3'
-
-* tag 'tag-r3':
-  Right #3
-  Common #2
-  Common #1
-
-* left:
-  Left #5
-  Left #4
-  Left #3
-  Common #2
-  Common #1
-EOF
-
 test_expect_success 'merge-msg tag and branch' '
+	cat >expected <<-EOF &&
+	Merge branch ${apos}left${apos}, tag ${apos}tag-r3${apos}
 
-	git config --unset-all merge.log
-	git config --unset-all merge.summary
+	* tag ${apos}tag-r3${apos}:
+	  Right #3
+	  Common #2
+	  Common #1
+
+	* left:
+	  Left #5
+	  Left #4
+	  Left #3
+	  Common #2
+	  Common #1
+	EOF
+
+	test_might_fail git config --unset-all merge.log &&
 	git config merge.summary yes &&
 
 	git checkout master &&
@@ -344,26 +303,27 @@ test_expect_success 'merge-msg tag and branch' '
 	test_cmp expected actual
 '
 
-cat >expected <<\EOF
-Merge branch 'long'
-
-* long: (35 commits)
-EOF
-
 test_expect_success 'merge-msg lots of commits' '
+	{
+		cat <<-EOF &&
+		Merge branch ${apos}long${apos}
+
+		* long: (35 commits)
+		EOF
+
+		i=29 &&
+		while test $i -gt 9
+		do
+			echo "  $i" &&
+			i=$(($i-1))
+		done &&
+		echo "  ..."
+	} >expected &&
 
 	git checkout master &&
 	test_tick &&
 	git fetch . long &&
 
-	i=29 &&
-	while test $i -gt 9
-	do
-		echo "  $i" &&
-		i=$(($i-1))
-	done >>expected &&
-	echo "  ..." >>expected
-
 	git fmt-merge-msg <.git/FETCH_HEAD >actual &&
 	test_cmp expected actual
 '
-- 
1.7.2.1.544.ga752d.dirty
Previous: Jonathan NiederNext: Jonathan Nieder
Message 13 of 36 in “updating examples/git-merge (plus a builtin/merge fix)”
  1. updating examples/git-merge (plus a builtin/merge fix)Jonathan Nieder, Aug 17, 2010
  2. 01/24 merge: do not mistake (ancestor of) tag for branchJonathan Nieder, Aug 17, 2010
  3. 02/24 t7600 (merge): modernize styleJonathan Nieder, Aug 17, 2010
  4. 03/24 t7600 (merge): do not launch gitk for --debugJonathan Nieder, Aug 17, 2010
  5. Ævar Arnfjörð BjarmasonAug 17, 2010
  6. Sverre RabbelierAug 17, 2010
  7. Jonathan NiederAug 18, 2010
  8. Ævar Arnfjörð BjarmasonAug 18, 2010
  9. Jonathan NiederAug 18, 2010
  10. 04/24 t7600 (merge): check reflog entryJonathan Nieder, Aug 17, 2010
  11. 05/24 t7600 (merge): test merge from branch yet to be bornJonathan Nieder, Aug 17, 2010
  12. 06/24 t6010 (merge-base): modernize styleJonathan Nieder, Aug 17, 2010
  13. 07/24 t6200 (fmt-merge-msg): style nitpicksJonathan Nieder, Aug 17, 2010
  14. 08/24 Documentation: add a SEE ALSO section for merge-baseJonathan Nieder, Aug 17, 2010
  15. 09/24 merge-base --octopus to mimic show-branch --merge-baseJonathan Nieder, Aug 17, 2010
  16. 10/24 merge-base --independent to print reduced parent list in a mergeJonathan Nieder, Aug 17, 2010
  17. 11/24 fmt-merge-msg -m to override subject lineJonathan Nieder, Aug 17, 2010
  18. 11/24 fmt-merge-msg -m to override merge titleJonathan Nieder, Aug 17, 2010
  19. 12/24 merge script: --squash, --ff from unborn branch are errorsJonathan Nieder, Aug 17, 2010
  20. 13/24 merge script: tweak unmerged files message to match builtinJonathan Nieder, Aug 17, 2010
  21. Ævar Arnfjörð BjarmasonAug 17, 2010
  22. 14/24 merge script: refuse to merge during mergeJonathan Nieder, Aug 17, 2010
  23. 15/24 merge script: improve log message subjectJonathan Nieder, Aug 17, 2010
  24. 16/24 merge script: merge -X<option>Jonathan Nieder, Aug 17, 2010
  25. 17/24 merge script: allow custom strategiesJonathan Nieder, Aug 17, 2010
  26. 18/24 merge script: forbid merge -s indexJonathan Nieder, Aug 17, 2010
  27. 19/24 merge script: handle -m --log correctlyJonathan Nieder, Aug 17, 2010
  28. Tay Ray ChuanAug 17, 2010
  29. Jonathan NiederAug 17, 2010
  30. 20/24 merge script: handle many-way octopusJonathan Nieder, Aug 17, 2010
  31. 21/24 merge script: --ff-only to disallow true mergeJonathan Nieder, Aug 17, 2010
  32. 22/24 merge script: handle --no-ff --no-commit correctlyJonathan Nieder, Aug 17, 2010
  33. 23/24 merge script: notice @{-1} shorthandJonathan Nieder, Aug 17, 2010
  34. 24/24 merge script: learn --[no-]rerere-autoupdateJonathan Nieder, Aug 17, 2010
  35. Ævar Arnfjörð BjarmasonAug 17, 2010
  36. Jonathan NiederAug 17, 2010

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.