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

[PATCH v2 09/16] t3310: extract common notes_merge_files_gone()

From
Denton Liu <liu.denton@gmail.com>
Date
Jan 7, 2020, 04:53 UTC
Message-ID
<46fe82b856d217265b01bf2bcf1ff78fa9474fc3.1578372682.git.liu.denton@gmail.com>
In-Reply-To
<cover.1578372682.git.liu.denton@gmail.com>

We have many statements which are duplicated. Extract and replace these duplicate statements with notes_merge_files_gone().

While we're at it, replace the test_might_fail(), which should only be used on git commands.

Also, remove the redirection from stderr to /dev/null. This is because the test scripts automatically suppress output already. Otherwise, if a developer asks for verbose output via the `-v` flag, the stderr output may be useful for debugging.

Signed-off-by: Denton Liu <liu.denton@gmail.com>
---
 t/t3310-notes-merge-manual-resolve.sh | 22 ++++++++++------------
 1 file changed, 10 insertions(+), 12 deletions(-)
diff --git a/t/t3310-notes-merge-manual-resolve.sh b/t/t3310-notes-merge-manual-resolve.sh
index 2dea846e25..d746f4ba55 100755
--- a/t/t3310-notes-merge-manual-resolve.sh
+++ b/t/t3310-notes-merge-manual-resolve.sh
@@ -32,6 +32,12 @@ verify_notes () {
 	test_cmp "expect_log_$notes_ref" "output_log_$notes_ref"
 }
 
+notes_merge_files_gone () {
+	# No .git/NOTES_MERGE_* files left
+	{ ls .git/NOTES_MERGE_* >output || :; } &&
+	test_must_be_empty output
+}
+
 cat <<EOF | sort >expect_notes_x
 6e8e3febca3c2bb896704335cc4d0c34cb2f8715 $commit_sha4
 e5388c10860456ee60673025345fe2e153eb8cf8 $commit_sha3
@@ -335,9 +341,7 @@ EOF
 y and z notes on 4th commit
 EOF
 	git notes merge --commit &&
-	# No .git/NOTES_MERGE_* files left
-	test_might_fail ls .git/NOTES_MERGE_* >output 2>/dev/null &&
-	test_must_be_empty output &&
+	notes_merge_files_gone &&
 	# Merge commit has pre-merge y and pre-merge z as parents
 	test "$(git rev-parse refs/notes/m^1)" = "$(cat pre_merge_y)" &&
 	test "$(git rev-parse refs/notes/m^2)" = "$(cat pre_merge_z)" &&
@@ -397,9 +401,7 @@ test_expect_success 'redo merge of z into m (== y) with default ("manual") resol
 
 test_expect_success 'abort notes merge' '
 	git notes merge --abort &&
-	# No .git/NOTES_MERGE_* files left
-	test_might_fail ls .git/NOTES_MERGE_* >output 2>/dev/null &&
-	test_must_be_empty output &&
+	notes_merge_files_gone &&
 	# m has not moved (still == y)
 	test "$(git rev-parse refs/notes/m)" = "$(cat pre_merge_y)" &&
 	# Verify that other notes refs has not changed (w, x, y and z)
@@ -464,9 +466,7 @@ EOF
 	echo "new note on 5th commit" > .git/NOTES_MERGE_WORKTREE/$commit_sha5 &&
 	# Finalize merge
 	git notes merge --commit &&
-	# No .git/NOTES_MERGE_* files left
-	test_might_fail ls .git/NOTES_MERGE_* >output 2>/dev/null &&
-	test_must_be_empty output &&
+	notes_merge_files_gone &&
 	# Merge commit has pre-merge y and pre-merge z as parents
 	test "$(git rev-parse refs/notes/m^1)" = "$(cat pre_merge_y)" &&
 	test "$(git rev-parse refs/notes/m^2)" = "$(cat pre_merge_z)" &&
@@ -553,9 +553,7 @@ EOF
 
 test_expect_success 'resolve situation by aborting the notes merge' '
 	git notes merge --abort &&
-	# No .git/NOTES_MERGE_* files left
-	test_might_fail ls .git/NOTES_MERGE_* >output 2>/dev/null &&
-	test_must_be_empty output &&
+	notes_merge_files_gone &&
 	# m has not moved (still == w)
 	test "$(git rev-parse refs/notes/m)" = "$(git rev-parse refs/notes/w)" &&
 	# Verify that other notes refs has not changed (w, x, y and z)
-- 
2.25.0.rc1.180.g49a268d3eb
Previous: Denton LiuNext: Denton Liu
Message 45 of 54 in “t: replace incorrect test_must_fail usage (part 2)”
  1. 00/16 t: replace incorrect test_must_fail usage (part 2)Denton Liu, Dec 27, 2019
  2. 01/16 t2018: remove trailing space from test descriptionDenton Liu, Dec 27, 2019
  3. 02/16 t2018: add space between function name and ()Denton Liu, Dec 27, 2019
  4. Eric SunshineDec 27, 2019
  5. 04/16 t2018: teach do_checkout() to accept `!` argDenton Liu, Dec 27, 2019
  6. Eric SunshineDec 28, 2019
  7. 03/16 t2018: use test_must_fail for failing git commandsDenton Liu, Dec 27, 2019
  8. Eric SunshineDec 28, 2019
  9. Jakub NarebskiDec 30, 2019
  10. 06/16 t2018: replace "sha" with "oid"Denton Liu, Dec 27, 2019
  11. 05/16 t2018: don't lose return code of git commandsDenton Liu, Dec 27, 2019
  12. Eric SunshineDec 27, 2019
  13. Denton LiuJan 1, 2020
  14. Eric SunshineJan 1, 2020
  15. Junio C HamanoJan 2, 2020
  16. 07/16 t3030: use test_path_is_missing()Denton Liu, Dec 27, 2019
  17. 10/16 t3415: increase granularity of test_auto_{fixup,squash}()Denton Liu, Dec 27, 2019
  18. 09/16 t3415: stop losing return codes of git commandsDenton Liu, Dec 27, 2019
  19. 12/16 t3504: don't use `test_must_fail test_cmp`Denton Liu, Dec 27, 2019
  20. Johannes SixtDec 27, 2019
  21. Junio C HamanoDec 27, 2019
  22. 13/16 t3507: fix indentationDenton Liu, Dec 27, 2019
  23. 15/16 t4124: only mark git command with test_must_failDenton Liu, Dec 27, 2019
  24. 16/16 t4124: let sed open its own filesDenton Liu, Dec 27, 2019
  25. Jakub NarebskiDec 30, 2019
  26. Junio C HamanoDec 30, 2019
  27. Denton LiuJan 1, 2020
  28. Eric SunshineJan 1, 2020
  29. Denton LiuJan 1, 2020
  30. 11/16 t3419: stop losing return code of git commandDenton Liu, Dec 27, 2019
  31. 14/16 t3507: use test_path_is_missing()Denton Liu, Dec 27, 2019
  32. 08/16 t3310: extract common no_notes_merge_left()Denton Liu, Dec 27, 2019
  33. Eric SunshineDec 28, 2019
  34. Jakub NarebskiDec 30, 2019
  35. 00/16 t: replace incorrect test_must_fail usage (part 2)Denton Liu, Jan 7, 2020
  36. 01/16 t2018: remove trailing space from test descriptionDenton Liu, Jan 7, 2020
  37. 02/16 t2018: add space between function name and ()Denton Liu, Jan 7, 2020
  38. 03/16 t2018: improve style of if-statementDenton Liu, Jan 7, 2020
  39. 04/16 t2018: use test_expect_code for failing git commandsDenton Liu, Jan 7, 2020
  40. Eric SunshineJan 12, 2020
  41. t2018: be more discerning when checking for expected exit codesDenton Liu, Jan 26, 2020
  42. 05/16 t2018: teach do_checkout() to accept `!` argDenton Liu, Jan 7, 2020
  43. 06/16 t2018: don't lose return code of git commandsDenton Liu, Jan 7, 2020
  44. 07/16 t2018: replace "sha" with "oid"Denton Liu, Jan 7, 2020
  45. 09/16 t3310: extract common notes_merge_files_gone()Denton Liu, Jan 7, 2020
  46. 10/16 t3415: stop losing return codes of git commandsDenton Liu, Jan 7, 2020
  47. 14/16 t3507: fix indentationDenton Liu, Jan 7, 2020
  48. 16/16 t4124: only mark git command with test_must_failDenton Liu, Jan 7, 2020
  49. 13/16 t3504: do check for conflict marker after failed cherry-pickDenton Liu, Jan 7, 2020
  50. 12/16 t3419: stop losing return code of git commandDenton Liu, Jan 7, 2020
  51. 15/16 t3507: use test_path_is_missing()Denton Liu, Jan 7, 2020
  52. 08/16 t3030: use test_path_is_missing()Denton Liu, Jan 7, 2020
  53. 11/16 t3415: increase granularity of test_auto_{fixup,squash}()Denton Liu, Jan 7, 2020
  54. Eric SunshineJan 10, 2020

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.