aboutsummaryrefslogtreecommitdiff
path: root/tests/union.scm
diff options
context:
space:
mode:
authorLudovic Courtès <ludo@gnu.org>2018-04-28 17:17:33 +0200
committerLudovic Courtès <ludo@gnu.org>2018-05-10 14:53:56 +0200
commitdac1c97d131d297134fa878ac240d9ec0127044b (patch)
treefd64fc397e73001b8e6ae6e3513602feaaad65fe /tests/union.scm
parent8584965b7949cdd7a4cd702b5422474b088beb36 (diff)
downloadpatches-dac1c97d131d297134fa878ac240d9ec0127044b.tar
patches-dac1c97d131d297134fa878ac240d9ec0127044b.tar.gz
union: Add 'relative-file-name'.
* guix/build/union.scm (%not-slash): New variable. (relative-file-name): New procedure. * tests/union.scm (test-relative-file-name): New macro and tests.
Diffstat (limited to 'tests/union.scm')
-rw-r--r--tests/union.scm18
1 files changed, 18 insertions, 0 deletions
diff --git a/tests/union.scm b/tests/union.scm
index aa95cae001..5a6a4033fc 100644
--- a/tests/union.scm
+++ b/tests/union.scm
@@ -184,4 +184,22 @@
(file-is-directory? "bin")
(eq? 'symlink (stat:type (lstat "bin/guile"))))))))
+(letrec-syntax ((test-relative-file-name
+ (syntax-rules (=>)
+ ((_ (reference file => expected) rest ...)
+ (begin
+ (test-equal (string-append "relative-file-name "
+ reference " " file)
+ expected
+ (relative-file-name reference file))
+ (test-relative-file-name rest ...)))
+ ((_)
+ #t))))
+ (test-relative-file-name
+ ("/a/b" "/a/c/d" => "../c/d")
+ ("/a/b" "/a/b" => "")
+ ("/a/b" "/a" => "..")
+ ("/a/b" "/a/b/c/d" => "c/d")
+ ("/a/b/c" "/a/d/e/f" => "../../d/e/f")))
+
(test-end)