aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorLudovic Courtès <ludo@gnu.org>2013-04-02 10:44:20 +0200
committerLudovic Courtès <ludo@gnu.org>2013-04-03 22:44:39 +0200
commitf65cf81a3cd15eab993e129977bca46972508b4b (patch)
tree81fea5351de590e66a985870f02aeb85bf33a3fc /tests
parentcf53ecf514301d3ffdfc33dea057b057ffb132d6 (diff)
downloadguix-f65cf81a3cd15eab993e129977bca46972508b4b.tar
guix-f65cf81a3cd15eab993e129977bca46972508b4b.tar.gz
Add preliminary binary substituter.
* guix/scripts/substitute-binary.scm: New file. * Makefile.am (MODULES): Add it. * nix/scripts/substitute-binary.in: New file. * config-daemon.ac: Produce nix/scripts/substitute-binary. * daemon.am (nodist_pkglibexec_SCRIPTS): Add nix/scripts/substitute-binary. * guix/store.scm (substitutable-path-info): Use the `query-substitutable-path-infos' RPC. * nix/nix-daemon/guix-daemon.cc (main): Honor `NIX_SUBSTITUTERS'. * pre-inst-env.in: Set `NIX_SUBSTITUTERS'. * test-env.in: Leave `NIX_SUBSTITUTERS' unchanged. Set `GUIX_BINARY_SUBSTITUTE_URL, and create $NIX_STATE_DIR/substituter-data. Run `guix-daemon' within `./pre-inst-env'. * tests/store.scm ("substitute query"): New test.
Diffstat (limited to 'tests')
-rw-r--r--tests/store.scm39
1 files changed, 39 insertions, 0 deletions
diff --git a/tests/store.scm b/tests/store.scm
index d6e1aa54e3..c75b99c6a9 100644
--- a/tests/store.scm
+++ b/tests/store.scm
@@ -26,6 +26,7 @@
#:use-module (gnu packages)
#:use-module (gnu packages bootstrap)
#:use-module (ice-9 match)
+ #:use-module (web uri)
#:use-module (srfi srfi-1)
#:use-module (srfi srfi-11)
#:use-module (srfi srfi-64))
@@ -128,6 +129,44 @@
(null? (substitutable-paths s o))
(null? (substitutable-path-info s o)))))
+(test-skip (if (getenv "GUIX_BINARY_SUBSTITUTE_URL") 0 1))
+
+(test-assert "substitute query"
+ (let* ((s (open-connection))
+ (d (package-derivation s %bootstrap-guile (%current-system)))
+ (o (derivation-path->output-path d))
+ (dir (and=> (getenv "GUIX_BINARY_SUBSTITUTE_URL")
+ (compose uri-path string->uri))))
+ ;; Create fake substituter data, to be read by `substitute-binary'.
+ (call-with-output-file (string-append dir "/nix-cache-info")
+ (lambda (p)
+ (format p "StoreDir: ~a\nWantMassQuery: 0\n"
+ (getenv "NIX_STORE_DIR"))))
+ (call-with-output-file (string-append dir "/" (store-path-hash-part o)
+ ".narinfo")
+ (lambda (p)
+ (format p "StorePath: ~a
+URL: ~a
+Compression: none
+NarSize: 1234
+References:
+System: ~a
+Deriver: ~a~%"
+ o ; StorePath
+ (string-append dir "/example.nar") ; URL
+ (%current-system) ; System
+ (basename d)))) ; Deriver
+
+ ;; Make sure `substitute-binary' correctly communicates the above data.
+ (set-build-options s #:use-substitutes? #t)
+ (and (has-substitutes? s o)
+ (equal? (list o) (substitutable-paths s (list o)))
+ (match (pk 'spi (substitutable-path-info s (list o)))
+ (((? substitutable? s))
+ (and (equal? (substitutable-deriver s) d)
+ (null? (substitutable-references s))
+ (equal? (substitutable-nar-size s) 1234)))))))
+
(test-end "store")