[Pkg-gnupg-commit] [gnupg2] 102/292: tests: Improve handling of Windows newlines.

Daniel Kahn Gillmor dkg at fifthhorseman.net
Mon Nov 21 06:31:30 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 1f76f8d8bc65fad98927c977baf4d5e36dafe52b
Author: Justus Winter <justus at g10code.com>
Date:   Fri Oct 7 16:16:15 2016 +0200

    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 <justus at g10code.com>
---
 tests/gpgscm/lib.scm          | 9 +++++++++
 tests/openpgp/default-key.scm | 2 +-
 tests/openpgp/defs.scm        | 6 +++---
 tests/openpgp/export.scm      | 4 ++--
 tests/openpgp/import.scm      | 4 ++--
 5 files changed, 17 insertions(+), 8 deletions(-)

diff --git a/tests/gpgscm/lib.scm b/tests/gpgscm/lib.scm
index fe28262..e4ab483 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 4433658..07cc8c0 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 4a968da..e484e86 100644
--- a/tests/openpgp/defs.scm
+++ b/tests/openpgp/defs.scm
@@ -91,7 +91,7 @@
 (define (gpg-with-colons args)
   (let ((s (call-popen `(, at GPG --with-colons , at 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 `(, at GPG --with-colons , at args) input) #\newline)))
+   (string-split-newlines
+    (call-popen `(, at GPG --with-colons , at args) input))))
 
 ;; Dearmor a file.
 (define (dearmor source-name sink-name)
diff --git a/tests/openpgp/export.scm b/tests/openpgp/export.scm
index 8291705..f7a23f4 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 580acea..98f3ad9 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"))))))

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