diff options
author | Ludovic Courtès <ludo@gnu.org> | 2012-06-01 23:29:55 +0200 |
---|---|---|
committer | Ludovic Courtès <ludo@gnu.org> | 2012-06-03 22:39:26 +0200 |
commit | f9c7080aa3acafc6fb15fa1b304670acfe114704 (patch) | |
tree | 829e4d03cfdf500b722e5feb8a273847a1ebffe1 /tests | |
parent | d0a92b7531274a71352c3620a77cbe81b18b7232 (diff) | |
download | guix-f9c7080aa3acafc6fb15fa1b304670acfe114704.tar guix-f9c7080aa3acafc6fb15fa1b304670acfe114704.tar.gz |
Fix `bytevector->nix-base32-string'.
* guix/utils.scm (bytevector-quintet-ref-right,
bytevector-quintet-fold): New procedures.
(bytevector-quintet-fold-right): Add `quintet-fold' parameter; use it
instead of `bytevector-quintet-fold'.
(bytevector->base32-string): Pass BYTEVECTOR-QUINTET-FOLD as the
first parameter.
(bytevector->nix-base32-string): Pass BYTEVECTOR-QUINTET-FOLD-RIGHT as
the first parameter.
* tests/utils.scm ("sha256 & bytevector->nix-base32-string"): New test.
Diffstat (limited to 'tests')
-rw-r--r-- | tests/utils.scm | 21 |
1 files changed, 20 insertions, 1 deletions
diff --git a/tests/utils.scm b/tests/utils.scm index 57705e6f48..eade84b5d4 100644 --- a/tests/utils.scm +++ b/tests/utils.scm @@ -22,7 +22,10 @@ #:use-module (srfi srfi-1) #:use-module (srfi srfi-26) #:use-module (srfi srfi-64) - #:use-module (rnrs bytevectors)) + #:use-module (rnrs bytevectors) + #:use-module (rnrs io ports) + #:use-module (ice-9 rdelim) + #:use-module (ice-9 popen)) (test-begin "utils") @@ -43,6 +46,22 @@ "mzxw6ytb" "mzxw6ytboi"))) +;; The following tests requires `nix-hash' in $PATH. +(test-skip (if (false-if-exception (system* "nix-hash" "--version")) + 0 + 1)) + +(test-assert "sha256 & bytevector->nix-base32-string" + (let ((file (search-path %load-path "tests/test.drv"))) + (equal? (bytevector->nix-base32-string + (sha256 (call-with-input-file file get-bytevector-all))) + (let* ((c (format #f "nix-hash --type sha256 --base32 --flat \"~a\"" + file)) + (p (open-input-pipe c)) + (l (read-line p))) + (close-pipe p) + l)))) + (test-end) |