all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* read-string from standard-input?
@ 2016-03-14 11:21 Michael Albinus
  2016-03-14 14:01 ` Philipp Stephani
  2016-03-15 12:35 ` Stefan Monnier
  0 siblings, 2 replies; 5+ messages in thread
From: Michael Albinus @ 2016-03-14 11:21 UTC (permalink / raw)
  To: help-gnu-emacs

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.



^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: read-string from standard-input?
  2016-03-14 11:21 read-string from standard-input? Michael Albinus
@ 2016-03-14 14:01 ` Philipp Stephani
  2016-03-14 14:42   ` Michael Albinus
  2016-03-15 12:35 ` Stefan Monnier
  1 sibling, 1 reply; 5+ messages in thread
From: Philipp Stephani @ 2016-03-14 14:01 UTC (permalink / raw)
  To: Michael Albinus, help-gnu-emacs

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"))))


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: read-string from standard-input?
  2016-03-14 14:01 ` Philipp Stephani
@ 2016-03-14 14:42   ` Michael Albinus
  0 siblings, 0 replies; 5+ messages in thread
From: Michael Albinus @ 2016-03-14 14:42 UTC (permalink / raw)
  To: Philipp Stephani; +Cc: help-gnu-emacs

Philipp Stephani <p.stephani2@gmail.com> writes:

Hi Philipp,

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

That works, thanks a lot!

Best regards, Michael.



^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: read-string from standard-input?
  2016-03-14 11:21 read-string from standard-input? Michael Albinus
  2016-03-14 14:01 ` Philipp Stephani
@ 2016-03-15 12:35 ` Stefan Monnier
  2016-03-15 12:53   ` Michael Albinus
  1 sibling, 1 reply; 5+ messages in thread
From: Stefan Monnier @ 2016-03-15 12:35 UTC (permalink / raw)
  To: help-gnu-emacs

> 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?

I'm not sure I understand.

    % emacs --batch -Q --eval '(message (read-string "hello:"))'

shows that `read-string' does read from stdin already if we're not in an
interactive session.  What am I missing?


        Stefan




^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: read-string from standard-input?
  2016-03-15 12:35 ` Stefan Monnier
@ 2016-03-15 12:53   ` Michael Albinus
  0 siblings, 0 replies; 5+ messages in thread
From: Michael Albinus @ 2016-03-15 12:53 UTC (permalink / raw)
  To: Stefan Monnier; +Cc: help-gnu-emacs

Stefan Monnier <monnier@iro.umontreal.ca> writes:

>> 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?
>
> I'm not sure I understand.
>
>     % emacs --batch -Q --eval '(message (read-string "hello:"))'
>
> shows that `read-string' does read from stdin already if we're not in an
> interactive session.  What am I missing?

I do not want to read from stdin (UNIX level). I want to read from a
stream inside Emacs (buffer or string), defined by the Lisp variable
`standard-input'.

>         Stefan

Best regards, Michael.



^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2016-03-15 12:53 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-03-14 11:21 read-string from standard-input? Michael Albinus
2016-03-14 14:01 ` Philipp Stephani
2016-03-14 14:42   ` Michael Albinus
2016-03-15 12:35 ` Stefan Monnier
2016-03-15 12:53   ` Michael Albinus

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.