[Pkg-gnupg-commit] [gnupg2] 201/292: gpgscm, tests: Add new functions to the test environment.

Daniel Kahn Gillmor dkg at fifthhorseman.net
Mon Nov 21 06:31:42 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 1ec07cbc209f247fd85704f5701564e31aa56d0b
Author: Justus Winter <justus at g10code.com>
Date:   Thu Nov 3 14:37:15 2016 +0100

    gpgscm,tests: Add new functions to the test environment.
    
    * tests/gpgscm/lib.scm (first, last, powerset): New functions.
    * tests/gpgscm/tests.scm (interactive-shell): New function.
    * tests/openpgp/Makefile.am (EXTRA_DIST): Add new file.
    * tests/openpgp/README: Document 'interactive-shell'.
    * tests/openpgp/shell.scm: New file.
    
    Signed-off-by: Justus Winter <justus at g10code.com>
---
 tests/gpgscm/lib.scm      | 18 ++++++++++++++++++
 tests/gpgscm/tests.scm    |  8 ++++++++
 tests/openpgp/Makefile.am |  2 +-
 tests/openpgp/README      |  5 ++++-
 tests/openpgp/shell.scm   | 32 ++++++++++++++++++++++++++++++++
 5 files changed, 63 insertions(+), 2 deletions(-)

diff --git a/tests/gpgscm/lib.scm b/tests/gpgscm/lib.scm
index e4ab483..316eacf 100644
--- a/tests/gpgscm/lib.scm
+++ b/tests/gpgscm/lib.scm
@@ -42,6 +42,24 @@
         ((not (p (car l))) #f)
         (else (all p (cdr l)))))
 
+;; Return the first element of a list.
+(define first car)
+
+;; Return the last element of a list.
+(define (last lst)
+  (if (null? (cdr lst))
+      (car lst)
+      (last (cdr lst))))
+
+;; Compute the powerset of a list.
+(define (powerset set)
+  (if (null? set)
+      '(())
+      (let ((rst (powerset (cdr set))))
+        (append (map (lambda (x) (cons (car set) x))
+                     rst)
+                rst))))
+
 ;; Is PREFIX a prefix of S?
 (define (string-prefix? s prefix)
   (and (>= (string-length s) (string-length prefix))
diff --git a/tests/gpgscm/tests.scm b/tests/gpgscm/tests.scm
index 8986a70..d89a96f 100644
--- a/tests/gpgscm/tests.scm
+++ b/tests/gpgscm/tests.scm
@@ -481,3 +481,11 @@
     (catch (list tmpfiles source *error*)
 	   (apply function `(,(call-with-input-file source read-all) , at args)))
     (list tmpfiles source #f)))
+
+;;
+;; Developing and debugging tests.
+;;
+
+;; Spawn an os shell.
+(define (interactive-shell)
+  (call-with-fds `(,(getenv "SHELL")) 0 1 2))
diff --git a/tests/openpgp/Makefile.am b/tests/openpgp/Makefile.am
index bb9b2f4..5725e11 100644
--- a/tests/openpgp/Makefile.am
+++ b/tests/openpgp/Makefile.am
@@ -188,7 +188,7 @@ sample_msgs = samplemsgs/issue2419.asc
 EXTRA_DIST = defs.scm $(XTESTS) $(TEST_FILES) \
 	     mkdemodirs signdemokey $(priv_keys) $(sample_keys)   \
 	     $(sample_msgs) ChangeLog-2011 run-tests.scm \
-	     setup.scm finish.scm
+	     setup.scm finish.scm shell.scm
 
 CLEANFILES = prepared.stamp x y yy z out err  $(data_files) \
 	     plain-1 plain-2 plain-3 trustdb.gpg *.lock .\#lk* \
diff --git a/tests/openpgp/README b/tests/openpgp/README
index 8845afd..75d818e 100644
--- a/tests/openpgp/README
+++ b/tests/openpgp/README
@@ -110,7 +110,10 @@ You can also get an interactive repl by dropping
 
   (interactive-repl (current-environment))
 
-anywhere you like.
+anywhere you like.  Or, if you want to examine the environment from an
+operating system shell, use
+
+  (interactive-shell)
 
 ** Interfacing with gpg
 
diff --git a/tests/openpgp/shell.scm b/tests/openpgp/shell.scm
new file mode 100644
index 0000000..dadafff
--- /dev/null
+++ b/tests/openpgp/shell.scm
@@ -0,0 +1,32 @@
+#!/usr/bin/env gpgscm
+
+;; Copyright (C) 2016 g10 Code GmbH
+;;
+;; This file is part of GnuPG.
+;;
+;; GnuPG is free software; you can redistribute it and/or modify
+;; it under the terms of the GNU General Public License as published by
+;; the Free Software Foundation; either version 3 of the License, or
+;; (at your option) any later version.
+;;
+;; GnuPG is distributed in the hope that it will be useful,
+;; but WITHOUT ANY WARRANTY; without even the implied warranty of
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+;; GNU General Public License for more details.
+;;
+;; You should have received a copy of the GNU General Public License
+;; along with this program; if not, see <http://www.gnu.org/licenses/>.
+
+(load (with-path "defs.scm"))
+
+;; This is not a test, but can be used to inspect the test
+;; environment.  Simply execute
+;;
+;;   make -Ctests/openpgp check XTESTS=shell.scm
+;;
+;; to run it.
+
+(echo "Note that gpg.conf includes 'batch'.  If you want to use gpg")
+(echo "interactively you should drop that.")
+(echo)
+(interactive-shell)

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