Skip to contentSkip to conversation

t7407: use test_grep

PATCH In review Jeff King 5 participants 6 messages Jan 7, 2025

lore
Share & tools
lore

Jeff King

author
#0 lore raw

PATCH 1/1 t7407: use test_grep

There are a few grep calls here that can benefit from test_grep, which produces more user-friendly output when it fails.

One of these calls also passes "-sq", which is curious. The "-q" option suppresses the matched output. But test output is either already redirected to /dev/null in non-verbose mode, and in verbose mode it's better to see the output. The "-s" option suppresses errors opening files, but we are just grepping in the "expected" file we just generated, so it should not be needed. Neither of these was really hurting anything, but they are not a style we'd like to see emulated. So get rid of them.

(It is also curious to grep in the expected file in the first place, but that is because we are auto-generating the expectation from a Git command. So this is double-checking it did what we wanted).

---
Just something I noticed while working on an unrelated topic.

 t/t7407-submodule-foreach.sh | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
t/t7407-submodule-foreach.sh +2 -2
index 8d7b234beb..77b6d0040e 100755
@@ -426,14 +426,14 @@ test_expect_success 'option-like arguments passed to foreach commands are not lo
 		git submodule foreach "echo be --quiet" > ../expected &&
 		git submodule foreach echo be --quiet > ../actual
 	) &&
-	grep -sq -e "--quiet" expected &&
+	test_grep -e "--quiet" expected &&
 	test_cmp expected actual
 '
 
 test_expect_success 'option-like arguments passed to foreach recurse correctly' '
 	git -C clone2 submodule foreach --recursive "echo be --an-option" >expect &&
 	git -C clone2 submodule foreach --recursive echo be --an-option >actual &&
-	grep -e "--an-option" expect &&
+	test_grep -e "--an-option" expect &&
 	test_cmp expect actual
 '
 
Signature · 1 line
2.48.0.rc2.377.g0507c08f68
#1 lore raw
Quoted 12 lines · Jeff King

There are a few grep calls here that can benefit from test_grep, which produces more user-friendly output when it fails.

One of these calls also passes "-sq", which is curious. The "-q" option suppresses the matched output. But test output is either already redirected to /dev/null in non-verbose mode, and in verbose mode it's better to see the output. The "-s" option suppresses errors opening files, but we are just grepping in the "expected" file we just generated, so it should not be needed. Neither of these was really hurting anything, but they are not a style we'd like to see emulated. So get rid of them.

Quoted 5 lines

(It is also curious to grep in the expected file in the first place, but that is because we are auto-generating the expectation from a Git command. So this is double-checking it did what we wanted).

Thanks, both of these look obviously good to me.

Patrick

#2 lore raw
In reply to Jeff King
Quoted 5 lines · Jeff King

get rid of them.

(It is also curious to grep in the expected file in the first place, but that is because we are auto-generating the expectation from a Git command. So this is double-checking it did what we wanted).

Missing “that”? s/it did/that it did/

#3 lore raw
Quoted 8 lines · Kristoffer Haugsbakk
Quoted 5 lines · Jeff King

get rid of them.

(It is also curious to grep in the expected file in the first place, but that is because we are auto-generating the expectation from a Git command. So this is double-checking it did what we wanted).

Missing “that”? s/it did/that it did/

It is colloquially correct, isn't it?

#4 lore raw
Quoted 5 lines · Junio C Hamano
Quoted 3 lines · Kristoffer Haugsbakk
Quoted 2 lines · Jeff King

get rid of them.

Quoted 7 lines
Quoted 5 lines
Quoted 3 lines

(It is also curious to grep in the expected file in the first place, but that is because we are auto-generating the expectation from a Git command. So this is double-checking it did what we wanted).

Missing “that”? s/it did/that it did/

It is colloquially correct, isn't it?

I’m just going by intuition but I couldn’t make it make sense in my head/read out loud.

Signature · 1 line
Kristoffer Haugsbakk
#5 lore raw
In reply to Junio C Hamano
Quoted 6 lines · Junio C Hamano
Quoted 3 lines · Kristoffer Haugsbakk
Quoted 2 lines · Jeff King

get rid of them.

Quoted 9 lines
Quoted 5 lines
Quoted 3 lines

(It is also curious to grep in the expected file in the first place, but that is because we are auto-generating the expectation from a Git command. So this is double-checking it did what we wanted).

Missing “that”? s/it did/that it did/

It is colloquially correct, isn't it?

Reads fine to me.

Signature · 1 line
D. Ben Knoble