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

[PATCH 1/2] t/t6300: introduce test_bad_atom()

From
Kousik Sanagavarapu <five231003@gmail.com>
Date
Sep 20, 2023, 19:05 UTC
Message-ID
<20230920191654.6133-2-five231003@gmail.com>
In-Reply-To
<20230920191654.6133-1-five231003@gmail.com>

Introduce a new function "test_bad_atom()", which is similar to "test_atom()" but should be used to check whether the correct error message is shown on stderr.

Like "test_atom()", the new function takes three arguments. The three arguments specify the ref, the format and the expected error message respectively, with an optional fourth argument for tweaking "test_expect_*" (which is by default "success").

Mentored-by: Christian Couder <christian.couder@gmail.com>
Mentored-by: Hariom Verma <hariom18599@gmail.com>
Signed-off-by: Kousik Sanagavarapu <five231003@gmail.com>
---
 t/t6300-for-each-ref.sh | 20 ++++++++++++++++++++
 1 file changed, 20 insertions(+)
diff --git a/t/t6300-for-each-ref.sh b/t/t6300-for-each-ref.sh
index 7b943fd34c..15b4622f57 100755
--- a/t/t6300-for-each-ref.sh
+++ b/t/t6300-for-each-ref.sh
@@ -267,6 +267,26 @@ test_expect_success 'arguments to %(objectname:short=) must be positive integers
 	test_must_fail git for-each-ref --format="%(objectname:short=foo)"
 '
 
+test_bad_atom() {
+	case "$1" in
+	head) ref=refs/heads/main ;;
+	 tag) ref=refs/tags/testtag ;;
+	 sym) ref=refs/heads/sym ;;
+	   *) ref=$1 ;;
+	esac
+	printf '%s\n' "$3">expect
+	test_expect_${4:-success} $PREREQ "err basic atom: $1 $2" "
+		test_must_fail git for-each-ref --format='%($2)' $ref 2>actual &&
+		test_cmp expect actual
+	"
+}
+
+test_bad_atom head 'authoremail:foo' \
+	'fatal: unrecognized %(authoremail) argument: foo'
+
+test_bad_atom tag 'taggeremail:localpart trim' \
+	'fatal: unrecognized %(taggeremail) argument:  trim'
+
 test_date () {
 	f=$1 &&
 	committer_date=$2 &&
-- 
2.42.0.160.g6905eb16ce.dirty
Previous: Kousik SanagavarapuNext: Junio C Hamano
Message 2 of 11 in “Add mailmap support to ref-filter”
  1. 0/2 Add mailmap support to ref-filterKousik Sanagavarapu, Sep 20, 2023
  2. 1/2 t/t6300: introduce test_bad_atom()Kousik Sanagavarapu, Sep 20, 2023
  3. Junio C HamanoSep 20, 2023
  4. Junio C HamanoSep 20, 2023
  5. Junio C HamanoSep 20, 2023
  6. Kousik SanagavarapuSep 21, 2023
  7. 2/2 ref-filter: add mailmap supportKousik Sanagavarapu, Sep 20, 2023
  8. 0/3 Add mailmap support to ref-filterKousik Sanagavarapu, Sep 25, 2023
  9. 1/3 t/t6300: cleanup test_atomKousik Sanagavarapu, Sep 25, 2023
  10. 2/3 t/t6300: introduce test_bad_atomKousik Sanagavarapu, Sep 25, 2023
  11. 3/3 ref-filter: add mailmap supportKousik Sanagavarapu, Sep 25, 2023

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.