[Pkg-gnupg-commit] [gnupg2] 03/116: tests: Move argument parser.
Daniel Kahn Gillmor
dkg at fifthhorseman.net
Tue Jan 24 04:40:48 UTC 2017
This is an automated email from the git hooks/post-receive script.
dkg pushed a commit to branch master
in repository gnupg2.
commit a30c0a6972cabde3858108e9020e900696094843
Author: Justus Winter <justus at g10code.com>
Date: Tue Dec 20 14:01:35 2016 +0100
tests: Move argument parser.
* tests/gpgme/gpgme-defs.scm (flag): Move...
* tests/gpgscm/tests.scm: ... over here.
Signed-off-by: Justus Winter <justus at g10code.com>
---
tests/gpgme/gpgme-defs.scm | 25 -------------------------
tests/gpgscm/tests.scm | 25 +++++++++++++++++++++++++
2 files changed, 25 insertions(+), 25 deletions(-)
diff --git a/tests/gpgme/gpgme-defs.scm b/tests/gpgme/gpgme-defs.scm
index 2490666..6e35285 100644
--- a/tests/gpgme/gpgme-defs.scm
+++ b/tests/gpgme/gpgme-defs.scm
@@ -83,31 +83,6 @@
(start-agent))
(apply create-gpgme-gpghome path)))
-;; Command line flag handling. Returns the elements following KEY in
-;; ARGUMENTS up to the next argument, or #f if KEY is not in
-;; ARGUMENTS.
-(define (flag key arguments)
- (cond
- ((null? arguments)
- #f)
- ((string=? key (car arguments))
- (let loop ((acc '())
- (args (cdr arguments)))
- (if (or (null? args) (string-prefix? (car args) "--"))
- (reverse acc)
- (loop (cons (car args) acc) (cdr args)))))
- ((string=? "--" (car arguments))
- #f)
- (else
- (flag key (cdr arguments)))))
-(assert (equal? (flag "--xxx" '("--yyy")) #f))
-(assert (equal? (flag "--xxx" '("--xxx")) '()))
-(assert (equal? (flag "--xxx" '("--xxx" "yyy")) '("yyy")))
-(assert (equal? (flag "--xxx" '("--xxx" "yyy" "zzz")) '("yyy" "zzz")))
-(assert (equal? (flag "--xxx" '("--xxx" "yyy" "zzz" "--")) '("yyy" "zzz")))
-(assert (equal? (flag "--xxx" '("--xxx" "yyy" "--" "zzz")) '("yyy")))
-(assert (equal? (flag "--" '("--" "xxx" "yyy" "--" "zzz")) '("xxx" "yyy")))
-
(define (parse-makefile port key)
(define (is-continuation? tokens)
(string=? (last tokens) "\\"))
diff --git a/tests/gpgscm/tests.scm b/tests/gpgscm/tests.scm
index 7b8d489..f127a93 100644
--- a/tests/gpgscm/tests.scm
+++ b/tests/gpgscm/tests.scm
@@ -658,3 +658,28 @@
(test' (test::set-directory wd)))
(loop (pool::add (test'::run-sync '--unpack-tarball gpghome-tar))
(cdr tests')))))))
+
+;; Command line flag handling. Returns the elements following KEY in
+;; ARGUMENTS up to the next argument, or #f if KEY is not in
+;; ARGUMENTS.
+(define (flag key arguments)
+ (cond
+ ((null? arguments)
+ #f)
+ ((string=? key (car arguments))
+ (let loop ((acc '())
+ (args (cdr arguments)))
+ (if (or (null? args) (string-prefix? (car args) "--"))
+ (reverse acc)
+ (loop (cons (car args) acc) (cdr args)))))
+ ((string=? "--" (car arguments))
+ #f)
+ (else
+ (flag key (cdr arguments)))))
+(assert (equal? (flag "--xxx" '("--yyy")) #f))
+(assert (equal? (flag "--xxx" '("--xxx")) '()))
+(assert (equal? (flag "--xxx" '("--xxx" "yyy")) '("yyy")))
+(assert (equal? (flag "--xxx" '("--xxx" "yyy" "zzz")) '("yyy" "zzz")))
+(assert (equal? (flag "--xxx" '("--xxx" "yyy" "zzz" "--")) '("yyy" "zzz")))
+(assert (equal? (flag "--xxx" '("--xxx" "yyy" "--" "zzz")) '("yyy")))
+(assert (equal? (flag "--" '("--" "xxx" "yyy" "--" "zzz")) '("xxx" "yyy")))
--
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