aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJustus Winter <[email protected]>2016-10-07 14:16:15 +0000
committerJustus Winter <[email protected]>2016-10-07 14:25:55 +0000
commit1f76f8d8bc65fad98927c977baf4d5e36dafe52b (patch)
tree71c2cb8a61d2cb26176518f967a2ed9284eaedb1
parentgpgscm: Improve test of low-level functions. (diff)
downloadgnupg-1f76f8d8bc65fad98927c977baf4d5e36dafe52b.tar.gz
gnupg-1f76f8d8bc65fad98927c977baf4d5e36dafe52b.zip
tests: Improve handling of Windows newlines.
* tests/gpgscm/lib.scm (string-split-newlines): New function. * tests/openpgp/default-key.scm: Use new function. * tests/openpgp/defs.scm: Likewise. * tests/openpgp/export.scm: Likewise. * tests/openpgp/import.scm: Likewise. Signed-off-by: Justus Winter <[email protected]>
-rw-r--r--tests/gpgscm/lib.scm9
-rwxr-xr-xtests/openpgp/default-key.scm2
-rw-r--r--tests/openpgp/defs.scm6
-rwxr-xr-xtests/openpgp/export.scm4
-rwxr-xr-xtests/openpgp/import.scm4
5 files changed, 17 insertions, 8 deletions
diff --git a/tests/gpgscm/lib.scm b/tests/gpgscm/lib.scm
index fe28262dc..e4ab48303 100644
--- a/tests/gpgscm/lib.scm
+++ b/tests/gpgscm/lib.scm
@@ -92,6 +92,15 @@
(assert (string=? "bar" (cadr (string-split "foo:bar:baz" #\:))))
(assert (string=? "baz" (caddr (string-split "foo:bar:baz" #\:))))
+;; Split haystack at newlines.
+(define (string-split-newlines haystack)
+ (if *win32*
+ (map (lambda (line) (if (string-suffix? line "\r")
+ (substring line 0 (- (string-length line) 1))
+ line))
+ (string-split haystack #\newline))
+ (string-split haystack #\newline)))
+
;; Trim the prefix of S containing only characters that make PREDICATE
;; true.
(define (string-ltrim predicate s)
diff --git a/tests/openpgp/default-key.scm b/tests/openpgp/default-key.scm
index 443365883..07cc8c0a0 100755
--- a/tests/openpgp/default-key.scm
+++ b/tests/openpgp/default-key.scm
@@ -71,6 +71,6 @@
(unless (any (lambda (line)
(and (string-prefix? line ":pubkey enc packet:")
(string-suffix? line "45117079")))
- (string-split c #\newline))
+ (string-split-newlines c))
(exit 1))))))
'("8BC90111" "3E880CFF" "F5F77B83" "45117079" "1EA97479"))
diff --git a/tests/openpgp/defs.scm b/tests/openpgp/defs.scm
index 4a968da93..e484e8633 100644
--- a/tests/openpgp/defs.scm
+++ b/tests/openpgp/defs.scm
@@ -91,7 +91,7 @@
(define (gpg-with-colons args)
(let ((s (call-popen `(,@GPG --with-colons ,@args) "")))
(map (lambda (line) (string-split line #\:))
- (string-split s #\newline))))
+ (string-split-newlines s))))
(define (get-config what)
(string-split (caddar (gpg-with-colons `(--list-config ,what))) #\;))
@@ -133,8 +133,8 @@
(lambda (line)
(let ((p (string-split line #\:)))
(list (string->number (cadr p)) (caddr p))))
- (string-split
- (call-popen `(,@GPG --with-colons ,@args) input) #\newline)))
+ (string-split-newlines
+ (call-popen `(,@GPG --with-colons ,@args) input))))
;; Dearmor a file.
(define (dearmor source-name sink-name)
diff --git a/tests/openpgp/export.scm b/tests/openpgp/export.scm
index 829170541..f7a23f4fd 100755
--- a/tests/openpgp/export.scm
+++ b/tests/openpgp/export.scm
@@ -37,13 +37,13 @@
"Signature packet not found"))
(define (check-exported-public-key packet-dump keyid)
- (let ((dump (string-split packet-dump #\newline)))
+ (let ((dump (string-split-newlines packet-dump)))
(check-for (lambda (l) (string-prefix? l ":public key packet:")) dump
"Public key packet not found")
(check-exported-key dump keyid)))
(define (check-exported-private-key packet-dump keyid)
- (let ((dump (string-split packet-dump #\newline)))
+ (let ((dump (string-split-newlines packet-dump)))
(check-for (lambda (l) (string-prefix? l ":secret key packet:")) dump
"Secret key packet not found")
(check-exported-key dump keyid)))
diff --git a/tests/openpgp/import.scm b/tests/openpgp/import.scm
index 580acea0d..98f3ad9d8 100755
--- a/tests/openpgp/import.scm
+++ b/tests/openpgp/import.scm
@@ -36,7 +36,7 @@
(unless (any (lambda (line)
(and (string-prefix? line "rvk:")
(string-contains? line ":0EE5BE979282D80B9F7540F1CCD2ED94D21739E9:")))
- (string-split c #\newline))
+ (string-split-newlines c))
(exit 1)))))
(define fpr1 "9E669861368BCA0BE42DAF7DDDA252EBB8EBE1AF")
@@ -55,6 +55,6 @@
(lambda (line)
(and (string-prefix? line "pub:")
(string-contains? line ":4096:1:DDA252EBB8EBE1AF:")))
- (string-split c #\newline))))
+ (string-split-newlines c))))
(unless (= 2 (length keys))
(error "Importing keys with long id collision failed"))))))