summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJim Meyering <meyering@fb.com>2020-09-17 13:16:42 -0700
committerJim Meyering <meyering@fb.com>2020-09-17 13:16:42 -0700
commit2c79623eb519aae04d42f938408280e5c59f23f8 (patch)
treee120fb3babd0dd47509d52a7cab2e69853366608
parent4b3f435b62107d35167f055bb4bad120159703d7 (diff)
downloadgrep-2c79623eb519aae04d42f938408280e5c59f23f8.tar.gz
tests: add coverage for code that emits the new diagnostic
* tests/binary-file-matches: New file. * tests/Makefile.am (TESTS): Add it.
-rw-r--r--tests/Makefile.am1
-rw-r--r--tests/binary-file-matches21
2 files changed, 22 insertions, 0 deletions
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 24f2c21e..3ee29154 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -70,6 +70,7 @@ TESTS = \
backslash-s-vs-invalid-multibyte \
big-hole \
big-match \
+ binary-file-matches \
bogus-wctob \
bre \
c-locale \
diff --git a/tests/binary-file-matches b/tests/binary-file-matches
new file mode 100644
index 00000000..75c23bcb
--- /dev/null
+++ b/tests/binary-file-matches
@@ -0,0 +1,21 @@
+#! /bin/sh
+# Test for the "binary file ... matches" diagnostic.
+#
+# Copyright (C) 2020 Free Software Foundation, Inc.
+#
+# Copying and distribution of this file, with or without modification,
+# are permitted in any medium without royalty provided the copyright
+# notice and this notice are preserved.
+
+. "${srcdir=.}/init.sh"; path_prepend_ ../src
+
+fail=0
+
+echo "grep: binary file '(standard input)' matches" > exp \
+ || framework_failure_
+
+printf 'a\0' | grep a > out 2> err || fail=1
+compare /dev/null out || fail=1
+compare exp err || fail=1
+
+Exit $fail