help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: read-string from standard-input?


From: Philipp Stephani
Subject: Re: read-string from standard-input?
Date: Mon, 14 Mar 2016 14:01:30 +0000

Michael Albinus <michael.albinus@gmx.de> schrieb am Mo., 14. März 2016 um
12:21 Uhr:

> Hi,
>
> these days, I'm writing some ert tests for shadowfile.el. Unfortunately
> some of the functions work strictly interactively, like
> shadow-define-cluster. It uses read-string for collecting its arguments.
>
> Running regression tests with interactive input is not what I want. Is
> there a technique, that read-string takes its input from a stream, like
> standard-input?
>
> TIA, and best regards, Michael.
>


You could simply mock out read-string, for example:

(ert-deftest read-string ()
  (cl-letf* ((mocked-input '("foo" "bar" "baz"))
             ((symbol-function 'read-string)
             (lambda (&rest args)
               (pop mocked-input))))
    (should (equal (read-string "prompt 1") "foo"))
    (should (equal (read-string "prompt 2") "bar"))))


reply via email to

[Prev in Thread] Current Thread [Next in Thread]