summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorNoam Postavsky <npostavs@gmail.com>2019-08-18 18:10:50 -0400
committerNoam Postavsky <npostavs@gmail.com>2019-08-18 18:19:21 -0400
commitf9464020d403be8344f8293297b27276872571d4 (patch)
tree476385d0b3d7db330b14125f40d147c2411b9492 /test
parent780509f29f0aa006a578744f7e871eb6d5ce5931 (diff)
downloademacs-f9464020d403be8344f8293297b27276872571d4.tar.gz
Handle more subprocess chunking in M-x man (Bug#36927)
* lisp/man.el (Man-bgproc-filter): Make sure not to chop man sections by narrowing. (Man-highlight-references0): Revert previous fix, as it's no longer needed. * test/lisp/man-tests.el (man-tests-filter-strings): New function. (man-bgproc-filter-buttonize-includes): New test.
Diffstat (limited to 'test')
-rw-r--r--test/lisp/man-tests.el48
1 files changed, 48 insertions, 0 deletions
diff --git a/test/lisp/man-tests.el b/test/lisp/man-tests.el
index dca0ff19398..9932e03f21a 100644
--- a/test/lisp/man-tests.el
+++ b/test/lisp/man-tests.el
@@ -24,6 +24,7 @@
(require 'ert)
(require 'man)
+(require 'seq)
(defconst man-tests-parse-man-k-tests
'(;; GNU/Linux: man-db-2.6.1
@@ -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