From 799e09e5fb9e23e2baae164ddc84a03879db6a6a Mon Sep 17 00:00:00 2001 From: =?utf8?q?Ren=C3=A9=20Scharfe?= Date: Sat, 28 May 2016 17:05:41 +0200 Subject: [PATCH] t7810: add test for grep -W and trailing empty context lines 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 Signed-off-by: Junio C Hamano --- 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 b540944408..c42b82ae52 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 < #include + int main(int argc, const char **argv) { printf("Hello world.\n"); @@ -715,6 +717,7 @@ test_expect_success 'grep -p' ' cat >expected < +hello.c- hello.c=int main(int argc, const char **argv) hello.c-{ hello.c- printf("Hello world.\n"); @@ -740,6 +743,16 @@ test_expect_success 'grep -W' ' test_cmp expected actual ' +cat >expected < +hello.c:#include +EOF + +test_expect_failure 'grep -W shows no trailing empty lines' ' + git grep -W stdio >actual && + test_cmp expected actual +' + cat >expected <expected <hello.c -2:int main(int argc, const char **argv) -6: /* char ?? */ +4:int main(int argc, const char **argv) +8: /* char ?? */ hello_world 3:Hello_world @@ -1313,7 +1326,7 @@ test_expect_success 'grep --color -e A --and --not -e B with context' ' ' cat >expected < +hello.c- hello.c=int main(int argc, const char **argv) hello.c-{ hello.c: printf("Hello world.\n"); -- 2.48.1