Subject: bug#37697: Recently-added checkdoc tests fail if stdin is empty

From: Paul Eggert <[email-masked]>
Date: Thu, 10 Oct 2019 13:28:17 -0700

The recently-added checkdoc CL tests read from stdin, which doesn't work 
when automated tests are run. Here is how I reproduced the bug on Fedora 30:

$ cd test
$ make lisp/emacs-lisp/checkdoc-tests </dev/null
make[1]: Entering directory 
'/home/eggert/src/gnu/emacs/static-checking/test'
   GEN      lisp/emacs-lisp/checkdoc-tests.log
Running 10 tests (2019-10-10 13:23:34-0700, selector `(not (tag 
:unstable))')
    passed   1/10  checkdoc-cl-defmethod-ok (0.000504 sec)
Add GLOBAL-VAR documentation to end of doc string? (y or n) Test 
checkdoc-cl-defmethod-with-context-ok backtrace:
   read-string("Add GLOBAL-VAR documentation to end of doc string?...")
   y-or-n-p("Add GLOBAL-VAR documentation to end of doc string?...")
   checkdoc-y-or-n-p("Add GLOBAL-VAR documentation to end of doc string
   checkdoc-this-string-valid-engine(("foo" nil nil nil "a" "&context"
   checkdoc-this-string-valid()
   checkdoc-defun()
   (progn (emacs-lisp-mode) (insert "(cl-defmethod foo (a &context (glo
   (unwind-protect (progn (emacs-lisp-mode) (insert "(cl-defmethod foo
   (save-current-buffer (set-buffer temp-buffer) (unwind-protect (progn
   (let ((temp-buffer (generate-new-buffer " *temp*"))) (save-current-b
   (closure (t) nil (let ((temp-buffer (generate-new-buffer " *temp*"))
   ert--run-test-internal(#s(ert--test-execution-info :test #s(ert-test
   ert-run-test(#s(ert-test :name checkdoc-cl-defmethod-with-context-ok
   ert-run-or-rerun-test(#s(ert--stats :selector (not (tag :unstable))
   ert-run-tests((not (tag :unstable)) #f(compiled-function (event-type
   ert-run-tests-batch((not (tag :unstable)))
   ert-run-tests-batch-and-exit((not (tag :unstable)))
   eval((ert-run-tests-batch-and-exit '(not (tag :unstable))) t)
   command-line-1(("-L" ":." "-l" "ert" "-l" "lisp/emacs-lisp/checkdoc-
   command-line()
   normal-top-level()
Test checkdoc-cl-defmethod-with-context-ok condition:
     (error "Error reading from stdin")
    FAILED   2/10  checkdoc-cl-defmethod-with-context-ok (0.000547 sec)
    passed   3/10  checkdoc-cl-defmethod-with-types-ok (0.000442 sec)
    passed   4/10  checkdoc-cl-defun-with-allow-other-keys-ok (0.000375 sec)
Add C documentation to end of doc string? (y or n) Test 
checkdoc-cl-defun-with-aux-ok backtrace:
   read-string("Add C documentation to end of doc string? (y or n)...")
   y-or-n-p("Add C documentation to end of doc string? ")
   checkdoc-y-or-n-p("Add C documentation to end of doc string? ")
   checkdoc-this-string-valid-engine(("foo" nil nil nil "a" "b" "&aux"
   checkdoc-this-string-valid()
   checkdoc-defun()
   (progn (emacs-lisp-mode) (insert "(cl-defun foo (a b &aux (c (+ a b)
   (unwind-protect (progn (emacs-lisp-mode) (insert "(cl-defun foo (a b
   (save-current-buffer (set-buffer temp-buffer) (unwind-protect (progn
   (let ((temp-buffer (generate-new-buffer " *temp*"))) (save-current-b
   (closure (t) nil (let ((temp-buffer (generate-new-buffer " *temp*"))
   ert--run-test-internal(#s(ert--test-execution-info :test #s(ert-test
   ert-run-test(#s(ert-test :name checkdoc-cl-defun-with-aux-ok :docume
   ert-run-or-rerun-test(#s(ert--stats :selector (not ...) :tests [...
   ert-run-tests((not (tag :unstable)) #f(compiled-function (event-type
   ert-run-tests-batch((not (tag :unstable)))
   ert-run-tests-batch-and-exit((not (tag :unstable)))
   eval((ert-run-tests-batch-and-exit '(not (tag :unstable))) t)
   command-line-1(("-L" ":." "-l" "ert" "-l" "lisp/emacs-lisp/checkdoc-
   command-line()
   normal-top-level()
Test checkdoc-cl-defun-with-aux-ok condition:
     (error "Error reading from stdin")
    FAILED   5/10  checkdoc-cl-defun-with-aux-ok (0.000437 sec)
    passed   6/10  checkdoc-cl-defun-with-default-optional-value-ok 
(0.000446 sec)
    passed   7/10  checkdoc-cl-defun-with-destructuring-ok (0.000384 sec)
    passed   8/10  checkdoc-cl-defun-with-key-ok (0.000357 sec)
    passed   9/10  checkdoc-tests--bug-24998 (0.000257 sec)
    passed  10/10  checkdoc-tests--next-docstring (0.000228 sec)

Ran 10 tests, 8 results as expected, 2 unexpected (2019-10-10 
13:23:34-0700, 0.233146 sec)

2 unexpected results:
    FAILED  checkdoc-cl-defmethod-with-context-ok
    FAILED  checkdoc-cl-defun-with-aux-ok

make[1]: *** [Makefile:183: lisp/emacs-lisp/checkdoc-tests.log] Error 1
make[1]: Leaving directory '/home/eggert/src/gnu/emacs/static-checking/test'
make: *** [Makefile:249: lisp/emacs-lisp/checkdoc-tests] Error 2