Skip to contentSkip to conversation

t6300-for-each-ref: fix "more than one quoting style" tests

PATCH In review SZEDER Gábor 2 participants 5 messages Feb 13, 2018 – Feb 15, 2018

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 t6300-for-each-ref: fix "more than one quoting style" tests

'git for-each-ref' should error out when invoked with more than one quoting style options. The tests checking this have two issues:

- They run 'git for-each-ref' upstream of a pipe, hiding its exit code, thus don't actually checking that 'git for-each-ref' exits with error code.

- They check the error message in a rather roundabout way.

Ensure that 'git for-each-ref' exits with an error code using the 'test_must_fail' helper function, and check its error message by grepping its saved standard error.

---

Those tests were like this since ancient times, c9ecf4f12a (for-each-ref: Fix quoting style constants., 2007-12-06).

 t/t6300-for-each-ref.sh | 7 ++-----
 1 file changed, 2 insertions(+), 5 deletions(-)
t/t6300-for-each-ref.sh +2 -5
index c128dfc579..295d1475bd 100755
@@ -373,11 +373,8 @@ test_expect_success 'Quoting style: tcl' '
 
 for i in "--perl --shell" "-s --python" "--python --tcl" "--tcl --perl"; do
 	test_expect_success "more than one quoting style: $i" "
-		git for-each-ref $i 2>&1 | (read line &&
-		case \$line in
-		\"error: more than one quoting style\"*) : happy;;
-		*) false
-		esac)
+		test_must_fail git for-each-ref $i 2>err &&
+		grep '^error: more than one quoting style' err
 	"
 done
 
Signature · 1 line
2.16.1.181.g4b60b0bfb6
#1 lore raw
Quoted 7 lines · SZEDER Gábor

'git for-each-ref' should error out when invoked with more than one quoting style options. The tests checking this have two issues:

- They run 'git for-each-ref' upstream of a pipe, hiding its exit code, thus don't actually checking that 'git for-each-ref' exits with error code.

Quoted 5 lines

- They check the error message in a rather roundabout way.

Ensure that 'git for-each-ref' exits with an error code using the 'test_must_fail' helper function, and check its error message by grepping its saved standard error.

Yeah, this looks much nicer than the original.

t/t6300-for-each-ref.sh test_expect_success 'Quoting style: tcl' ' · line 377

Quoted 9 lines

for i in "--perl --shell" "-s --python" "--python --tcl" "--tcl --perl"; do

t/t6300-for-each-ref.sh +2 -5
 	test_expect_success "more than one quoting style: $i" "
-		git for-each-ref $i 2>&1 | (read line &&
-		case \$line in
-		\"error: more than one quoting style\"*) : happy;;
-		*) false
-		esac)
+		test_must_fail git for-each-ref $i 2>err &&
+		grep '^error: more than one quoting style' err

I suspect in the long run this ought to be test_i18ngrep, but since it's not localized yet, it makes sense to stop here with this patch.

-Peff

#2 lore raw
Quoted 10 lines · Jeff King

t/t6300-for-each-ref.sh test_expect_success 'Quoting style: tcl' ' · line 377

Quoted 9 lines

for i in "--perl --shell" "-s --python" "--python --tcl" "--tcl --perl"; do
test_expect_success "more than one quoting style: $i" "

t/t6300-for-each-ref.sh +2 -5
-             git for-each-ref $i 2>&1 | (read line &&
-             case \$line in
-             \"error: more than one quoting style\"*) : happy;;
-             *) false
-             esac)
+             test_must_fail git for-each-ref $i 2>err &&
+             grep '^error: more than one quoting style' err
Quoted 2 lines

I suspect in the long run this ought to be test_i18ngrep, but since it's not localized yet, it makes sense to stop here with this patch.

I thought 'git for-each-ref' is plumbing and that means that it shouldn't be localized.

#3 lore raw
Quoted 12 lines · SZEDER Gábor
Quoted 10 lines · Jeff King
Quoted 9 lines

for i in "--perl --shell" "-s --python" "--python --tcl" "--tcl --perl"; do
test_expect_success "more than one quoting style: $i" "

t/t6300-for-each-ref.sh +2 -5
-             git for-each-ref $i 2>&1 | (read line &&
-             case \$line in
-             \"error: more than one quoting style\"*) : happy;;
-             *) false
-             esac)
+             test_must_fail git for-each-ref $i 2>err &&
+             grep '^error: more than one quoting style' err
Quoted 5 lines
Quoted 2 lines

I suspect in the long run this ought to be test_i18ngrep, but since it's not localized yet, it makes sense to stop here with this patch.

I thought 'git for-each-ref' is plumbing and that means that it shouldn't be localized.

I always assumed stderr was mostly fair game, even for plumbing. At any rate, I'm willing to ignore the issue until somebody actually proposes a patch to translate it.

-Peff

#4 lore raw
Quoted 17 lines · Jeff King
Quoted 15 lines · SZEDER Gábor
Quoted 12 lines · Jeff King

t/t6300-for-each-ref.sh test_expect_success 'Quoting style: tcl' ' · line 377

Quoted 9 lines

for i in "--perl --shell" "-s --python" "--python --tcl" "--tcl --perl"; do
test_expect_success "more than one quoting style: $i" "

t/t6300-for-each-ref.sh +2 -5
-             git for-each-ref $i 2>&1 | (read line &&
-             case \$line in
-             \"error: more than one quoting style\"*) : happy;;
-             *) false
-             esac)
+             test_must_fail git for-each-ref $i 2>err &&
+             grep '^error: more than one quoting style' err

I suspect in the long run this ought to be test_i18ngrep, but since it's not localized yet, it makes sense to stop here with this patch.

Quoted 6 lines
Quoted 2 lines

I thought 'git for-each-ref' is plumbing and that means that it shouldn't be localized.

I always assumed stderr was mostly fair game, even for plumbing. At any rate, I'm willing to ignore the issue until somebody actually proposes a patch to translate it.

Ah, OK, will keep that in mind.

Anyway, the first GETTEXT_POISON build will fail if that error string ever gets translated but the test doesn't get updated.