summaryrefslogtreecommitdiff
path: root/tests/graph.scm
diff options
context:
space:
mode:
authorLudovic Courtès <ludovic.courtes@inria.fr>2021-09-17 10:13:15 +0200
committerLudovic Courtès <ludo@gnu.org>2021-09-21 15:15:52 +0200
commit5b32ad4f6f555d305659cee825879df075b06331 (patch)
tree41006f22dae8547c5b7a159e52bce284a438f533 /tests/graph.scm
parentbe32889902abc29c14f3ea9a4f52da1bf9a0383a (diff)
graph: Add '--max-depth'.
* guix/graph.scm (export-graph): Add #:max-depth and honor it, adding 'depths' argument to 'loop'. * guix/scripts/graph.scm (%options, show-help): Add '--max-depth'. (%default-options): Add 'max-depth'. (guix-graph): Pass #:max-depth to 'export-graph'. * tests/graph.scm ("package DAG, limited depth"): New test. * doc/guix.texi (Invoking guix graph): Document it.
Diffstat (limited to 'tests/graph.scm')
-rw-r--r--tests/graph.scm21
1 files changed, 20 insertions, 1 deletions
diff --git a/tests/graph.scm b/tests/graph.scm
index e374dad1a55..fadac265f96 100644
--- a/tests/graph.scm
+++ b/tests/graph.scm
@@ -1,5 +1,5 @@
1;;; GNU Guix --- Functional package management for GNU 1;;; GNU Guix --- Functional package management for GNU
2;;; Copyright © 2015, 2016, 2017, 2018, 2019, 2020 Ludovic Courtès <ludo@gnu.org> 2;;; Copyright © 2015, 2016, 2017, 2018, 2019, 2020, 2021 Ludovic Courtès <ludo@gnu.org>
3;;; 3;;;
4;;; This file is part of GNU Guix. 4;;; This file is part of GNU Guix.
5;;; 5;;;
@@ -94,6 +94,25 @@ edges."
94 (list p3 p3 p2) 94 (list p3 p3 p2)
95 (list p2 p1 p1)))))))) 95 (list p2 p1 p1))))))))
96 96
97(test-assert "package DAG, limited depth"
98 (let-values (((backend nodes+edges) (make-recording-backend)))
99 (let* ((p1 (dummy-package "p1"))
100 (p2 (dummy-package "p2" (inputs `(("p1" ,p1)))))
101 (p3 (dummy-package "p3" (inputs `(("p1" ,p1)))))
102 (p4 (dummy-package "p4" (inputs `(("p2" ,p2) ("p3" ,p3))))))
103 (run-with-store %store
104 (export-graph (list p4) 'port
105 #:max-depth 1
106 #:node-type %package-node-type
107 #:backend backend))
108 ;; We should see nothing more than these 3 packages.
109 (let-values (((nodes edges) (nodes+edges)))
110 (and (equal? nodes (map package->tuple (list p4 p2 p3)))
111 (equal? edges
112 (map edge->tuple
113 (list p4 p4)
114 (list p2 p3))))))))
115
97(test-assert "reverse package DAG" 116(test-assert "reverse package DAG"
98 (let-values (((backend nodes+edges) (make-recording-backend))) 117 (let-values (((backend nodes+edges) (make-recording-backend)))
99 (run-with-store %store 118 (run-with-store %store