aboutsummaryrefslogtreecommitdiff
path: root/tests/nar.scm
diff options
context:
space:
mode:
authorLudovic Courtès <ludo@gnu.org>2014-02-22 00:27:57 +0100
committerLudovic Courtès <ludo@gnu.org>2014-02-22 00:27:57 +0100
commitb2bfa32d253337a48f3bc0260982cbb945b345a3 (patch)
treea75ae018b5c7608414bf50bd6e55683eb0c44f7a /tests/nar.scm
parent99662b8dbf420d0112f83b7daddcecfb1bcb9bad (diff)
parent2096ef47aad57a9988c8fdfaa46a70770a0e0b12 (diff)
downloadguix-b2bfa32d253337a48f3bc0260982cbb945b345a3.tar.gz
guix-b2bfa32d253337a48f3bc0260982cbb945b345a3.zip
Merge branch 'master' into core-updates
Conflicts: gnu-system.am
Diffstat (limited to 'tests/nar.scm')
-rw-r--r--tests/nar.scm34
1 files changed, 33 insertions, 1 deletions
diff --git a/tests/nar.scm b/tests/nar.scm
index 9f21f990c8..16a7845342 100644
--- a/tests/nar.scm
+++ b/tests/nar.scm
@@ -19,10 +19,14 @@
(define-module (test-nar)
#:use-module (guix nar)
#:use-module (guix store)
- #:use-module ((guix hash) #:select (open-sha256-input-port))
+ #:use-module ((guix hash)
+ #:select (open-sha256-port open-sha256-input-port))
+ #:use-module ((guix packages)
+ #:select (base32))
#:use-module (rnrs bytevectors)
#:use-module (rnrs io ports)
#:use-module (srfi srfi-1)
+ #:use-module (srfi srfi-11)
#:use-module (srfi srfi-26)
#:use-module (srfi srfi-34)
#:use-module (srfi srfi-35)
@@ -183,6 +187,34 @@
(test-begin "nar")
+(test-assert "write-file supports non-file output ports"
+ (let ((input (string-append (dirname (search-path %load-path "guix.scm"))
+ "/guix"))
+ (output (%make-void-port "w")))
+ (write-file input output)
+ #t))
+
+(test-equal "write-file puts file in C locale collation order"
+ (base32 "0sfn5r63k88w9ls4hivnvscg82bqg8a0w7955l6xlk4g96jnb2z3")
+ (let ((input (string-append %test-dir ".input")))
+ (dynamic-wind
+ (lambda ()
+ (define (touch file)
+ (call-with-output-file (string-append input "/" file)
+ (const #t)))
+
+ (mkdir input)
+ (touch "B")
+ (touch "Z")
+ (touch "a")
+ (symlink "B" (string-append input "/z")))
+ (lambda ()
+ (let-values (((port get-hash) (open-sha256-port)))
+ (write-file input port)
+ (get-hash)))
+ (lambda ()
+ (rm-rf input)))))
+
(test-assert "write-file + restore-file"
(let* ((input (string-append (dirname (search-path %load-path "guix.scm"))
"/guix"))