[Pkg-gnupg-commit] [gnupg2] 21/292: tests: Correctly handle exceptions in resource handling macros.

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 58007e52593e6b0f838de2e464ceeacf22757018
Author: Justus Winter <justus at g10code.com>
Date:   Mon Sep 19 17:24:03 2016 +0200

    tests: Correctly handle exceptions in resource handling macros.
    
    * tests/gpgscm/tests.scm (letfd): Correctly release resources when an
    exception is thrown.
    (with-working-directory): Likewise.
    (with-temporary-working-directory): Likewise.
    (lettmp): Likewise.
    
    Signed-off-by: Justus Winter <justus at g10code.com>
---
 tests/gpgscm/tests.scm | 17 +++++++++++++----
 1 file changed, 13 insertions(+), 4 deletions(-)

diff --git a/tests/gpgscm/tests.scm b/tests/gpgscm/tests.scm
index 7b88e0e..71ca369 100644
--- a/tests/gpgscm/tests.scm
+++ b/tests/gpgscm/tests.scm
@@ -234,7 +234,9 @@
     `((lambda (,(caaadr form))
 	(let ((,result-sym
 	       ,(if (= 1 (length (cadr form)))
-		    `(begin ,@(cddr form))
+		    `(catch (begin (close ,(caaadr form))
+				   (apply throw *error*))
+			    ,@(cddr form))
 		    `(letfd ,(cdadr form) ,@(cddr form)))))
 	  (close ,(caaadr form))
 	  ,result-sym)) ,@(cdaadr form))))
@@ -243,7 +245,9 @@
   (let ((result-sym (gensym)) (cwd-sym (gensym)))
     `(let* ((,cwd-sym (getcwd))
 	    (_ (if ,(cadr form) (chdir ,(cadr form))))
-	    (,result-sym (begin ,@(cddr form))))
+	    (,result-sym (catch (begin (chdir ,cwd-sym)
+				       (apply throw *error*))
+				,@(cddr form))))
        (chdir ,cwd-sym)
        ,result-sym)))
 
@@ -264,7 +268,10 @@
     `(let* ((,cwd-sym (getcwd))
 	    (,tmp-sym (mkdtemp))
 	    (_ (chdir ,tmp-sym))
-	    (,result-sym (begin ,@(cdr form))))
+	    (,result-sym (catch (begin (chdir ,cwd-sym)
+				       (unlink-recursively ,tmp-sym)
+				       (apply throw *error*))
+				,@(cdr form))))
        (chdir ,cwd-sym)
        (unlink-recursively ,tmp-sym)
        ,result-sym)))
@@ -293,7 +300,9 @@
     `((lambda (,(caadr form))
 	(let ((,result-sym
 	       ,(if (= 1 (length (cadr form)))
-		    `(begin ,@(cddr form))
+		    `(catch (begin (remove-temporary-file ,(caadr form))
+				   (apply throw *error*))
+			    ,@(cddr form))
 		    `(lettmp ,(cdadr form) ,@(cddr form)))))
 	  (remove-temporary-file ,(caadr form))
 	  ,result-sym)) (make-temporary-file ,(symbol->string (caadr form))))))

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