Quoting Eric Sunshine <sunsh...@sunshineco.com>:

On Thu, Mar 24, 2016 at 7:00 AM, SZEDER Gábor <sze...@ira.uka.de> wrote:

diff --git a/t/t7507-commit-verbose.sh b/t/t7507-commit-verbose.sh
index 2ddf28c..cf95efb 100755
--- a/t/t7507-commit-verbose.sh
+++ b/t/t7507-commit-verbose.sh
@@ -3,12 +3,11 @@
 test_description='verbose commit template'
 . ./test-lib.sh

-cat >check-for-diff <<EOF
-#!$SHELL_PATH
-exec grep '^diff --git' "\$1"
+write_script "check-for-diff" <<-\EOF &&
+grep '^diff --git' "$1" >out &&
+test $(wc -l <out) = 1

Our test lib offers the test_line_count helper function, which
outputs a helpful error message in case the number of lines do not
match.

test_line_count() was mentioned in [2], however, this line counting is
done in the fake "editor" script, not in the test script proper, so
the spelled-out form $(wc ...) was proposed[2].

Ah, yes, of course.

But then the question is: why is the line counting in the editor script
in the first place?

By redirecting grep's output to a file in the editor script, like this
patch wanted to, we can count the lines in the test script itself after
'git commit' finished.  This way we could use test_line_count, with
all its error reporting benefits, and we could use the same editor
script for all tests.

And if you insist on doing the line counting in the editor script, then
why redirecting grep's output and 'wc -l' separately, why not 'grep -c'?


--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to