packages: Remove 'search-bootstrap-binary'.
[jackhill/guix/guix.git] / tests / derivations.scm
index c0601c0..25ba4c9 100644 (file)
@@ -29,7 +29,6 @@
   #:use-module (guix tests http)
   #:use-module ((guix packages) #:select (package-derivation base32))
   #:use-module ((guix build utils) #:select (executable-file?))
-  #:use-module ((gnu packages) #:select (search-bootstrap-binary))
   #:use-module (gnu packages bootstrap)
   #:use-module ((gnu packages guile) #:select (guile-1.8))
   #:use-module (srfi srfi-1)
       (build-derivations %store (list drv))
       #f)))
 
-;; Here we should get the value of $NIX_STATE_DIR that the daemon sees, which
-;; is a unique value for each test process; this value is the same as the one
-;; we see in the process executing this file since it is set by 'test-env'.
+;; Here we should get the value of $GUIX_STATE_DIRECTORY that the daemon sees,
+;; which is a unique value for each test process; this value is the same as
+;; the one we see in the process executing this file since it is set by
+;; 'test-env'.
 (test-equal "derivation #:leaked-env-vars"
-  (getenv "NIX_STATE_DIR")
-  (let* ((value (getenv "NIX_STATE_DIR"))
+  (getenv "GUIX_STATE_DIRECTORY")
+  (let* ((value (getenv "GUIX_STATE_DIRECTORY"))
          (drv   (derivation %store "leaked-env-vars" %bash
-                            '("-c" "echo -n $NIX_STATE_DIR > $out")
+                            '("-c" "echo -n $GUIX_STATE_DIRECTORY > $out")
                             #:hash (sha256 (string->utf8 value))
                             #:hash-algo 'sha256
                             #:inputs `((,%bash))
-                            #:leaked-env-vars '("NIX_STATE_DIR"))))
+                            #:leaked-env-vars '("GUIX_STATE_DIRECTORY"))))
     (and (build-derivations %store (list drv))
          (call-with-input-file (derivation->output-path drv)
            get-string-all))))
       (build-derivations store (list drv))
       #f)))
 
+(test-assert "build-derivations with specific output"
+  (with-store store
+    (let* ((content (random-text))                ;contents of the output
+           (drv     (build-expression->derivation
+                     store "substitute-me"
+                     `(begin ,content (exit 1))   ;would fail
+                     #:outputs '("out" "one" "two")
+                     #:guile-for-build
+                     (package-derivation store %bootstrap-guile)))
+           (out     (derivation->output-path drv)))
+      (with-derivation-substitute drv content
+        (set-build-options store #:use-substitutes? #t
+                           #:substitute-urls (%test-substitute-urls))
+        (and (has-substitutes? store out)
+
+             ;; Ask for nothing but the "out" output of DRV.
+             (build-derivations store `((,drv . "out")))
+
+             (valid-path? store out)
+             (equal? (pk 'x content) (pk 'y (call-with-input-file out get-string-all)))
+             )))))
+
 (test-assert "build-expression->derivation and derivation-prerequisites-to-build"
   (let ((drv (build-expression->derivation %store "fail" #f)))
     ;; The only direct dependency is (%guile-for-build) and it's already