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>
René Scharfe committed
May 28, 2016 at 17:05 UTC
799e09e5fb9e23e2baae164ddc84a03879db6a6a
1 file changed
+16
-3
t/t7810-grep.sh
+16
-3
@@ -9,7 +9,9 @@ test_description='git grep various.
9
. ./test-lib.sh
10
11
cat >hello.c <<EOF
12
+#include <assert.h>
13
#include <stdio.h>
14
+
15
int main(int argc, const char **argv)
16
{
17
printf("Hello world.\n");
@@ -715,6 +717,7 @@ test_expect_success 'grep -p' '
717
718
cat >expected <<EOF
719
hello.c-#include <stdio.h>
720
+hello.c-
721
hello.c=int main(int argc, const char **argv)
722
hello.c-{
723
hello.c- printf("Hello world.\n");
@@ -740,6 +743,16 @@ test_expect_success 'grep -W' '
743
test_cmp expected actual
744
'
745
746
+cat >expected <<EOF
747
+hello.c-#include <assert.h>
748
+hello.c:#include <stdio.h>
749
+EOF
750
+
751
+test_expect_failure 'grep -W shows no trailing empty lines' '
752
+ git grep -W stdio >actual &&
753
+ test_cmp expected actual
754
+'
755
+
756
cat >expected <<EOF
757
hello.c= printf("Hello world.\n");
758
hello.c: return 0;
@@ -1205,8 +1218,8 @@ test_expect_success 'grep --heading' '
1218
1219
cat >expected <<EOF
1220
<BOLD;GREEN>hello.c<RESET>
1208
-2:int main(int argc, const <BLACK;BYELLOW>char<RESET> **argv)
1209
-6: /* <BLACK;BYELLOW>char<RESET> ?? */
1221
+4:int main(int argc, const <BLACK;BYELLOW>char<RESET> **argv)
1222
+8: /* <BLACK;BYELLOW>char<RESET> ?? */
1223
1224
<BOLD;GREEN>hello_world<RESET>
1225
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' '
1326
'
1327
1328
cat >expected <<EOF
1316
-hello.c-#include <stdio.h>
1329
+hello.c-
1330
hello.c=int main(int argc, const char **argv)
1331
hello.c-{
1332
hello.c: pr<RED>int<RESET>f("<RED>Hello<RESET> world.\n");