[Pkg-gnupg-commit] [gnupg2] 24/112: gpgscm: Make the verbose setting more useful.

Daniel Kahn Gillmor dkg at fifthhorseman.net
Tue Aug 30 17:48:16 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 f17aecbcd98103fcd2ece537be96930f354de656
Author: Justus Winter <justus at g10code.com>
Date:   Tue Jul 26 15:53:50 2016 +0200

    gpgscm: Make the verbose setting more useful.
    
    * tests/gpgscm/ffi.c (do_get_verbose): New function.
    (do_set_verbose): Likewise.
    (ffi_init): Turn *verbose* into a function, add *set-verbose!*.
    * tests/gpgscm/tests.scm (call): Adapt accordingly.
    (call-with-io): Dump output if *verbose* is high.
    (pipe-do): Adapt accordingly.
    * tests/openpgp/defs.scm: Set verbosity according to environment.
    * tests/openpgp/run-tests.scm (test): Adapt accordingly.
    
    Signed-off-by: Justus Winter <justus at g10code.com>
---
 tests/gpgscm/ffi.c          | 27 ++++++++++++++++++++++++++-
 tests/gpgscm/tests.scm      | 11 ++++++++---
 tests/openpgp/defs.scm      |  4 ++++
 tests/openpgp/run-tests.scm |  2 +-
 4 files changed, 39 insertions(+), 5 deletions(-)

diff --git a/tests/gpgscm/ffi.c b/tests/gpgscm/ffi.c
index 5494c4d..c37bf1d 100644
--- a/tests/gpgscm/ffi.c
+++ b/tests/gpgscm/ffi.c
@@ -1052,6 +1052,30 @@ do_glob (scheme *sc, pointer args)
 }
 
 

+
+static pointer
+do_get_verbose (scheme *sc, pointer args)
+{
+  FFI_PROLOG ();
+  FFI_ARGS_DONE_OR_RETURN (sc, args);
+  FFI_RETURN_INT (sc, verbose);
+}
+
+static pointer
+do_set_verbose (scheme *sc, pointer args)
+{
+  FFI_PROLOG ();
+  int new_verbosity, old;
+  FFI_ARG_OR_RETURN (sc, int, new_verbosity, number, args);
+  FFI_ARGS_DONE_OR_RETURN (sc, args);
+
+  old = verbose;
+  verbose = new_verbosity;
+
+  FFI_RETURN_INT (sc, old);
+}
+
+

 gpg_error_t
 ffi_list2argv (scheme *sc, pointer list, char ***argv, size_t *len)
 {
@@ -1260,7 +1284,8 @@ ffi_init (scheme *sc, const char *argv0, int argc, const char **argv)
   ffi_define_function (sc, prompt);
 
   /* Configuration.  */
-  ffi_define (sc, "*verbose*", sc->vptr->mk_integer (sc, verbose));
+  ffi_define_function_name (sc, "*verbose*", get_verbose);
+  ffi_define_function_name (sc, "*set-verbose!*", set_verbose);
 
   ffi_define (sc, "*argv0*", sc->vptr->mk_string (sc, argv0));
   for (i = argc - 1; i >= 0; i--)
diff --git a/tests/gpgscm/tests.scm b/tests/gpgscm/tests.scm
index e14e0e3..f97b22e 100644
--- a/tests/gpgscm/tests.scm
+++ b/tests/gpgscm/tests.scm
@@ -92,8 +92,8 @@
 (define (call what)
   (call-with-fds what
 		 CLOSED_FD
-		 (if (< *verbose* 0) STDOUT_FILENO CLOSED_FD)
-		 (if (< *verbose* 0) STDERR_FILENO CLOSED_FD)))
+		 (if (< (*verbose*) 0) STDOUT_FILENO CLOSED_FD)
+		 (if (< (*verbose*) 0) STDERR_FILENO CLOSED_FD)))
 
 ;; Accessor functions for the results of 'spawn-process'.
 (define :stdin car)
@@ -110,6 +110,11 @@
 	   (result (wait-process (car what) (:pid h) #t)))
       (es-fclose (:stdout h))
       (es-fclose (:stderr h))
+      (if (> (*verbose*) 2)
+	  (begin
+	    (echo (stringify what) "returned:" result)
+	    (echo (stringify what) "wrote to stdout:" out)
+	    (echo (stringify what) "wrote to stderr:" err)))
       (list result out err))))
 
 ;; Accessor function for the results of 'call-with-io'.  ':stdout' and
@@ -360,7 +365,7 @@
   (lambda (M)
     (define (do-spawn M new-source)
       (let ((pid (spawn-process-fd command M::source M::sink
-				   (if (> *verbose* 0)
+				   (if (> (*verbose*) 0)
 				       STDERR_FILENO CLOSED_FD)))
 	    (M' (M::set-source new-source)))
 	(M'::add-proc command pid)))
diff --git a/tests/openpgp/defs.scm b/tests/openpgp/defs.scm
index 8ceffc8..06bc0b8 100644
--- a/tests/openpgp/defs.scm
+++ b/tests/openpgp/defs.scm
@@ -132,3 +132,7 @@
        (list (string->number (cadr p)) (caddr p))))
    (string-split
     (call-popen `(, at GPG --with-colons , at args) input) #\newline)))
+
+(let ((verbose (string->number (getenv "verbose"))))
+  (if (number? verbose)
+      (*set-verbose!* verbose)))
diff --git a/tests/openpgp/run-tests.scm b/tests/openpgp/run-tests.scm
index a921fdb..ad94baf 100644
--- a/tests/openpgp/run-tests.scm
+++ b/tests/openpgp/run-tests.scm
@@ -72,7 +72,7 @@
 (define test
   (package
    (define (scm name . args)
-     (new name #f `(,*argv0* ,@(verbosity *verbose*) , at args
+     (new name #f `(,*argv0* ,@(verbosity (*verbose*)) , at args
 			     ,(in-srcdir name)) #f #f))
    (define (new name directory command pid retcode)
      (package

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