mirror of
git://git.gnupg.org/gnupg.git
synced 2024-09-21 15:01:41 +02:00
gpgscm: Capture output of spawned processes.
* tests/gpgscm/tests.scm (call-check): Capture stdout and stderr, and return stdout if the child exited successfully, or include stderr in the error. * tests/openpgp/version.scm: Demonstrate this by checking the stdout. Signed-off-by: Justus Winter <justus@g10code.com>
This commit is contained in:
parent
511c2522b9
commit
2f61aa0ff1
@ -94,9 +94,6 @@
|
|||||||
CLOSED_FD
|
CLOSED_FD
|
||||||
(if (< *verbose* 0) STDOUT_FILENO CLOSED_FD)
|
(if (< *verbose* 0) STDOUT_FILENO CLOSED_FD)
|
||||||
(if (< *verbose* 0) STDERR_FILENO CLOSED_FD)))
|
(if (< *verbose* 0) STDERR_FILENO CLOSED_FD)))
|
||||||
(define (call-check what)
|
|
||||||
(if (not (= 0 (call what)))
|
|
||||||
(throw (list what "failed"))))
|
|
||||||
|
|
||||||
;; Accessor functions for the results of 'spawn-process'.
|
;; Accessor functions for the results of 'spawn-process'.
|
||||||
(define :stdin car)
|
(define :stdin car)
|
||||||
@ -119,6 +116,12 @@
|
|||||||
;; ':stderr' can also be used.
|
;; ':stderr' can also be used.
|
||||||
(define :retcode car)
|
(define :retcode car)
|
||||||
|
|
||||||
|
(define (call-check what)
|
||||||
|
(let ((result (call-with-io what "")))
|
||||||
|
(if (= 0 (:retcode result))
|
||||||
|
(:stdout result)
|
||||||
|
(throw (list what "failed:" (:stderr result))))))
|
||||||
|
|
||||||
(define (call-popen command input-string)
|
(define (call-popen command input-string)
|
||||||
(let ((result (call-with-io command input-string)))
|
(let ((result (call-with-io command input-string)))
|
||||||
(if (= 0 (:retcode result))
|
(if (= 0 (:retcode result))
|
||||||
|
@ -20,6 +20,5 @@
|
|||||||
(load (with-path "defs.scm"))
|
(load (with-path "defs.scm"))
|
||||||
|
|
||||||
(info "Printing the GPG version")
|
(info "Printing the GPG version")
|
||||||
(assert (= 0 (call `(,@GPG --version))))
|
(assert (string-contains? (call-check `(,@GPG --version))
|
||||||
|
"gpg (GnuPG) 2."))
|
||||||
;; fixme: check that the output is as expected
|
|
||||||
|
Loading…
Reference in New Issue
Block a user