From 2b81eac01e5828c6fce61b3cafc0f78e7a0ab891 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ludovic=20Court=C3=A8s?= Date: Sat, 23 Mar 2019 15:04:44 +0100 Subject: graph: Add the 'reverse-bag' graph. Suggested by Julien Lepiller. * guix/scripts/graph.scm (%reverse-bag-node-type): New variable. (%node-types): Add it. * tests/graph.scm ("reverse bag DAG"): New test. * doc/guix.texi (Invoking guix graph): Document it. --- tests/graph.scm | 28 +++++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) (limited to 'tests/graph.scm') diff --git a/tests/graph.scm b/tests/graph.scm index 4799d3bd0c..c4c5096226 100644 --- a/tests/graph.scm +++ b/tests/graph.scm @@ -1,5 +1,5 @@ ;;; GNU Guix --- Functional package management for GNU -;;; Copyright © 2015, 2016, 2017, 2018 Ludovic Courtès +;;; Copyright © 2015, 2016, 2017, 2018, 2019 Ludovic Courtès ;;; ;;; This file is part of GNU Guix. ;;; @@ -191,6 +191,32 @@ edges." (string=? target (derivation-file-name g))))) edges))))))))) +(test-assert "reverse bag DAG" + (let-values (((dune bap ocaml-base) + (values (specification->package "dune") + (specification->package "bap") + (specification->package "ocaml-base"))) + ((backend nodes+edges) (make-recording-backend))) + (run-with-store %store + (export-graph (list dune) 'port + #:node-type %reverse-bag-node-type + #:backend backend)) + + (run-with-store %store + (mlet %store-monad ((dune-drv (package->derivation dune)) + (bap-drv (package->derivation bap)) + (ocaml-base-drv (package->derivation ocaml-base))) + ;; OCAML-BASE uses 'dune-build-system' so DUNE is a direct dependency. + ;; BAP is much higher in the stack but it should be there. + (let-values (((nodes edges) (nodes+edges))) + (return + (and (member `(,(derivation-file-name bap-drv) + ,(package-full-name bap)) + nodes) + (->bool (member (map derivation-file-name + (list dune-drv ocaml-base-drv)) + edges))))))))) + (test-assert "derivation DAG" (let-values (((backend nodes+edges) (make-recording-backend))) (run-with-store %store -- cgit v1.2.3