aboutsummaryrefslogtreecommitdiff
path: root/tests/grep.test
diff options
context:
space:
mode:
authorRob Landley <rob@landley.net>2016-07-23 01:32:23 -0500
committerRob Landley <rob@landley.net>2016-07-23 01:32:23 -0500
commit12adb4113d7c269f26c53292f91079b7c2fee3d1 (patch)
tree77bd02b19a6088ce5f97f23f86f0442c1e6c4606 /tests/grep.test
parentc7f0d6ce8987262d5e310025413a75d6290d7c7e (diff)
downloadtoybox-12adb4113d7c269f26c53292f91079b7c2fee3d1.tar.gz
Many failing tests I need to fix grep to pass while adding --color.
Diffstat (limited to 'tests/grep.test')
-rwxr-xr-xtests/grep.test34
1 files changed, 34 insertions, 0 deletions
diff --git a/tests/grep.test b/tests/grep.test
index 227fee00..2a4f178b 100755
--- a/tests/grep.test
+++ b/tests/grep.test
@@ -109,3 +109,37 @@ testing "-C" "grep -C 1 yes" \
testing "-HnC" "grep -HnC1 two" \
"(standard input)-1-one\n(standard input):2:two\n(standard input)-3-three\n" \
"" "one\ntwo\nthree"
+
+# Context lines weren't showing -b
+testing "-HnbB1" "grep -HnbB1 f input" \
+ "input-3-8-three\ninput:4:14:four\ninput:5:19:five\n" \
+ "one\ntwo\nthree\nfour\nfive\n" ""
+
+testing "-q match overrides error" \
+ "grep -q hello missing input 2>/dev/null && echo yes" "yes\n" "hello\n" ""
+testing "-q not found is 1" \
+ 'grep -q hello input || echo $?' "1\n" "" ""
+testing "-q missing is 2" \
+ 'grep -q hello missing missing 2>/dev/null || echo $?' "2\n" "" ""
+testing "-q missing survives exists but not found" \
+ 'grep -q hello missing missing input 2>/dev/null || echo $?' "2\n" "" ""
+testing "not found retained past match" \
+ 'grep hello missing input 2>/dev/null || echo $?' \
+ "input:hello\n2\n" "hello\n" ""
+touch empty
+testing "one match good enough for 0" \
+ 'grep hello input empty && echo $?' 'input:hello\n0\n' 'hello\n' ''
+rm empty
+
+testing "-o ''" "grep -o ''" "" "" "one two three\none two\none\n"
+testing '' "grep -o -e '' -e two" "two\ntwo\n" "" \
+ "one two three\none two\none\n"
+
+echo "one\ntwo\nthree" > test
+testing "-l trumps -C" "grep -l -C1 two test input" "test\ninput\n" \
+ "three\ntwo\none\n" ""
+rm test
+
+# match after NUL byte
+testing "match after NUL byte" "grep -a two" "one\0and two three\n" \
+ "" 'one\0and two three'