[Pkg-gnupg-commit] [gnupg2] 47/124: tests: Run the tests for the Python bindings of GPGME.
Daniel Kahn Gillmor
dkg at fifthhorseman.net
Wed Apr 5 15:55:31 UTC 2017
This is an automated email from the git hooks/post-receive script.
dkg pushed a commit to branch experimental
in repository gnupg2.
commit 046a15a88c83b40a753b4ad7ecc1456efa5b527f
Author: Justus Winter <justus at g10code.com>
Date: Thu Mar 9 14:33:02 2017 +0100
tests: Run the tests for the Python bindings of GPGME.
* tests/gpgme/gpgme-defs.scm (create-file): Write lines.
(create-gpgmehome): Extend function to create the right environment
for the Python tests.
* tests/gpgme/run-tests.scm: Make an environment cache for the Python
tests and enable them.
* tests/gpgme/wrap.scm: Do not hardcode the path of the Python
interpreter.
Signed-off-by: Justus Winter <justus at g10code.com>
---
tests/gpgme/gpgme-defs.scm | 34 +++++++++++++++++++++++++++++++---
tests/gpgme/run-tests.scm | 9 ++++++---
tests/gpgme/wrap.scm | 23 ++++++++++++++---------
3 files changed, 51 insertions(+), 15 deletions(-)
diff --git a/tests/gpgme/gpgme-defs.scm b/tests/gpgme/gpgme-defs.scm
index 7a7166c..12e033c 100644
--- a/tests/gpgme/gpgme-defs.scm
+++ b/tests/gpgme/gpgme-defs.scm
@@ -45,12 +45,25 @@
;; The tests expect the pinentry to return the passphrase "abc".
(setenv "PINENTRY_USER_DATA" "abc" #t)
-(define (create-file name content)
+(define (create-file name . lines)
(letfd ((fd (open name (logior O_WRONLY O_CREAT O_BINARY) #o600)))
- (display content (fdopen fd "wb"))))
+ (let ((port (fdopen fd "wb")))
+ (for-each (lambda (line) (display line port) (newline port)) lines))))
(define (create-gpgmehome . path)
- (create-file "gpg.conf" "no-force-v3-sigs\n")
+ ;; Support for various environments.
+ (define mode
+ (cond
+ ((equal? path '("lang" "python" "tests"))
+ (set! path '("tests" "gpg")) ;; Mostly uses files from tests/gpg.
+ 'python)
+ (else
+ 'gpg)))
+
+ (create-file
+ "gpg.conf"
+ "no-force-v3-sigs"
+ (string-append "agent-program " (tool 'gpg-agent) "|--debug-quick-random\n"))
(create-file
"gpg-agent.conf"
(string-append "pinentry-program " (tool 'pinentry)))
@@ -75,6 +88,21 @@
(call-check `(, at GPG --yes --import ,(apply in-gpgme-srcdir
`(, at path ,file)))))
(list "pubdemo.asc" "secdemo.asc"))
+
+ (when (equal? mode 'python)
+ (log "Importing extra keys for Python tests")
+ (for-each
+ (lambda (file)
+ (call-check `(, at GPG --yes --import
+ ,(apply in-gpgme-srcdir
+ `("lang" "python" "tests" ,file)))))
+ (list "encrypt-only.asc" "sign-only.asc"))
+
+ (log "Marking key as trusted")
+ (pipe:do
+ (pipe:echo "A0FF4590BB6122EDEF6E3C542D727CC768697734:6:\n")
+ (pipe:spawn `(,(tool 'gpg) --import-ownertrust))))
+
(stop-agent))
;; Initialize the test environment, install appropriate configuration
diff --git a/tests/gpgme/run-tests.scm b/tests/gpgme/run-tests.scm
index 4d3a7e6..72de495 100644
--- a/tests/gpgme/run-tests.scm
+++ b/tests/gpgme/run-tests.scm
@@ -40,7 +40,11 @@
run-tests-parallel
run-tests-sequential))
(setup-c (make-environment-cache
- (test::scm #f "setup.scm" (in-srcdir "setup.scm") "--" "tests" "gpg")))
+ (test::scm #f "setup.scm (tests/gpg)" (in-srcdir "setup.scm")
+ "--" "tests" "gpg")))
+ (setup-py (make-environment-cache
+ (test::scm #f "setup.scm (lang/python/tests)" (in-srcdir "setup.scm")
+ "--" "lang" "python" "tests")))
(tests (filter (lambda (arg) (not (string-prefix? arg "--"))) *args*)))
(runner
(apply
@@ -67,6 +71,5 @@
-- ,@(:path cmpnts))))
(if (null? tests) (all-tests makefile (:key cmpnts)) tests))))
`((("tests" "gpg") "c_tests" ,setup-c)
- ;; XXX: Not yet.
- ;; (("lang" "python" "tests") "py_tests")
+ (("lang" "python" "tests") "py_tests" ,setup-py)
(("lang" "qt" "tests") "TESTS" ,setup-c))))))
diff --git a/tests/gpgme/wrap.scm b/tests/gpgme/wrap.scm
index e8f2b1f..d338892 100644
--- a/tests/gpgme/wrap.scm
+++ b/tests/gpgme/wrap.scm
@@ -29,6 +29,9 @@
(setenv "top_srcdir" gpgme-srcdir #t)
(setenv "srcdir" (path-join gpgme-srcdir "tests" "gpg") #t)
+(define python (catch #f
+ (path-expand "python" (string-split (getenv "PATH") *pathsep*))))
+
(define (run what)
(if (string-suffix? (car what) ".py")
(begin
@@ -39,15 +42,17 @@
(getenv "LD_LIBRARY_PATH"))
(path-join gpgme-builddir "src/.libs"))
#t)
- (call-with-fds
- `("/usr/bin/python"
- ,(in-gpgme-srcdir "lang" "python" "tests" "run-tests.py")
- --quiet
- --interpreters=/usr/bin/python
- --builddir ,(path-join gpgme-builddir "lang" "python" "tests")
- , at what)
- STDIN_FILENO STDOUT_FILENO STDERR_FILENO))
- (if #f 77 (call-with-fds what STDIN_FILENO STDOUT_FILENO STDERR_FILENO))))
+ (if python
+ (call-with-fds
+ `(,python
+ ,(in-gpgme-srcdir "lang" "python" "tests" "run-tests.py")
+ --quiet
+ ,(string-append "--interpreters=" python)
+ --builddir ,(path-join gpgme-builddir "lang" "python" "tests")
+ , at what)
+ STDIN_FILENO STDOUT_FILENO STDERR_FILENO)
+ 77))
+ (call-with-fds what STDIN_FILENO STDOUT_FILENO STDERR_FILENO)))
(let ((name (basename (car executable))))
(cond
--
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