From 07a716b167ef6b21f82c86b026dc0f8fdd385c6f Mon Sep 17 00:00:00 2001
From: makepost <makepost@firemail.cc>
Date: Sun, 28 Apr 2019 17:00:31 +0300
Subject: Search name and first line with man -k regex.

Exec -k value as regex on basename, and on the first content line
outside a tag or on a referenced see-other, whichever appears earlier.
Reuse zcat choice as a function when looping over files. Fix \-\- and
glob.h include leftover. Handle man-pages example newlines. Clarify the
todos, naming package and issue. Remaining items are more of a wishlist
than a plan. Remove `<1>2` because it doesn't let `-k .` work, please
look into that.
---
 tests/man.test | 31 +++++++++++++++++++++++++++----
 1 file changed, 27 insertions(+), 4 deletions(-)

(limited to 'tests')

diff --git a/tests/man.test b/tests/man.test
index f261437c..65b8a06f 100644
--- a/tests/man.test
+++ b/tests/man.test
@@ -16,6 +16,7 @@ echo five > banana/man5/numbers.5
 testing "man" "$MAN numbers" " one\n\n" "" ""
 testing "man.section" "$MAN numbers.3" " three\n\n" "" ""
 testing "section man" "$MAN 5 numbers" " five\n\n" "" ""
+testing "/" "$MAN /" "" "" "" # Regression guard for !suf in zopen
 
 cat >banana/man1/toybox.1 <<EOF
 .TP
@@ -27,7 +28,7 @@ cat >banana/man1/toybox.1 <<EOF
 Does something.
 .TP
 .PD 0
-.B \\-\\^\\-no\\-alias
+.B \\-\\-no\\-alias
 Has no alias.
 EOF
 
@@ -128,6 +129,14 @@ cat >banana/man1/toybox.1 <<EOF
 EOF
 testing "bash nroff" "$MAN toybox" " Copyright (C) 2019\n\n" "" ""
 
+cat >banana/man1/toybox.1 <<EOF
+.EX
+#include <stdio.h>
+#include <stdlib.h>
+.EE
+EOF
+testing "stat example" "$MAN toybox" "#include <stdio.h>\n#include <stdlib.h>\n\n\n" "" ""
+
 cat >banana/man1/toybox.1 <<EOF
 (...)
 .PP
@@ -183,9 +192,23 @@ cat >banana/man1/toybox.1 <<EOF
 EOF
 testing "bash,git garbage" "$MAN toybox" "" "" ""
 
-# TODO: -k
+# "bash,git garbage" from above has no content, -k skips it.
+bzip2 >banana/man1/numbers.1.bz2 <<EOF
+.TH NUMBERS 1 "2019 Apr 28" "Toybox Manual"
+.SH NAME
+man \- test -k
+.SH ANOTHER SECTION
+.so noop.1
+Skip this text.
+EOF
+echo "No dash." | gzip >banana/man3/numbers.3.gz
+echo .so man1/numbers.1 >banana/man5/numbers.5
+testing "-k ." "$MAN -k ." "numbers.1.bz2 - test -k\nnumbers.3.gz - No dash.\nnumbers.5 - See numbers.1\n" "" ""
+testing "-k -k" "$MAN -k -k" "numbers.1.bz2 - test -k\n" "" ""
+testing "-k d.*h" "$MAN -k 'd.*h'" "numbers.3.gz - No dash.\n" "" ""
+testing "-k ers.1" "$MAN -k ers.1" "numbers.1.bz2 - test -k\nnumbers.5 - See numbers.1\n" "" ""
+
 # TODO: emerge section header newline
-# TODO: fdm not roff
-# TODO: git-pull consecutive escaped slashes
+# TODO: fdm,man-pages man1p/, .nf, rare tags
 
 rm -rf banana
-- 
cgit v1.2.3