aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLudovic Courtès <ludo@gnu.org>2014-03-27 23:53:00 +0100
committerLudovic Courtès <ludo@gnu.org>2014-03-27 23:56:47 +0100
commitc9e2b0b16e3efe319d437d9a96c8ce65ed145e8f (patch)
tree82b602f16c70002fa688770039198f3399e567bf
parent968e84a6cf9941963df0437d9e99adad805e8143 (diff)
downloadguix-c9e2b0b16e3efe319d437d9a96c8ce65ed145e8f.tar
guix-c9e2b0b16e3efe319d437d9a96c8ce65ed145e8f.tar.gz
daemon: Add tests for substitutes and --no-substitutes.
* tests/guix-daemon.sh: Add substituter tests.
-rw-r--r--tests/guix-daemon.sh56
1 files changed, 52 insertions, 4 deletions
diff --git a/tests/guix-daemon.sh b/tests/guix-daemon.sh
index 698516490b..a73c9e22e3 100644
--- a/tests/guix-daemon.sh
+++ b/tests/guix-daemon.sh
@@ -1,5 +1,5 @@
# GNU Guix --- Functional package management for GNU
-# Copyright © 2012 Ludovic Courtès <ludo@gnu.org>
+# Copyright © 2012, 2014 Ludovic Courtès <ludo@gnu.org>
#
# This file is part of GNU Guix.
#
@@ -17,7 +17,7 @@
# along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
#
-# Test the daemon.
+# Test the daemon and its interaction with 'guix substitute-binary'.
#
set -e
@@ -25,5 +25,53 @@ set -e
guix-daemon --version
guix build --version
-guix build -e '(@ (gnu packages bootstrap) %bootstrap-guile)'
-guix build coreutils -n
+drv="`guix build emacs -d`"
+out="`guile -c ' \
+ (use-modules (guix) (gnu packages emacs)) \
+ (define store (open-connection)) \
+ (display (derivation->output-path (package-derivation store emacs)))'`"
+
+hash_part="`basename $out | cut -c 1-32`"
+narinfo="$hash_part.narinfo"
+substitute_dir="`echo $GUIX_BINARY_SUBSTITUTE_URL | sed -'es,file://,,g'`"
+
+cat > "$substitute_dir/nix-cache-info"<<EOF
+StoreDir: `dirname $drv`
+WantMassQuery: 0
+EOF
+
+cat > "$substitute_dir/$narinfo"<<EOF
+StorePath: $out
+URL: /nowhere/example.nar
+Compression: none
+NarSize: 1234
+References:
+System: `guile -c '(use-modules (guix)) (display (%current-system))'`
+Deriver: $drv
+EOF
+
+# Remove the cached narinfo.
+rm -f "$XDG_CACHE_HOME/guix/substitute-binary/$hash_part"
+
+# Make sure we see the substitute.
+guile -c '
+ (use-modules (guix))
+ (define store (open-connection))
+ (set-build-options store #:use-substitutes? #t)
+ (exit (has-substitutes? store "'"$out"'"))'
+
+# Now, run guix-daemon --no-substitutes.
+socket="$NIX_STATE_DIR/alternate-socket"
+guix-daemon --no-substitutes --listen="$socket" --disable-chroot &
+daemon_pid=$!
+trap "kill $daemon_pid" EXIT
+
+# Make sure we DON'T see the substitute.
+guile -c "
+ (use-modules (guix))
+ (define store (open-connection \"$socket\"))
+
+ ;; This setting MUST NOT override the daemon's --no-substitutes.
+ (set-build-options store #:use-substitutes? #t)
+
+ (exit (not (has-substitutes? store \"$out\")))"