diff options
| author | Ludovic Courtès <ludo@gnu.org> | 2012-12-13 00:23:20 +0100 |
|---|---|---|
| committer | Ludovic Courtès <ludo@gnu.org> | 2012-12-13 00:23:20 +0100 |
| commit | fdb50f8d8aba87e48c00a9633ed3e43b13792c3e (patch) | |
| tree | 439451f736175c0e99b44ffd15b99c5a5f364e97 | |
| parent | a9128eac414e56882a12571e4856873a19ff6ec3 (diff) | |
tests: base32: Work around `system*' bug.
* tests/base32.scm (%nix-hash): When `getenv' returns the empty string,
ignore it.
(%have-nix-hash?): New variable. Update `test-skip' clause to use it.
| -rw-r--r-- | tests/base32.scm | 18 |
1 files changed, 13 insertions, 5 deletions
diff --git a/tests/base32.scm b/tests/base32.scm index b8b9ebb0dda..d1bbaa1764f 100644 --- a/tests/base32.scm +++ b/tests/base32.scm | |||
| @@ -23,15 +23,24 @@ | |||
| 23 | #:use-module (srfi srfi-64) | 23 | #:use-module (srfi srfi-64) |
| 24 | #:use-module (ice-9 rdelim) | 24 | #:use-module (ice-9 rdelim) |
| 25 | #:use-module (ice-9 popen) | 25 | #:use-module (ice-9 popen) |
| 26 | #:use-module (ice-9 match) | ||
| 26 | #:use-module (rnrs bytevectors) | 27 | #:use-module (rnrs bytevectors) |
| 27 | #:use-module (rnrs io ports)) | 28 | #:use-module (rnrs io ports)) |
| 28 | 29 | ||
| 29 | ;; Test the (guix base32) module. | 30 | ;; Test the (guix base32) module. |
| 30 | 31 | ||
| 31 | (define %nix-hash | 32 | (define %nix-hash |
| 32 | (or (getenv "NIX_HASH") | 33 | (or (and=> (getenv "NIX_HASH") |
| 34 | (match-lambda | ||
| 35 | ("" #f) | ||
| 36 | (val val))) | ||
| 33 | "nix-hash")) | 37 | "nix-hash")) |
| 34 | 38 | ||
| 39 | (define %have-nix-hash? | ||
| 40 | ;; Note: Use `system', not `system*', because of <http://bugs.gnu.org/13166>. | ||
| 41 | (false-if-exception | ||
| 42 | (zero? (system (string-append %nix-hash " --version"))))) | ||
| 43 | |||
| 35 | (test-begin "base32") | 44 | (test-begin "base32") |
| 36 | 45 | ||
| 37 | (test-assert "bytevector->base32-string" | 46 | (test-assert "bytevector->base32-string" |
| @@ -67,10 +76,9 @@ | |||
| 67 | ;; Examples from RFC 4648. | 76 | ;; Examples from RFC 4648. |
| 68 | (map string->utf8 '("" "f" "fo" "foo" "foob" "fooba" "foobar")))) | 77 | (map string->utf8 '("" "f" "fo" "foo" "foob" "fooba" "foobar")))) |
| 69 | 78 | ||
| 70 | ;; The following tests requires `nix-hash' in $PATH. | 79 | ;; The following test requires `nix-hash' in $PATH. |
| 71 | (test-skip (if (false-if-exception (system* %nix-hash "--version")) | 80 | (unless %have-nix-hash? |
| 72 | 0 | 81 | (test-skip 1)) |
| 73 | 1)) | ||
| 74 | 82 | ||
| 75 | (test-assert "sha256 & bytevector->nix-base32-string" | 83 | (test-assert "sha256 & bytevector->nix-base32-string" |
| 76 | (let ((file (search-path %load-path "tests/test.drv"))) | 84 | (let ((file (search-path %load-path "tests/test.drv"))) |
