summary refs log tree commit diff
path: root/tests/import-utils.scm
diff options
context:
space:
mode:
authorLudovic Courtès <ludo@gnu.org>2019-12-10 20:13:04 +0100
committerLudovic Courtès <ludo@gnu.org>2019-12-11 12:12:58 +0100
commitddd59159004ca73c9449a27945116ff5069c3743 (patch)
tree9212db3dbfdc22d62afdc92643e5dbdd91f06399 /tests/import-utils.scm
parent6c3021a84006924d924d282f22aa1f338d4b3528 (diff)
downloadguix-ddd59159004ca73c9449a27945116ff5069c3743.tar.gz
import: utils: 'recursive-import' returns packages in topological order.
* guix/import/utils.scm (topological-sort): New procedure.
(recursive-import): Rewrite to use it.
* tests/import-utils.scm ("recursive-import"): New test.
* guix/import/cran.scm (cran->guix-package): Always return two values.
* guix/scripts/import/cran.scm (guix-import-cran): Remove 'reverse' call
on 'cran-recursive-import' result.
* guix/scripts/import/crate.scm (guix-import-crate): Likewise.
* guix/scripts/import/elpa.scm (guix-import-elpa): Likewise.
* guix/scripts/import/gem.scm (guix-import-gem): Likewise.
* guix/scripts/import/hackage.scm (guix-import-hackage): Likewise.
* guix/scripts/import/opam.scm (guix-import-opam): Likewise.
* guix/scripts/import/pypi.scm (guix-import-pypi): Likewise.
* guix/scripts/import/stackage.scm (guix-import-stackage): Likewise.
* tests/gem.scm ("gem-recursive-import"): Change the order of package
expressions accordingly.
Diffstat (limited to 'tests/import-utils.scm')
-rw-r--r--tests/import-utils.scm25
1 files changed, 24 insertions, 1 deletions
diff --git a/tests/import-utils.scm b/tests/import-utils.scm
index c3ab25d788..3400433bbb 100644
--- a/tests/import-utils.scm
+++ b/tests/import-utils.scm
@@ -24,7 +24,9 @@
   #:use-module (guix packages)
   #:use-module (guix build-system)
   #:use-module (gnu packages)
-  #:use-module (srfi srfi-64))
+  #:use-module (srfi srfi-41)
+  #:use-module (srfi srfi-64)
+  #:use-module (ice-9 match))
 
 (test-begin "import-utils")
 
@@ -41,6 +43,27 @@
   'license:lgpl2.0
   (license->symbol license:lgpl2.0))
 
+(test-equal "recursive-import"
+  '((package                         ;package expressions in topological order
+      (name "bar"))
+    (package
+      (name "foo")
+      (inputs `(("bar" ,bar)))))
+  (stream->list
+   (recursive-import "foo" 'repo
+                     #:repo->guix-package
+                     (match-lambda*
+                       (("foo" 'repo)
+                        (values '(package
+                                   (name "foo")
+                                   (inputs `(("bar" ,bar))))
+                                '("bar")))
+                       (("bar" 'repo)
+                        (values '(package
+                                   (name "bar"))
+                                '())))
+                     #:guix-name identity)))
+
 (test-assert "alist->package with simple source"
   (let* ((meta '(("name" . "hello")
                  ("version" . "2.10")