summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorLudovic Courtès <ludo@gnu.org>2021-09-24 23:00:11 +0200
committerLudovic Courtès <ludo@gnu.org>2021-09-25 00:41:32 +0200
commitdf46bef48eaa43c502fa9193371692c039b460c1 (patch)
treebe496d3a0e8ff150ff8fc48c53f29c73e8f23867 /tests
parent9fbe4b88c2369166733bc039fb261839846011d3 (diff)
gexp: Leave grafting as is when lowering allowed/disallowed references.
Fixes <https://issues.guix.gnu.org/50676>. Reported by Mathieu Othacehe <othacehe@gnu.org>. Commit a779363b6aa581e88eda21f9f35530962d54ac25 was partially incorrect: references passed to #:allowed-references or #:references-graphs *can* be lowered as references to grafted elements. This is for example the case when doing: (computed-file "partition.img" exp #:options `(#:references-graphs ,inputs)) Here INPUTS must be lowered as a reference to suitably grafted elements. Failing to do that, the reference graph will not match the actual INPUTS. However, when building a package, those references must indeed refer only to ungrafted packages. This commit preserves that by having build systems pass #:graft? #f. * guix/gexp.scm (lower-reference-graphs, lower-references): Remove uses of 'without-grafting'. This reverts a779363b6aa581e88eda21f9f35530962d54ac25. * guix/build-system/cmake.scm (cmake-build, cmake-cross-build): Pass #:graft? #f. * guix/build-system/glib-or-gtk.scm (glib-or-gtk-build) (glib-or-gtk-cross-build): Likewise. * guix/build-system/gnu.scm (gnu-build, gnu-cross-build): Likewise. * guix/build-system/meson.scm (meson-build, meson-cross-build): Likewise. * guix/build-system/trivial.scm (trivial-build, trivial-cross-build): Likewise. * tests/gexp.scm ("lower-object, computed-file + grafts"): New test. * tests/packages.scm ("trivial with #:allowed-references + grafts"): New test.
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 709a198e1ea..28d09f5a6d1 100644
--- a/tests/gexp.scm
+++ b/tests/gexp.scm
@@ -1475,6 +1475,42 @@ importing.* \\(guix config\\) from the host"
1475 (string=? (readlink (string-append comp "/text")) 1475 (string=? (readlink (string-append comp "/text"))
1476 text))))))) 1476 text)))))))
1477 1477
1478(test-assert "lower-object, computed-file + grafts"
1479 ;; The reference graph should refer to grafted packages when grafts are
1480 ;; enabled. See <https://issues.guix.gnu.org/50676>.
1481 (let* ((base (package
1482 (inherit (dummy-package "trivial"))
1483 (build-system trivial-build-system)
1484 (arguments
1485 `(#:guile ,%bootstrap-guile
1486 #:builder (mkdir %output)))))
1487 (pkg (package
1488 (inherit base)
1489 (version "1.1")
1490 (replacement (package
1491 (inherit base)
1492 (version "9.9")))))
1493 (exp #~(begin
1494 (use-modules (ice-9 rdelim))
1495 (let ((item (call-with-input-file "graph" read-line)))
1496 (call-with-output-file #$output
1497 (lambda (port)
1498 (display item port))))))
1499 (computed (computed-file "computed" exp
1500 #:options
1501 `(#:references-graphs (("graph" ,pkg)))))
1502 (drv0 (package-derivation %store pkg #:graft? #t))
1503 (drv1 (parameterize ((%graft? #t))
1504 (run-with-store %store
1505 (lower-object computed)))))
1506 (build-derivations %store (list drv1))
1507
1508 ;; The graph obtained in COMPUTED should refer to the grafted version of
1509 ;; PKG, not to PKG itself.
1510 (string=? (call-with-input-file (derivation->output-path drv1)
1511 get-string-all)
1512 (derivation->output-path drv0))))
1513
1478(test-equal "lower-object, computed-file, #:system" 1514(test-equal "lower-object, computed-file, #:system"
1479 '("mips64el-linux") 1515 '("mips64el-linux")
1480 (run-with-store %store 1516 (run-with-store %store
diff --git a/tests/packages.scm b/tests/packages.scm
index 46f4da1494b..a9494b5c0eb 100644
--- a/tests/packages.scm
+++ b/tests/packages.scm
@@ -882,6 +882,28 @@
882 (build-derivations %store (list d)) 882 (build-derivations %store (list d))
883 #f))) 883 #f)))
884 884
885(test-assert "trivial with #:allowed-references + grafts"
886 (let* ((g (package
887 (inherit %bootstrap-guile)
888 (replacement (package
889 (inherit %bootstrap-guile)
890 (version "9.9")))))
891 (p (package
892 (inherit (dummy-package "trivial"))
893 (build-system trivial-build-system)
894 (inputs (list g))
895 (arguments
896 `(#:guile ,g
897 #:allowed-references (,g)
898 #:builder (mkdir %output)))))
899 (d0 (package-derivation %store p #:graft? #f))
900 (d1 (parameterize ((%graft? #t))
901 (package-derivation %store p #:graft? #t))))
902 ;; D1 should be equal to D2 because there's nothing to graft. In
903 ;; particular, its #:disallowed-references should be lowered in the same
904 ;; way (ungrafted) whether or not #:graft? is true.
905 (string=? (derivation-file-name d1) (derivation-file-name d0))))
906
885(test-assert "search paths" 907(test-assert "search paths"
886 (let* ((p (make-prompt-tag "return-search-paths")) 908 (let* ((p (make-prompt-tag "return-search-paths"))
887 (t (make-parameter "guile-0")) 909 (t (make-parameter "guile-0"))