mirror of
git://git.gnupg.org/gnupg.git
synced 2025-04-17 15:44:34 +02:00
tests: Refine the repl function.
* tests/gpgscm/repl.scm (repl): Add an argument 'environment'. (interactive-repl): Add an optional argument 'environment'. -- With this change, we can drop (interactive-repl (current-environment)) anywhere into the code and do some interactive debugging. Signed-off-by: Justus Winter <justus@g10code.com>
This commit is contained in:
parent
9a0659a65c
commit
884e78efe1
@ -20,8 +20,7 @@
|
|||||||
;; Interactive repl using 'prompt' function. P must be a function
|
;; Interactive repl using 'prompt' function. P must be a function
|
||||||
;; that given the current entered prefix returns the prompt to
|
;; that given the current entered prefix returns the prompt to
|
||||||
;; display.
|
;; display.
|
||||||
(define (repl p)
|
(define (repl p environment)
|
||||||
(let ((repl-environment (make-environment)))
|
|
||||||
(call/cc
|
(call/cc
|
||||||
(lambda (exit)
|
(lambda (exit)
|
||||||
(let loop ((prefix ""))
|
(let loop ((prefix ""))
|
||||||
@ -36,9 +35,9 @@
|
|||||||
(if (not (eof-object? c))
|
(if (not (eof-object? c))
|
||||||
(begin
|
(begin
|
||||||
(catch (echo "Error:" *error*)
|
(catch (echo "Error:" *error*)
|
||||||
(echo " ===>" (eval c repl-environment)))
|
(echo " ===>" (eval c environment)))
|
||||||
(exit (loop ""))))
|
(exit (loop ""))))
|
||||||
(exit (loop next))))))))))
|
(exit (loop next)))))))))
|
||||||
|
|
||||||
(define (prompt-append-prefix prompt prefix)
|
(define (prompt-append-prefix prompt prefix)
|
||||||
(string-append prompt (if (> (string-length prefix) 0)
|
(string-append prompt (if (> (string-length prefix) 0)
|
||||||
@ -46,5 +45,6 @@
|
|||||||
"> ")))
|
"> ")))
|
||||||
|
|
||||||
;; Default repl run by main.c.
|
;; Default repl run by main.c.
|
||||||
(define (interactive-repl)
|
(define (interactive-repl . environment)
|
||||||
(repl (lambda (p) (prompt-append-prefix "gpgscm " p))))
|
(repl (lambda (p) (prompt-append-prefix "gpgscm " p))
|
||||||
|
(if (null? environment) (interaction-environment) (car environment))))
|
||||||
|
Loading…
x
Reference in New Issue
Block a user