mirror of
git://git.gnupg.org/gnupg.git
synced 2024-12-22 10:19:57 +01:00
tests,w32: Fix locating the components.
* tests/openpgp/defs.scm (percent-decode): New function. (bin-prefix): New variable. (installed?): Likewise. (tool-hardcoded): Use the new variables. (gpg-conf): Use the new function to decode the values. (gpg-components): Do not use '--build-prefix' when 'installed?'. Signed-off-by: Justus Winter <justus@g10code.com>
This commit is contained in:
parent
293a55bacd
commit
28e149609d
@ -81,6 +81,21 @@
|
|||||||
default
|
default
|
||||||
value)))
|
value)))
|
||||||
|
|
||||||
|
(define (percent-decode s)
|
||||||
|
(define (decode c)
|
||||||
|
(if (and (> (length c) 2) (char=? #\% (car c)))
|
||||||
|
(integer->char (string->number (string #\# #\x (cadr c) (caddr c))))
|
||||||
|
#f))
|
||||||
|
(let loop ((i 0) (c (string->list s)) (r (make-string (string-length s))))
|
||||||
|
(if (null? c)
|
||||||
|
(substring r 0 i)
|
||||||
|
(let ((decoded (decode c)))
|
||||||
|
(string-set! r i (if decoded decoded (car c)))
|
||||||
|
(loop (+ 1 i) (if decoded (cdddr c) (cdr c)) r)))))
|
||||||
|
(assert (equal? (percent-decode "") ""))
|
||||||
|
(assert (equal? (percent-decode "%61") "a"))
|
||||||
|
(assert (equal? (percent-decode "foob%61r") "foobar"))
|
||||||
|
|
||||||
(define tools
|
(define tools
|
||||||
'((gpgv "GPGV" "g10/gpgv")
|
'((gpgv "GPGV" "g10/gpgv")
|
||||||
(gpg-connect-agent "GPG_CONNECT_AGENT" "tools/gpg-connect-agent")
|
(gpg-connect-agent "GPG_CONNECT_AGENT" "tools/gpg-connect-agent")
|
||||||
@ -91,25 +106,30 @@
|
|||||||
(gpg-zip "GPGZIP" "tools/gpg-zip")
|
(gpg-zip "GPGZIP" "tools/gpg-zip")
|
||||||
(pinentry "PINENTRY" "tests/openpgp/fake-pinentry")))
|
(pinentry "PINENTRY" "tests/openpgp/fake-pinentry")))
|
||||||
|
|
||||||
|
(define bin-prefix (getenv "BIN_PREFIX"))
|
||||||
|
(define installed? (not (string=? "" bin-prefix)))
|
||||||
|
|
||||||
(define (tool-hardcoded which)
|
(define (tool-hardcoded which)
|
||||||
(let ((t (assoc which tools))
|
(let ((t (assoc which tools)))
|
||||||
(prefix (getenv "BIN_PREFIX")))
|
|
||||||
(getenv' (cadr t)
|
(getenv' (cadr t)
|
||||||
(qualify (if (string=? prefix "")
|
(qualify (if installed?
|
||||||
(string-append (getenv "objdir") "/" (caddr t))
|
(string-append bin-prefix "/" (basename (caddr t)))
|
||||||
(string-append prefix "/" (basename (caddr t))))))))
|
(string-append (getenv "objdir") "/" (caddr t)))))))
|
||||||
|
|
||||||
(define (gpg-conf . args)
|
(define (gpg-conf . args)
|
||||||
(let ((s (call-popen `(,(tool-hardcoded 'gpgconf) ,@args) "")))
|
(let ((s (call-popen `(,(tool-hardcoded 'gpgconf) ,@args) "")))
|
||||||
(map (lambda (line) (string-split line #\:))
|
(map (lambda (line) (map percent-decode (string-split line #\:)))
|
||||||
(string-split-newlines s))))
|
(string-split-newlines s))))
|
||||||
(define :gc:c:name car)
|
(define :gc:c:name car)
|
||||||
(define :gc:c:description cadr)
|
(define :gc:c:description cadr)
|
||||||
(define :gc:c:pgmname caddr)
|
(define :gc:c:pgmname caddr)
|
||||||
|
|
||||||
(setenv "GNUPG_BUILDDIR" (getenv "objdir") #t)
|
(unless installed?
|
||||||
(define gpg-components (gpg-conf '--build-prefix (getenv "objdir")
|
(setenv "GNUPG_BUILDDIR" (getenv "objdir") #t))
|
||||||
'--list-components))
|
(define gpg-components (apply gpg-conf
|
||||||
|
`(,@(if installed? '()
|
||||||
|
(list '--build-prefix (getenv "objdir")))
|
||||||
|
--list-components)))
|
||||||
|
|
||||||
(define (tool which)
|
(define (tool which)
|
||||||
(case which
|
(case which
|
||||||
|
Loading…
x
Reference in New Issue
Block a user