aboutsummaryrefslogtreecommitdiffstats
path: root/tests/gpgscm/tests.scm
diff options
context:
space:
mode:
authorJustus Winter <[email protected]>2016-11-16 11:02:03 +0000
committerJustus Winter <[email protected]>2016-12-13 14:05:26 +0000
commite3876f16eb237bdeb9f79aca2e7db5e9e2d86686 (patch)
tree4f6137cd658ae11d2a2eb2870363cdaa043b4df9 /tests/gpgscm/tests.scm
parentpo: Update Japanese translation. (diff)
downloadgnupg-e3876f16eb237bdeb9f79aca2e7db5e9e2d86686.tar.gz
gnupg-e3876f16eb237bdeb9f79aca2e7db5e9e2d86686.zip
gpgscm: Improve library functions.
* tests/gpgscm/tests.scm (absolute-path?): New function. (canonical-path): Use the new function. * tests/gpgscm/lib.scm (string-split-pln): New function. (string-indexp, string-splitp): Likewise. (string-splitn): Express using the above function. (string-ltrim, string-rtrim): Fix corner case. (list->string-reversed): New function. (read-line): Fix performance. Signed-off-by: Justus Winter <[email protected]>
Diffstat (limited to '')
-rw-r--r--tests/gpgscm/tests.scm21
1 files changed, 12 insertions, 9 deletions
diff --git a/tests/gpgscm/tests.scm b/tests/gpgscm/tests.scm
index bec19223d..d360272fd 100644
--- a/tests/gpgscm/tests.scm
+++ b/tests/gpgscm/tests.scm
@@ -186,16 +186,19 @@
(assert (string=? (path-join "foo" "bar" "baz") "foo/bar/baz"))
(assert (string=? (path-join "" "bar" "baz") "bar/baz"))
+;; Is PATH an absolute path?
+(define (absolute-path? path)
+ (or (char=? #\/ (string-ref path 0))
+ (and *win32* (char=? #\\ (string-ref path 0)))
+ (and *win32*
+ (char-alphabetic? (string-ref path 0))
+ (char=? #\: (string-ref path 1))
+ (or (char=? #\/ (string-ref path 2))
+ (char=? #\\ (string-ref path 2))))))
+
+;; Make PATH absolute.
(define (canonical-path path)
- (if (or (char=? #\/ (string-ref path 0))
- (and *win32* (char=? #\\ (string-ref path 0)))
- (and *win32*
- (char-alphabetic? (string-ref path 0))
- (char=? #\: (string-ref path 1))
- (or (char=? #\/ (string-ref path 2))
- (char=? #\\ (string-ref path 2)))))
- path
- (path-join (getcwd) path)))
+ (if (absolute-path? path) path (path-join (getcwd) path)))
(define (in-srcdir . names)
(canonical-path (apply path-join (cons (getenv "srcdir") names))))