summaryrefslogtreecommitdiff
path: root/tests/derivations.scm
diff options
context:
space:
mode:
authorLudovic Courtès <ludo@gnu.org>2015-07-03 00:05:16 +0200
committerLudovic Courtès <ludo@gnu.org>2015-07-03 00:30:55 +0200
commit4a6aeb670f74ef895878631bc3d832d08e1cb321 (patch)
treee6c2813bb9d13cb57c4d725614e255392e543a6b /tests/derivations.scm
parent322eeb87d0e5bb608ae1c176611a50297c93cbe8 (diff)
downloadpatches-4a6aeb670f74ef895878631bc3d832d08e1cb321.tar
patches-4a6aeb670f74ef895878631bc3d832d08e1cb321.tar.gz
derivations: Add #:substitutable?, distinguished from #:local-build?.
Fixes <http://bugs.gnu.org/18747>. * guix/derivations.scm (substitutable-derivation?): Rewrite to check for "allowSubstitutes". (derivation): Add #:substitutable? parameter. [user+system-env-vars]: Honor it. (build-expression->derivation): Add #:substitutable? and honor it. * guix/gexp.scm (gexp->derivation): Likewise. * tests/derivations.scm ("derivation-prerequisites-to-build and substitutes, non-substitutable build"): Use #:substitutable? instead of #:local-build?. ("substitutable-derivation?", "derivation-prerequisites-to-build and substitutes, local build"): New tests. * guix/download.scm (url-fetch): Adjust comment. * guix/git-download.scm (git-fetch): Likewise. * guix/build-system/gnu.scm (gnu-build, gnu-cross-build): Use #:substitutable? instead of #:local-build?. * doc/guix.texi (Derivations, G-Expressions): Adjust accordingly.
Diffstat (limited to 'tests/derivations.scm')
-rw-r--r--tests/derivations.scm44
1 files changed, 37 insertions, 7 deletions
diff --git a/tests/derivations.scm b/tests/derivations.scm
index df5f07d117..f66ef5cdd7 100644
--- a/tests/derivations.scm
+++ b/tests/derivations.scm
@@ -188,10 +188,22 @@
(test-assert "offloadable-derivation?"
(and (offloadable-derivation? (derivation %store "foo" %bash '()))
+ (offloadable-derivation? ;see <http://bugs.gnu.org/18747>
+ (derivation %store "foo" %bash '()
+ #:substitutable? #f))
(not (offloadable-derivation?
(derivation %store "foo" %bash '()
#:local-build? #t)))))
+(test-assert "substitutable-derivation?"
+ (and (substitutable-derivation? (derivation %store "foo" %bash '()))
+ (substitutable-derivation? ;see <http://bugs.gnu.org/18747>
+ (derivation %store "foo" %bash '()
+ #:local-build? #f))
+ (not (substitutable-derivation?
+ (derivation %store "foo" %bash '()
+ #:substitutable? #f)))))
+
(test-assert "fixed-output-derivation?"
(let* ((builder (add-text-to-store %store "my-fixed-builder.sh"
"echo -n hello > $out" '()))
@@ -614,14 +626,11 @@
(null? download*)
(null? build*))))))
-(test-assert "derivation-prerequisites-to-build and substitutes, local build"
+(test-assert "derivation-prerequisites-to-build and substitutes, non-substitutable build"
(let* ((store (open-connection))
- (drv (build-expression->derivation store "prereq-subst-local"
+ (drv (build-expression->derivation store "prereq-no-subst"
(random 1000)
- ;; XXX: Adjust once
- ;; <http://bugs.gnu.org/18747>
- ;; is fixed.
- #:local-build? #t))
+ #:substitutable? #f))
(output (derivation->output-path drv)))
;; Make sure substitutes are usable.
@@ -631,13 +640,34 @@
(let-values (((build download)
(derivation-prerequisites-to-build store drv)))
;; Despite being available as a substitute, DRV will be built locally
- ;; due to #:local-build?.
+ ;; due to #:substitutable? #f.
(and (null? download)
(match build
(((? derivation-input? input))
(string=? (derivation-input-path input)
(derivation-file-name drv)))))))))
+(test-assert "derivation-prerequisites-to-build and substitutes, local build"
+ (with-store store
+ (let* ((drv (build-expression->derivation store "prereq-subst-local"
+ (random 1000)
+ #:local-build? #t))
+ (output (derivation->output-path drv)))
+
+ ;; Make sure substitutes are usable.
+ (set-build-options store #:use-substitutes? #t)
+
+ (with-derivation-narinfo drv
+ (let-values (((build download)
+ (derivation-prerequisites-to-build store drv)))
+ ;; #:local-build? is not be synonymous with #:substitutable?, so we
+ ;; must be able to substitute DRV's output.
+ ;; See <http://bugs.gnu.org/18747>.
+ (and (null? build)
+ (match download
+ (((? string? item))
+ (string=? item (derivation->output-path drv))))))))))
+
(test-assert "build-expression->derivation with expression returning #f"
(let* ((builder '(begin
(mkdir %output)