summaryrefslogtreecommitdiff
path: root/tests/nar.scm
diff options
context:
space:
mode:
authorLudovic Courtès <ludo@gnu.org>2016-06-12 23:22:54 +0200
committerLudovic Courtès <ludo@gnu.org>2016-06-12 23:55:22 +0200
commitfe585be9aa8f5158a7dfb6477d19ece3d643dec3 (patch)
tree855b01af0646dee9186ae539fd9f561e47777649 /tests/nar.scm
parent31d968fbcfa78b52c5280503417b67943f8a9660 (diff)
serialization: Add #:select? parameter to 'write-file'.
* guix/serialization.scm (write-file): Add #:select? parameter and honor it. * tests/nar.scm ("write-file #:select? + restore-file"): New test.
Diffstat (limited to 'tests/nar.scm')
-rw-r--r--tests/nar.scm42
1 files changed, 41 insertions, 1 deletions
diff --git a/tests/nar.scm b/tests/nar.scm
index 9796980e350..4f4b304b1dd 100644
--- a/tests/nar.scm
+++ b/tests/nar.scm
@@ -1,5 +1,5 @@
1;;; GNU Guix --- Functional package management for GNU 1;;; GNU Guix --- Functional package management for GNU
2;;; Copyright © 2012, 2013, 2014, 2015 Ludovic Courtès <ludo@gnu.org> 2;;; Copyright © 2012, 2013, 2014, 2015, 2016 Ludovic Courtès <ludo@gnu.org>
3;;; 3;;;
4;;; This file is part of GNU Guix. 4;;; This file is part of GNU Guix.
5;;; 5;;;
@@ -241,6 +241,46 @@
241 (lambda () 241 (lambda ()
242 (rmdir input))))) 242 (rmdir input)))))
243 243
244(test-assert "write-file #:select? + restore-file"
245 (let ((input (string-append %test-dir ".input")))
246 (mkdir input)
247 (dynamic-wind
248 (const #t)
249 (lambda ()
250 (with-file-tree input
251 (directory "root"
252 ((directory "a" (("x") ("y") ("z")))
253 ("b") ("c") ("d" -> "b")))
254 (let* ((output %test-dir)
255 (nar (string-append output ".nar")))
256 (dynamic-wind
257 (lambda () #t)
258 (lambda ()
259 (call-with-output-file nar
260 (lambda (port)
261 (write-file input port
262 #:select?
263 (lambda (file stat)
264 (and (not (string=? (basename file)
265 "a"))
266 (not (eq? (stat:type stat)
267 'symlink)))))))
268 (call-with-input-file nar
269 (cut restore-file <> output))
270
271 ;; Make sure "a" and "d" have been filtered out.
272 (and (not (file-exists? (string-append output "/root/a")))
273 (file=? (string-append output "/root/b")
274 (string-append input "/root/b"))
275 (file=? (string-append output "/root/c")
276 (string-append input "/root/c"))
277 (not (file-exists? (string-append output "/root/d")))))
278 (lambda ()
279 (false-if-exception (delete-file nar))
280 (false-if-exception (rm-rf output)))))))
281 (lambda ()
282 (rmdir input)))))
283
244;; 'restore-file-set' depends on 'open-sha256-input-port', which in turn 284;; 'restore-file-set' depends on 'open-sha256-input-port', which in turn
245;; relies on a Guile 2.0.10+ feature. 285;; relies on a Guile 2.0.10+ feature.
246(test-skip (if (false-if-exception 286(test-skip (if (false-if-exception