tests: base32: Work around `system*' bug.
authorLudovic Courtès <ludo@gnu.org>
Wed, 12 Dec 2012 23:23:20 +0000 (00:23 +0100)
committerLudovic Courtès <ludo@gnu.org>
Wed, 12 Dec 2012 23:23:20 +0000 (00:23 +0100)
* 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.

tests/base32.scm

index b8b9ebb..d1bbaa1 100644 (file)
   #:use-module (srfi srfi-64)
   #:use-module (ice-9 rdelim)
   #:use-module (ice-9 popen)
+  #:use-module (ice-9 match)
   #:use-module (rnrs bytevectors)
   #:use-module (rnrs io ports))
 
 ;; Test the (guix base32) module.
 
 (define %nix-hash
-  (or (getenv "NIX_HASH")
+  (or (and=> (getenv "NIX_HASH")
+             (match-lambda
+              ("" #f)
+              (val val)))
       "nix-hash"))
 
+(define %have-nix-hash?
+  ;; Note: Use `system', not `system*', because of <http://bugs.gnu.org/13166>.
+  (false-if-exception
+   (zero? (system (string-append %nix-hash " --version")))))
+
 (test-begin "base32")
 
 (test-assert "bytevector->base32-string"
          ;; Examples from RFC 4648.
          (map string->utf8 '("" "f" "fo" "foo" "foob" "fooba" "foobar"))))
 
-;; The following tests requires `nix-hash' in $PATH.
-(test-skip (if (false-if-exception (system* %nix-hash "--version"))
-               0
-               1))
+;; The following test requires `nix-hash' in $PATH.
+(unless %have-nix-hash?
+  (test-skip 1))
 
 (test-assert "sha256 & bytevector->nix-base32-string"
   (let ((file (search-path %load-path "tests/test.drv")))