summaryrefslogtreecommitdiff
path: root/tests/store.scm
diff options
context:
space:
mode:
authorMarius Bakke <mbakke@fastmail.com>2018-07-24 19:56:35 +0200
committerMarius Bakke <mbakke@fastmail.com>2018-07-24 19:56:35 +0200
commit706ae8e15c8d36b0aee7c19c54c143d3e17f5784 (patch)
treee9fe8ebfb1417d30979b5413165599f066a1c504 /tests/store.scm
parent3e95125e9bd0676d4a9add9105217ad3eaef3ff0 (diff)
parent8440db459a10daa24282038f35bc0b6771bd51ab (diff)
downloadpatches-706ae8e15c8d36b0aee7c19c54c143d3e17f5784.tar
patches-706ae8e15c8d36b0aee7c19c54c143d3e17f5784.tar.gz
Merge branch 'master' into core-updates
Diffstat (limited to 'tests/store.scm')
-rw-r--r--tests/store.scm46
1 files changed, 46 insertions, 0 deletions
diff --git a/tests/store.scm b/tests/store.scm
index afecec940a..47fab0df18 100644
--- a/tests/store.scm
+++ b/tests/store.scm
@@ -210,6 +210,52 @@
(valid-path? store path)
(file-exists? path)))))
+(test-equal "add-file-tree-to-store"
+ `(42
+ ("." directory #t)
+ ("./bar" directory #t)
+ ("./foo" directory #t)
+ ("./foo/a" regular "file a")
+ ("./foo/b" symlink "a")
+ ("./foo/c" directory #t)
+ ("./foo/c/p" regular "file p")
+ ("./foo/c/q" directory #t)
+ ("./foo/c/q/x" regular "#!/bin/sh\nexit 42")
+ ("./foo/c/q/y" symlink "..")
+ ("./foo/c/q/z" directory #t))
+ (let* ((tree `("file-tree" directory
+ ("foo" directory
+ ("a" regular (data "file a"))
+ ("b" symlink "a")
+ ("c" directory
+ ("p" regular (data ,(string->utf8 "file p")))
+ ("q" directory
+ ("x" executable
+ (data "#!/bin/sh\nexit 42"))
+ ("y" symlink "..")
+ ("z" directory))))
+ ("bar" directory)))
+ (result (add-file-tree-to-store %store tree)))
+ (cons (status:exit-val (system* (string-append result "/foo/c/q/x")))
+ (with-directory-excursion result
+ (map (lambda (file)
+ (let ((type (stat:type (lstat file))))
+ `(,file ,type
+ ,(match type
+ ((or 'regular 'executable)
+ (call-with-input-file file
+ get-string-all))
+ ('symlink (readlink file))
+ ('directory #t)))))
+ (find-files "." #:directories? #t))))))
+
+(test-equal "add-file-tree-to-store, flat"
+ "Hello, world!"
+ (let* ((tree `("flat-file" regular (data "Hello, world!")))
+ (result (add-file-tree-to-store %store tree)))
+ (and (file-exists? result)
+ (call-with-input-file result get-string-all))))
+
(test-assert "references"
(let* ((t1 (add-text-to-store %store "random1"
(random-text)))