[Pkg-gnupg-commit] [gnupg2] 20/292: tests: Refine exception handling.
Daniel Kahn Gillmor
dkg at fifthhorseman.net
Mon Nov 21 06:31:22 UTC 2016
This is an automated email from the git hooks/post-receive script.
dkg pushed a commit to branch master
in repository gnupg2.
commit ab483eff9a8254adf127cdee178e14ba74f0a2b3
Author: Justus Winter <justus at g10code.com>
Date: Mon Sep 19 17:19:00 2016 +0200
tests: Refine exception handling.
* tests/gpgscm/init.scm (catch): Bind all arguments to '*error*' in
the error handler, update and fix comment.
(*error-hook*): Revert to original definition.
* tests/gpgscm/tests.scm (tr:do): Adapt accordingly.
* tests/openpgp/issue2419.scm: Likewise.
Signed-off-by: Justus Winter <justus at g10code.com>
---
tests/gpgscm/init.scm | 10 +++++-----
tests/gpgscm/tests.scm | 2 +-
tests/openpgp/issue2419.scm | 2 +-
3 files changed, 7 insertions(+), 7 deletions(-)
diff --git a/tests/gpgscm/init.scm b/tests/gpgscm/init.scm
index b32172b..f8fd71a 100644
--- a/tests/gpgscm/init.scm
+++ b/tests/gpgscm/init.scm
@@ -544,13 +544,14 @@
;
; "Catch" establishes a scope spanning multiple call-frames until
; another "catch" is encountered. Within the recovery expression
-; the thrown exception is bound to *error*.
+; the thrown exception is bound to *error*. Errors can be rethrown
+; using (apply throw *error*).
;
; Exceptions are thrown with:
;
; (throw "message")
;
-; If used outside a (catch ...), reverts to (error "message)
+; If used outside a (catch ...), reverts to (error "message")
(define *handlers* (list))
@@ -573,13 +574,12 @@
(macro (catch form)
(let ((label (gensym)))
`(call/cc (lambda (**exit**)
- (push-handler (lambda (*error*) (**exit** ,(cadr form))))
+ (push-handler (lambda *error* (**exit** ,(cadr form))))
(let ((,label (begin ,@(cddr form))))
(pop-handler)
,label)))))
-(define (*error-hook* . args)
- (throw args))
+(define *error-hook* throw)
;;;;; Definition of MAKE-ENVIRONMENT, to be used with two-argument EVAL
diff --git a/tests/gpgscm/tests.scm b/tests/gpgscm/tests.scm
index 0738bc6..7b88e0e 100644
--- a/tests/gpgscm/tests.scm
+++ b/tests/gpgscm/tests.scm
@@ -411,7 +411,7 @@
(if error
(begin
(for-each remove-temporary-file tmpfiles')
- (throw error)))
+ (apply throw error)))
(loop tmpfiles' sink (cdr cmds))))))
(define (tr:open pathname)
diff --git a/tests/openpgp/issue2419.scm b/tests/openpgp/issue2419.scm
index efc42a6..1f87d1b 100755
--- a/tests/openpgp/issue2419.scm
+++ b/tests/openpgp/issue2419.scm
@@ -23,6 +23,6 @@
(lettmp
(onebyte)
(dearmor (in-srcdir "samplemsgs/issue2419.asc") onebyte)
- (catch (assert (string-contains? *error* "invalid packet"))
+ (catch (assert (string-contains? (car *error*) "invalid packet"))
(call-popen `(, at GPG --list-packets ,onebyte) "")
(error "Expected an error but got none")))
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-gnupg/gnupg2.git
More information about the Pkg-gnupg-commit
mailing list