git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "René Scharfe" <l.s.r@web.de>
To: Junio C Hamano <gitster@pobox.com>, git@vger.kernel.org
Cc: Ramsay Jones <ramsay@ramsayjones.plus.com>
Subject: [PATCH v2 7/8] t7810: add test for grep -W and trailing empty context lines
Date: Sat, 28 May 2016 17:05:41 +0200	[thread overview]
Message-ID: <5749B3C5.4060809@web.de> (raw)
In-Reply-To: <5749AF59.2070704@web.de>

Add a test demonstrating that git grep -W prints empty lines following
the function context we're actually interested in.  The modified test
file makes it necessary to adjust three unrelated test cases.

Signed-off-by: Rene Scharfe <l.s.r@web.de>
---
 t/t7810-grep.sh | 19 ++++++++++++++++---
 1 file changed, 16 insertions(+), 3 deletions(-)

diff --git a/t/t7810-grep.sh b/t/t7810-grep.sh
index 1e72971..26912dc 100755
--- a/t/t7810-grep.sh
+++ b/t/t7810-grep.sh
@@ -9,7 +9,9 @@ test_description='git grep various.
 . ./test-lib.sh
 
 cat >hello.c <<EOF
+#include <assert.h>
 #include <stdio.h>
+
 int main(int argc, const char **argv)
 {
 	printf("Hello world.\n");
@@ -715,6 +717,7 @@ test_expect_success 'grep -p' '
 
 cat >expected <<EOF
 hello.c-#include <stdio.h>
+hello.c-
 hello.c=int main(int argc, const char **argv)
 hello.c-{
 hello.c-	printf("Hello world.\n");
@@ -741,6 +744,16 @@ test_expect_success 'grep -W' '
 '
 
 cat >expected <<EOF
+hello.c-#include <assert.h>
+hello.c:#include <stdio.h>
+EOF
+
+test_expect_failure 'grep -W shows no trailing empty lines' '
+	git grep -W stdio >actual &&
+	test_cmp expected actual
+'
+
+cat >expected <<EOF
 hello.c=	printf("Hello world.\n");
 hello.c:	return 0;
 hello.c-	/* char ?? */
@@ -1232,8 +1245,8 @@ test_expect_success 'grep --heading' '
 
 cat >expected <<EOF
 <BOLD;GREEN>hello.c<RESET>
-2:int main(int argc, const <BLACK;BYELLOW>char<RESET> **argv)
-6:	/* <BLACK;BYELLOW>char<RESET> ?? */
+4:int main(int argc, const <BLACK;BYELLOW>char<RESET> **argv)
+8:	/* <BLACK;BYELLOW>char<RESET> ?? */
 
 <BOLD;GREEN>hello_world<RESET>
 3:Hel<BLACK;BYELLOW>lo_w<RESET>orld
@@ -1340,7 +1353,7 @@ test_expect_success 'grep --color -e A --and --not -e B with context' '
 '
 
 cat >expected <<EOF
-hello.c-#include <stdio.h>
+hello.c-
 hello.c=int main(int argc, const char **argv)
 hello.c-{
 hello.c:	pr<RED>int<RESET>f("<RED>Hello<RESET> world.\n");
-- 
2.8.3

  parent reply	other threads:[~2016-05-28 15:05 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-05-10 21:51 [Bug?] log -p -W showing the whole file for a patch that adds to the end? Junio C Hamano
2016-05-10 22:51 ` Junio C Hamano
2016-05-12 22:12   ` René Scharfe
2016-05-21 18:42   ` René Scharfe
2016-05-21 18:45     ` [PATCH 1/5] diff: factor out match_func_rec() René Scharfe
2016-05-21 18:45     ` [PATCH 2/5] diff: handle appended chunks better with -W René Scharfe
2016-05-21 18:46     ` [PATCH 3/5] diff: ignore empty lines before added functions " René Scharfe
2016-05-21 18:46     ` [PATCH 4/5] diff: don't include common trailing empty lines " René Scharfe
2016-05-21 18:47     ` [PATCH 5/5] grep: don't extend context to " René Scharfe
2016-05-24 18:16     ` [Bug?] log -p -W showing the whole file for a patch that adds to the end? Junio C Hamano
2016-05-26  8:54       ` René Scharfe
2016-05-26 17:05         ` Junio C Hamano
2016-05-27 17:13           ` René Scharfe
2016-05-28 14:46     ` René Scharfe
2016-05-28 14:57       ` [PATCH v2 1/8] t4051: rewrite, add more tests René Scharfe
2016-05-29 23:55         ` Junio C Hamano
2016-05-30 20:55           ` René Scharfe
2016-05-31 20:00           ` [PATCH v2.5 " René Scharfe
2016-05-31 20:15             ` René Scharfe
2016-05-31 21:23             ` Junio C Hamano
2016-05-28 14:58       ` [PATCH v2 2/8] xdiff: factor out match_func_rec() René Scharfe
2016-05-28 15:00       ` [PATCH v2 3/8] xdiff: handle appended chunks better with -W René Scharfe
2016-05-28 15:02       ` [PATCH v2 4/8] xdiff: ignore empty lines before added functions " René Scharfe
2016-05-28 15:03       ` [PATCH v2 5/8] xdiff: -W: don't include common trailing empty lines in context René Scharfe
2016-05-28 15:04       ` [PATCH v2 6/8] xdiff: don't trim common tail with -W René Scharfe
2016-05-28 15:05       ` René Scharfe [this message]
2016-05-28 15:06       ` [PATCH v2 8/8] grep: -W: don't extend context to trailing empty lines René Scharfe

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=5749B3C5.4060809@web.de \
    --to=l.s.r@web.de \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=ramsay@ramsayjones.plus.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).