diff options
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/store.scm | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/tests/store.scm b/tests/store.scm index afecec940ad..47fab0df18a 100644 --- a/tests/store.scm +++ b/tests/store.scm | |||
| @@ -210,6 +210,52 @@ | |||
| 210 | (valid-path? store path) | 210 | (valid-path? store path) |
| 211 | (file-exists? path))))) | 211 | (file-exists? path))))) |
| 212 | 212 | ||
| 213 | (test-equal "add-file-tree-to-store" | ||
| 214 | `(42 | ||
| 215 | ("." directory #t) | ||
| 216 | ("./bar" directory #t) | ||
| 217 | ("./foo" directory #t) | ||
| 218 | ("./foo/a" regular "file a") | ||
| 219 | ("./foo/b" symlink "a") | ||
| 220 | ("./foo/c" directory #t) | ||
| 221 | ("./foo/c/p" regular "file p") | ||
| 222 | ("./foo/c/q" directory #t) | ||
| 223 | ("./foo/c/q/x" regular "#!/bin/sh\nexit 42") | ||
| 224 | ("./foo/c/q/y" symlink "..") | ||
| 225 | ("./foo/c/q/z" directory #t)) | ||
| 226 | (let* ((tree `("file-tree" directory | ||
| 227 | ("foo" directory | ||
| 228 | ("a" regular (data "file a")) | ||
| 229 | ("b" symlink "a") | ||
| 230 | ("c" directory | ||
| 231 | ("p" regular (data ,(string->utf8 "file p"))) | ||
| 232 | ("q" directory | ||
| 233 | ("x" executable | ||
| 234 | (data "#!/bin/sh\nexit 42")) | ||
| 235 | ("y" symlink "..") | ||
| 236 | ("z" directory)))) | ||
| 237 | ("bar" directory))) | ||
| 238 | (result (add-file-tree-to-store %store tree))) | ||
| 239 | (cons (status:exit-val (system* (string-append result "/foo/c/q/x"))) | ||
| 240 | (with-directory-excursion result | ||
| 241 | (map (lambda (file) | ||
| 242 | (let ((type (stat:type (lstat file)))) | ||
| 243 | `(,file ,type | ||
| 244 | ,(match type | ||
| 245 | ((or 'regular 'executable) | ||
| 246 | (call-with-input-file file | ||
| 247 | get-string-all)) | ||
| 248 | ('symlink (readlink file)) | ||
| 249 | ('directory #t))))) | ||
| 250 | (find-files "." #:directories? #t)))))) | ||
| 251 | |||
| 252 | (test-equal "add-file-tree-to-store, flat" | ||
| 253 | "Hello, world!" | ||
| 254 | (let* ((tree `("flat-file" regular (data "Hello, world!"))) | ||
| 255 | (result (add-file-tree-to-store %store tree))) | ||
| 256 | (and (file-exists? result) | ||
| 257 | (call-with-input-file result get-string-all)))) | ||
| 258 | |||
| 213 | (test-assert "references" | 259 | (test-assert "references" |
| 214 | (let* ((t1 (add-text-to-store %store "random1" | 260 | (let* ((t1 (add-text-to-store %store "random1" |
| 215 | (random-text))) | 261 | (random-text))) |
