summary refs log tree commit diff
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/gexp.scm36
-rw-r--r--tests/packages.scm22
2 files changed, 58 insertions, 0 deletions
diff --git a/tests/gexp.scm b/tests/gexp.scm
index 709a198e1e..28d09f5a6d 100644
--- a/tests/gexp.scm
+++ b/tests/gexp.scm
@@ -1475,6 +1475,42 @@ importing.* \\(guix config\\) from the host"
                      (string=? (readlink (string-append comp "/text"))
                                text)))))))
 
+(test-assert "lower-object, computed-file + grafts"
+  ;; The reference graph should refer to grafted packages when grafts are
+  ;; enabled.  See <https://issues.guix.gnu.org/50676>.
+  (let* ((base    (package
+                    (inherit (dummy-package "trivial"))
+                    (build-system trivial-build-system)
+                    (arguments
+                     `(#:guile ,%bootstrap-guile
+                       #:builder (mkdir %output)))))
+         (pkg     (package
+                    (inherit base)
+                    (version "1.1")
+                    (replacement (package
+                                   (inherit base)
+                                   (version "9.9")))))
+         (exp      #~(begin
+                       (use-modules (ice-9 rdelim))
+                       (let ((item (call-with-input-file "graph" read-line)))
+                         (call-with-output-file #$output
+                           (lambda (port)
+                             (display item port))))))
+         (computed (computed-file "computed" exp
+                                  #:options
+                                  `(#:references-graphs (("graph" ,pkg)))))
+         (drv0     (package-derivation %store pkg #:graft? #t))
+         (drv1     (parameterize ((%graft? #t))
+                     (run-with-store %store
+                       (lower-object computed)))))
+    (build-derivations %store (list drv1))
+
+    ;; The graph obtained in COMPUTED should refer to the grafted version of
+    ;; PKG, not to PKG itself.
+    (string=? (call-with-input-file (derivation->output-path drv1)
+                get-string-all)
+              (derivation->output-path drv0))))
+
 (test-equal "lower-object, computed-file, #:system"
   '("mips64el-linux")
   (run-with-store %store
diff --git a/tests/packages.scm b/tests/packages.scm
index 46f4da1494..a9494b5c0e 100644
--- a/tests/packages.scm
+++ b/tests/packages.scm
@@ -882,6 +882,28 @@
       (build-derivations %store (list d))
       #f)))
 
+(test-assert "trivial with #:allowed-references + grafts"
+  (let* ((g (package
+              (inherit %bootstrap-guile)
+              (replacement (package
+                             (inherit %bootstrap-guile)
+                             (version "9.9")))))
+         (p (package
+              (inherit (dummy-package "trivial"))
+              (build-system trivial-build-system)
+              (inputs (list g))
+              (arguments
+               `(#:guile ,g
+                 #:allowed-references (,g)
+                 #:builder (mkdir %output)))))
+         (d0 (package-derivation %store p #:graft? #f))
+         (d1 (parameterize ((%graft? #t))
+               (package-derivation %store p #:graft? #t))))
+    ;; D1 should be equal to D2 because there's nothing to graft.  In
+    ;; particular, its #:disallowed-references should be lowered in the same
+    ;; way (ungrafted) whether or not #:graft? is true.
+    (string=? (derivation-file-name d1) (derivation-file-name d0))))
+
 (test-assert "search paths"
   (let* ((p (make-prompt-tag "return-search-paths"))
          (t (make-parameter "guile-0"))