summaryrefslogtreecommitdiff
path: root/test/lisp/man-tests.el
diff options
context:
space:
mode:
authorStefan Monnier <monnier@iro.umontreal.ca>2022-09-25 16:15:16 -0400
committerStefan Monnier <monnier@iro.umontreal.ca>2022-09-25 16:15:16 -0400
commit650c20f1ca4e07591a727e1cfcc74b3363d15985 (patch)
tree85d11f6437cde22f410c25e0e5f71a3131ebd07d /test/lisp/man-tests.el
parent8869332684c2302b5ba1ead4568bbc7ba1c0183e (diff)
parent4b85ae6a24380fb67a3315eaec9233f17a872473 (diff)
downloademacs-650c20f1ca4e07591a727e1cfcc74b3363d15985.tar.gz
emacs-650c20f1ca4e07591a727e1cfcc74b3363d15985.tar.bz2
emacs-650c20f1ca4e07591a727e1cfcc74b3363d15985.zip
Merge 'master' into noverlay
Diffstat (limited to 'test/lisp/man-tests.el')
-rw-r--r--test/lisp/man-tests.el56
1 files changed, 52 insertions, 4 deletions
diff --git a/test/lisp/man-tests.el b/test/lisp/man-tests.el
index 9294994892d..82714f15668 100644
--- a/test/lisp/man-tests.el
+++ b/test/lisp/man-tests.el
@@ -1,6 +1,6 @@
-;;; man-tests.el --- Test suite for man.
+;;; man-tests.el --- Test suite for man. -*- lexical-binding:t -*-
-;; Copyright (C) 2013-2017 Free Software Foundation, Inc.
+;; Copyright (C) 2013-2022 Free Software Foundation, Inc.
;; Author: Wolfgang Jenkner <wjenkner@inode.at>
;; Keywords: help, internal, unix
@@ -24,6 +24,7 @@
(require 'ert)
(require 'man)
+(require 'seq)
(defconst man-tests-parse-man-k-tests
'(;; GNU/Linux: man-db-2.6.1
@@ -43,7 +44,7 @@ sinl [sin] (3) - sine function"
sin(3), sinf(3), sinl(3) - sine functions"
. (#("sin(3)" 0 6 (help-echo "sine functions")) #("sinf(3)" 0 7 (help-echo "sine functions")) #("sinl(3)" 0 7 (help-echo "sine functions"))))
;; SunOS, Solaris
- ;; http://docs.oracle.com/cd/E19455-01/805-6331/usradm-7/index.html
+ ;; https://docs.oracle.com/cd/E19455-01/805-6331/usradm-7/index.html
;; SunOS 4
("\
tset, reset (1) - establish or restore terminal characteristics"
@@ -60,7 +61,7 @@ cawf, nroff (1) - C version of the nroff-like, Amazingly Workable (text) Formatt
whatis (5) - database of online manual pages"
. (#("cawf(1)" 0 7 (help-echo "C version of the nroff-like, Amazingly Workable (text) Formatter")) #("nroff(1)" 0 8 (help-echo "C version of the nroff-like, Amazingly Workable (text) Formatter")) #("whatis(5)" 0 9 (help-echo "database of online manual pages"))))
;; HP-UX
- ;; http://docstore.mik.ua/manuals/hp-ux/en/B2355-60130/man.1.html
+ ;; https://docstore.mik.ua/manuals/hp-ux/en/B2355-60130/man.1.html
;; Assuming that the line break in the zgrep description was
;; introduced by the man page formatting.
("\
@@ -113,6 +114,53 @@ in the cdr of the element.")
(dolist (test man-tests-parse-man-k-tests)
(should (man-tests-parse-man-k-test-case test))))
+(defun man-tests-filter-strings (_buffer strings)
+ "Run `Man-bgproc-filter' on each of STRINGS.
+The formatted result will be inserted into BUFFER."
+ (let ((proc (start-process "dummy man-tests proc" (current-buffer) "cat")))
+ (set-process-query-on-exit-flag proc nil)
+ (dolist (str strings)
+ (Man-bgproc-filter proc str))))
+
+(ert-deftest man-bgproc-filter-buttonize-includes ()
+ ;; Test with abridged version of printf man page (Bug#36927).
+ (let ((str "\
+PRINTF(3) Linux Programmer's Manual PRINTF(3)
+
+NAME
+ printf, fprintf, dprintf, sprintf, snprintf, vprintf, vfprintf,
+
+SYNOPSIS
+ #include <stdio.h>
+
+ int printf(const char *format, ...);
+
+ #include <stdarg.h>
+
+ int vsprintf(char *str, const char *format, va_list ap);
+
+DESCRIPTION
+ The functions in the printf() family produce output according\n"))
+ (with-temp-buffer
+ (dolist (chunks
+ (list
+ ;; Test a few different kinds of chunking.
+ (list str)
+ (seq-mapcat (lambda (line)
+ (list line "\n"))
+ (split-string str "\n"))
+ (mapcar #'string str)))
+ (erase-buffer)
+ (man-tests-filter-strings (current-buffer) chunks)
+ (goto-char (point-min))
+ (ert-info ((format "%S" chunks) :prefix "Input: ")
+ (search-forward "#include <stdio.h>")
+ (let ((button (button-at (match-beginning 0))))
+ (should (and button (eq 'Man-xref-header-file (button-type button)))))
+ (search-forward "#include <stdarg.h>")
+ (let ((button (button-at (match-beginning 0))))
+ (should (and button (eq 'Man-xref-header-file (button-type button))))))))))
+
(provide 'man-tests)
;;; man-tests.el ends here