summary refs log tree commit diff
path: root/tests
diff options
context:
space:
mode:
authorLudovic Courtès <ludo@gnu.org>2012-12-13 22:14:25 +0100
committerLudovic Courtès <ludo@gnu.org>2012-12-13 22:14:25 +0100
commit1e9824513c570370638b1bfe33bf1dba1f12be4a (patch)
treecb7bd7f0bebd42dbeabf2c8f09ae1d5144ac969b /tests
parent70915c1a2ef72e7350b2a29d1d93e30643bce6f3 (diff)
parentb35c0f866c83288e64dcf5839d908705d416c317 (diff)
downloadguix-1e9824513c570370638b1bfe33bf1dba1f12be4a.tar.gz
Merge branch 'nix-integration'
Conflicts:
	tests/guix-package.sh
Diffstat (limited to 'tests')
-rw-r--r--tests/base32.scm18
-rw-r--r--tests/builders.scm5
-rw-r--r--tests/derivations.scm8
-rw-r--r--tests/guix-daemon.sh29
-rw-r--r--tests/guix-package.sh46
-rw-r--r--tests/packages.scm2
-rw-r--r--tests/union.scm6
-rw-r--r--tests/utils.scm5
8 files changed, 87 insertions, 32 deletions
diff --git a/tests/base32.scm b/tests/base32.scm
index b8b9ebb0dd..d1bbaa1764 100644
--- a/tests/base32.scm
+++ b/tests/base32.scm
@@ -23,15 +23,24 @@
   #: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"
@@ -67,10 +76,9 @@
          ;; 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")))
diff --git a/tests/builders.scm b/tests/builders.scm
index 12841d5690..6035032d5d 100644
--- a/tests/builders.scm
+++ b/tests/builders.scm
@@ -50,9 +50,13 @@
               (list name (package-derivation %store package))))
             (@@ (distro packages base) %boot0-inputs))))
 
+(define network-reachable?
+  (false-if-exception (getaddrinfo "www.gnu.org" "80" AI_NUMERICSERV)))
+
 
 (test-begin "builders")
 
+(unless network-reachable? (test-skip 1))
 (test-assert "url-fetch"
   (let* ((url      '("http://ftp.gnu.org/gnu/hello/hello-2.8.tar.gz"
                      "ftp://ftp.gnu.org/gnu/hello/hello-2.8.tar.gz"))
@@ -69,6 +73,7 @@
   (and (build-system? gnu-build-system)
        (eq? gnu-build (build-system-builder gnu-build-system))))
 
+(unless network-reachable? (test-skip 1))
 (test-assert "gnu-build"
   (let* ((url      "http://ftp.gnu.org/gnu/hello/hello-2.8.tar.gz")
          (hash     (nix-base32-string->bytevector
diff --git a/tests/derivations.scm b/tests/derivations.scm
index 14e1863a12..46bab4e19d 100644
--- a/tests/derivations.scm
+++ b/tests/derivations.scm
@@ -76,7 +76,7 @@
     (and (equal? b1 b2)
          (equal? d1 d2))))
 
-(test-skip (if %store 0 4))
+(test-skip (if %store 0 11))
 
 (test-assert "add-to-store, flat"
   (let* ((file (search-path %load-path "language/tree-il/spec.scm"))
@@ -290,8 +290,9 @@
 
 (define %coreutils
   (false-if-exception
-   (or (package-derivation %store %bootstrap-coreutils&co)
-       (nixpkgs-derivation "coreutils"))))
+   (and (getaddrinfo "www.gnu.org" "80" AI_NUMERICSERV)
+        (or (package-derivation %store %bootstrap-coreutils&co)
+            (nixpkgs-derivation "coreutils")))))
 
 (test-skip (if %coreutils 0 1))
 
@@ -385,6 +386,7 @@
            (and (equal? '(hello) (call-with-input-file one read))
                 (equal? '(world) (call-with-input-file two read)))))))
 
+(test-skip (if %coreutils 0 1))
 (test-assert "build-expression->derivation with one input"
   (let* ((builder    '(call-with-output-file %output
                         (lambda (p)
diff --git a/tests/guix-daemon.sh b/tests/guix-daemon.sh
new file mode 100644
index 0000000000..b942cbd546
--- /dev/null
+++ b/tests/guix-daemon.sh
@@ -0,0 +1,29 @@
+# Guix --- Nix package management from Guile.         -*- coding: utf-8 -*-
+# Copyright (C) 2012 Ludovic Courtès <ludo@gnu.org>
+#
+# This file is part of Guix.
+#
+# Guix is free software; you can redistribute it and/or modify it
+# under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or (at
+# your option) any later version.
+#
+# Guix is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with Guix.  If not, see <http://www.gnu.org/licenses/>.
+
+#
+# Test the daemon.
+#
+
+set -e
+
+guix-daemon --version
+guix-build --version
+
+guix-build -e '(@ (distro packages bootstrap) %bootstrap-guile)'
+guix-build coreutils -n
diff --git a/tests/guix-package.sh b/tests/guix-package.sh
index 2a424cc3de..60a0394f1c 100644
--- a/tests/guix-package.sh
+++ b/tests/guix-package.sh
@@ -39,31 +39,35 @@ test -L "$profile" && test -L "$profile-1-link"
 ! test -f "$profile-2-link"
 test -f "$profile/bin/guile"
 
-guix-package -b -p "$profile"						\
-    -i `guix-build -e '(@@ (distro packages base) gnu-make-boot0)'`
-test -L "$profile-2-link"
-test -f "$profile/bin/make" && test -f "$profile/bin/guile"
+# Check whether we have network access.
+if guile -c '(getaddrinfo "www.gnu.org" "80" AI_NUMERICSERV)' 2> /dev/null
+then
+    guix-package -b -p "$profile"						\
+	-i `guix-build -e '(@@ (distro packages base) gnu-make-boot0)'`
+    test -L "$profile-2-link"
+    test -f "$profile/bin/make" && test -f "$profile/bin/guile"
 
 
-# Check whether `--list-installed' works.
-# XXX: Change the tests when `--install' properly extracts the package
-# name and version string.
-installed="`guix-package -p "$profile" --list-installed | cut -f1 | xargs echo | sort`"
-case "x$installed" in
-    "guile-bootstrap make-boot0")
-	true;;
-    "make-boot0 guile-bootstrap")
-	true;;
-    "*")
-        false;;
-esac
+    # Check whether `--list-installed' works.
+    # XXX: Change the tests when `--install' properly extracts the package
+    # name and version string.
+    installed="`guix-package -p "$profile" --list-installed | cut -f1 | xargs echo | sort`"
+    case "x$installed" in
+	"guile-bootstrap make-boot0")
+	    true;;
+	"make-boot0 guile-bootstrap")
+	    true;;
+	"*")
+            false;;
+    esac
 
-test "`guix-package -p "$profile" -I 'g.*e' | cut -f1`" = "guile-bootstrap"
+    test "`guix-package -p "$profile" -I 'g.*e' | cut -f1`" = "guile-bootstrap"
 
-# Remove a package.
-guix-package -b -p "$profile" -r "guile-bootstrap"
-test -L "$profile-3-link"
-test -f "$profile/bin/make" && ! test -f "$profile/bin/guile"
+    # Remove a package.
+    guix-package -b -p "$profile" -r "guile-bootstrap"
+    test -L "$profile-3-link"
+    test -f "$profile/bin/make" && ! test -f "$profile/bin/guile"
+fi
 
 # Make sure the `:' syntax works.
 guix-package -b -i "libsigsegv:lib" -n
diff --git a/tests/packages.scm b/tests/packages.scm
index c89f6e7721..5b0cd79b0f 100644
--- a/tests/packages.scm
+++ b/tests/packages.scm
@@ -125,6 +125,8 @@
          (let ((p (pk 'drv d (derivation-path->output-path d))))
            (eq? 'hello (call-with-input-file p read))))))
 
+(unless (false-if-exception (getaddrinfo "www.gnu.org" "80" AI_NUMERICSERV))
+  (test-skip 1))
 (test-assert "GNU Make, bootstrap"
   ;; GNU Make is the first program built during bootstrap; we choose it
   ;; here so that the test doesn't last for too long.
diff --git a/tests/union.scm b/tests/union.scm
index 73b95c49b8..c839855ef4 100644
--- a/tests/union.scm
+++ b/tests/union.scm
@@ -64,7 +64,11 @@
                 (bin make)
                 (share (doc (make README))))))
 
-(test-skip (if %store 0 1))
+(test-skip (if (and %store
+                    (false-if-exception
+                     (getaddrinfo "www.gnu.org" "80" AI_NUMERICSERV)))
+               0
+               1))
 
 (test-assert "union-build"
   (let* ((inputs  (map (match-lambda
diff --git a/tests/utils.scm b/tests/utils.scm
index 0a6e8a0833..ba04e281eb 100644
--- a/tests/utils.scm
+++ b/tests/utils.scm
@@ -18,7 +18,7 @@
 
 (define-module (test-utils)
   #:use-module (guix utils)
-  #:use-module ((guix store) #:select (store-path-package-name))
+  #:use-module ((guix store) #:select (%store-prefix store-path-package-name))
   #:use-module (srfi srfi-1)
   #:use-module (srfi srfi-11)
   #:use-module (srfi srfi-64)
@@ -127,7 +127,8 @@
 (test-equal "store-path-package-name"
   "bash-4.2-p24"
   (store-path-package-name
-   "/nix/store/qvs2rj2ia5vci3wsdb7qvydrmacig4pg-bash-4.2-p24"))
+   (string-append (%store-prefix)
+                  "/qvs2rj2ia5vci3wsdb7qvydrmacig4pg-bash-4.2-p24")))
 
 (test-end)