aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorLudovic Courtès <ludo@gnu.org>2014-06-01 23:32:26 +0200
committerLudovic Courtès <ludo@gnu.org>2014-06-01 23:32:26 +0200
commitb53be755e465be04dc05e9069178874cb9f1f44d (patch)
treeac203c60539f00266d98edd3e3aff1c787dbe599 /tests
parent5a6a3ba43a1830c712e29d09e341e3cf14aea507 (diff)
downloadguix-b53be755e465be04dc05e9069178874cb9f1f44d.tar
guix-b53be755e465be04dc05e9069178874cb9f1f44d.tar.gz
derivations: Add #:allowed-references 'derivation' parameter.
* guix/derivations.scm (derivation): Add #:allowed-references parameter. [user+system-env-vars]: Honor it. * tests/derivations.scm ("derivation #:allowed-references, ok", "derivation #:allowed-references, not allowed", "derivation #:allowed-references, self allowed", "derivation #:allowed-references, self not allowed"): New tests. * doc/guix.texi (Derivations): Document #:allowed-references.
Diffstat (limited to 'tests')
-rw-r--r--tests/derivations.scm37
1 files changed, 37 insertions, 0 deletions
diff --git a/tests/derivations.scm b/tests/derivations.scm
index 0b785029a7..87609108d6 100644
--- a/tests/derivations.scm
+++ b/tests/derivations.scm
@@ -390,6 +390,43 @@
((p2 . _)
(string<? p1 p2)))))))))))))))
+(test-assert "derivation #:allowed-references, ok"
+ (let ((drv (derivation %store "allowed" %bash
+ '("-c" "echo hello > $out")
+ #:inputs `((,%bash))
+ #:allowed-references '())))
+ (build-derivations %store (list drv))))
+
+(test-assert "derivation #:allowed-references, not allowed"
+ (let* ((txt (add-text-to-store %store "foo" "Hello, world."))
+ (drv (derivation %store "disallowed" %bash
+ `("-c" ,(string-append "echo " txt "> $out"))
+ #:inputs `((,%bash) (,txt))
+ #:allowed-references '())))
+ (guard (c ((nix-protocol-error? c)
+ ;; There's no specific error message to check for.
+ #t))
+ (build-derivations %store (list drv))
+ #f)))
+
+(test-assert "derivation #:allowed-references, self allowed"
+ (let ((drv (derivation %store "allowed" %bash
+ '("-c" "echo $out > $out")
+ #:inputs `((,%bash))
+ #:allowed-references '("out"))))
+ (build-derivations %store (list drv))))
+
+(test-assert "derivation #:allowed-references, self not allowed"
+ (let ((drv (derivation %store "disallowed" %bash
+ `("-c" ,"echo $out > $out")
+ #:inputs `((,%bash))
+ #:allowed-references '())))
+ (guard (c ((nix-protocol-error? c)
+ ;; There's no specific error message to check for.
+ #t))
+ (build-derivations %store (list drv))
+ #f)))
+
(define %coreutils
(false-if-exception