[PATCH] tests: Assert that cyclic graphs can be produced.

  • Done
  • quality assurance status badge
Details
2 participants
  • Liliana Marie Prikler
  • Ludovic Courtès
Owner
unassigned
Submitted by
Liliana Marie Prikler
Severity
normal
L
L
Liliana Marie Prikler wrote on 24 Jan 2022 19:15
(address . guix-patches@gnu.org)
9649435159ca9f35c55ae66e577f520da50f5f8d.camel@gmail.com
* tests/graph.scm ("package DAG, oops it was a cycle"): New test.
---
tests/graph.scm | 28 ++++++++++++++++++++++++++++
1 file changed, 28 insertions(+)

Toggle diff (48 lines)
diff --git a/tests/graph.scm b/tests/graph.scm
index fadac265f9..baa08a6be2 100644
--- a/tests/graph.scm
+++ b/tests/graph.scm
@@ -36,6 +36,7 @@ (define-module (test-graph)
#:use-module (gnu packages libunistring)
#:use-module (gnu packages bootstrap)
#:use-module (ice-9 match)
+ #:use-module (ice-9 sandbox)
#:use-module (srfi srfi-1)
#:use-module (srfi srfi-11)
#:use-module (srfi srfi-26)
@@ -113,6 +114,33 @@ (define (edge->tuple source target)
(list p4 p4)
(list p2 p3))))))))
+(test-assert "package DAG, oops it was a cycle"
+ (let-values (((backend nodes+edges) (make-recording-backend)))
+ (letrec ((p1 (dummy-package "p1" (inputs `(("p3" ,p3)))))
+ (p2 (dummy-package "p2" (inputs `(("p1" ,p1)))))
+ (p3 (dummy-package "p3" (inputs `(("p2" ,p2) ("p1", p1))))))
+ (call-with-time-limit
+ 600 ;; If ever this test should fail, we still want it to terminate
+ (lambda ()
+ (run-with-store %store
+ (export-graph (list p3) 'port
+ #:node-type %package-node-type
+ #:backend backend)))
+ (lambda ()
+ (run-with-store %store
+ (export-graph
+ (list (dummy-package "timeout-reached"))
+ 'port
+ #:node-type %package-node-type
+ #:backend backend))))
+ ;; We should see nothing more than these 3 packages.
+ (let-values (((nodes edges) (nodes+edges)))
+ (and (equal? nodes (map package->tuple (list p3 p2 p1)))
+ (equal? edges
+ (map edge->tuple
+ (list p3 p3 p2 p1)
+ (list p2 p1 p1 p3))))))))
+
(test-assert "reverse package DAG"
(let-values (((backend nodes+edges) (make-recording-backend)))
(run-with-store %store
--
2.34.0
L
L
Ludovic Courtès wrote on 4 Feb 2022 23:11
(name . Liliana Marie Prikler)(address . liliana.prikler@gmail.com)(address . 53510@debbugs.gnu.org)
8735kymgcz.fsf@gnu.org
Liliana Marie Prikler <liliana.prikler@gmail.com> skribis:

Toggle quote (2 lines)
> * tests/graph.scm ("package DAG, oops it was a cycle"): New test.

LGTM, thanks!

Ludo'.
L
L
Ludovic Courtès wrote on 10 Feb 2022 22:21
control message for bug #53510
(address . control@debbugs.gnu.org)
87pmnu2zb1.fsf@gnu.org
close 53510
quit
?