aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRené Scharfe <l.s.r@web.de>2016-05-28 17:05:41 +0200
committerJunio C Hamano <gitster@pobox.com>2016-05-31 13:08:56 -0700
commit799e09e5fb9e23e2baae164ddc84a03879db6a6a (patch)
tree1db47b3c0eadb2ac97789582859ad24be140abd2
parente0876bca4de44638a1cb51b03bdf0a40df631a80 (diff)
downloadgit-799e09e5fb9e23e2baae164ddc84a03879db6a6a.tar.gz
git-799e09e5fb9e23e2baae164ddc84a03879db6a6a.tar.xz
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 <l.s.r@web.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>
-rwxr-xr-xt/t7810-grep.sh19
1 files changed, 16 insertions, 3 deletions
diff --git a/t/t7810-grep.sh b/t/t7810-grep.sh
index b54094440..c42b82ae5 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 ?? */
@@ -1205,8 +1218,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
@@ -1313,7 +1326,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");