summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorJustus Winter <justus@g10code.com>2016-12-20 14:01:35 +0100
committerJustus Winter <justus@g10code.com>2016-12-20 16:25:35 +0100
commita30c0a6972cabde3858108e9020e900696094843 (patch)
tree91db4ab795e322229a7e6a56604e4f284c17ebc1 /tests
parenttests: Add missing encrypted sample, cleanup samples handling. (diff)
downloadgnupg2-a30c0a6972cabde3858108e9020e900696094843.tar.xz
gnupg2-a30c0a6972cabde3858108e9020e900696094843.zip
tests: Move argument parser.
* tests/gpgme/gpgme-defs.scm (flag): Move... * tests/gpgscm/tests.scm: ... over here. Signed-off-by: Justus Winter <justus@g10code.com>
Diffstat (limited to 'tests')
-rw-r--r--tests/gpgme/gpgme-defs.scm25
-rw-r--r--tests/gpgscm/tests.scm25
2 files changed, 25 insertions, 25 deletions
diff --git a/tests/gpgme/gpgme-defs.scm b/tests/gpgme/gpgme-defs.scm
index 24906665f..6e3528586 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 7b8d48943..f127a93b2 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")))