[PATCH 2/4] add tests for grep --heading with context

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



It is easy to make a mistake in the logic that conditionally prints out
hunk separators in the various combinations of --heading, --break,
and --context.

Signed-off-by: Mark Lodato <lodatom@xxxxxxxxx>
---
 t/t7810-grep.sh |   37 +++++++++++++++++++++++++++++++++++++
 1 file changed, 37 insertions(+)

diff --git a/t/t7810-grep.sh b/t/t7810-grep.sh
index d9ad633..58c0821 100755
--- a/t/t7810-grep.sh
+++ b/t/t7810-grep.sh
@@ -901,6 +901,43 @@ test_expect_success 'mimic ack-grep --group' '
 '
 
 cat >expected <<EOF
+hello.c
+int main(int argc, const char **argv)
+{
+--
+	/* char ?? */
+}
+--
+hello_world
+Hello_world
+HeLLo_world
+EOF
+
+test_expect_success 'grep --heading with context' '
+	git grep --heading -A1 -e char -e lo_w hello.c hello_world >actual &&
+	test_cmp expected actual
+'
+
+cat >expected <<EOF
+hello.c
+int main(int argc, const char **argv)
+{
+--
+	/* char ?? */
+}
+
+hello_world
+Hello_world
+HeLLo_world
+EOF
+
+test_expect_success 'grep --break --heading with context' '
+	git grep --break --heading -A1 \
+		-e char -e lo_w hello.c hello_world >actual &&
+	test_cmp expected actual
+'
+
+cat >expected <<EOF
 space: line with leading space1
 space: line with leading space2
 space: line with leading space3
-- 
1.7.9.2

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


[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]