unofficial mirror of guix-patches@gnu.org 
 help / color / mirror / code / Atom feed
From: Liliana Marie Prikler <liliana.prikler@gmail.com>
To: 53510@debbugs.gnu.org
Subject: [bug#53510] [PATCH] tests: Assert that cyclic graphs can be produced.
Date: Mon, 24 Jan 2022 19:15:44 +0100	[thread overview]
Message-ID: <9649435159ca9f35c55ae66e577f520da50f5f8d.camel@gmail.com> (raw)

* tests/graph.scm ("package DAG, oops it was a cycle"): New test.
---
 tests/graph.scm | 28 ++++++++++++++++++++++++++++
 1 file changed, 28 insertions(+)

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





             reply	other threads:[~2022-01-24 18:37 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-01-24 18:15 Liliana Marie Prikler [this message]
2022-02-04 22:11 ` [bug#53510] [PATCH] tests: Assert that cyclic graphs can be produced Ludovic Courtès

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://guix.gnu.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=9649435159ca9f35c55ae66e577f520da50f5f8d.camel@gmail.com \
    --to=liliana.prikler@gmail.com \
    --cc=53510@debbugs.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/guix.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).