summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorLudovic Courtès <ludo@gnu.org>2026-03-14 11:18:30 +0100
committerLudovic Courtès <ludo@gnu.org>2026-03-25 23:51:26 +0100
commitea827812f2b2dbc569f4b3478c3bc4645ea2eb15 (patch)
treefd08e7ab4f678891933d6dd0807b0de91b8fca31 /tests
parentac1a7cd864e30df462a8f2d667342cba3dbcfa7b (diff)
channels: Resolve dependencies recursively.
* guix/channels.scm (closure): New procedure. (resolve-dependencies): Use it. * tests/channels.scm ("channel-instance-dependency-resolver"): New test. Fixes: https://issues.guix.gnu.org/68797 Change-Id: Iaba4f54261e33e18bd57a0a319aa099f259b8570 Signed-off-by: Ludovic Courtès <ludo@gnu.org> Merges: #7137
Diffstat (limited to 'tests')
-rw-r--r--tests/channels.scm57
1 files changed, 56 insertions, 1 deletions
diff --git a/tests/channels.scm b/tests/channels.scm
index 15deb551ffa..2df4c86b5a8 100644
--- a/tests/channels.scm
+++ b/tests/channels.scm
@@ -1,6 +1,6 @@
1;;; GNU Guix --- Functional package management for GNU 1;;; GNU Guix --- Functional package management for GNU
2;;; Copyright © 2018 Ricardo Wurmus <rekado@elephly.net> 2;;; Copyright © 2018 Ricardo Wurmus <rekado@elephly.net>
3;;; Copyright © 2019-2020, 2022, 2024 Ludovic Courtès <ludo@gnu.org> 3;;; Copyright © 2019-2020, 2022, 2024, 2026 Ludovic Courtès <ludo@gnu.org>
4;;; 4;;;
5;;; This file is part of GNU Guix. 5;;; This file is part of GNU Guix.
6;;; 6;;;
@@ -278,6 +278,61 @@
278 #:current-channels (list new) 278 #:current-channels (list new)
279 #:validate-pull validate-pull))))))) 279 #:validate-pull validate-pull)))))))
280 280
281(test-equal "channel-instance-dependency-resolver"
282 '((c => (a b)) (b => (a)) (a => ()))
283 ;; Check that channel dependencies propagate. Here we create three channels
284 ;; that depend on one another: c depends on b, which depends on a. When
285 ;; resolving dependencies for c, we must get both a and b, such that
286 ;; (use-modules (b)) from channel c finds (a) when building the derivation
287 ;; of channel c. See <https://issues.guix.gnu.org/68797>.
288 (let ((call-with-channel
289 (lambda (name dependencies channels proc)
290 (with-temporary-git-repository directory
291 `((add ,(string-append (symbol->string name) ".scm")
292 ,(object->string
293 `(define-module (,name)
294 ,@(append-map (lambda (dependency)
295 `(#:use-module (,dependency)))
296 dependencies))))
297 (add ".guix-channel"
298 ,(object->string
299 `(channel
300 (version 0)
301 (dependencies
302 ,@(map (lambda (dependency)
303 `(channel
304 (name ,dependency)
305 (url "http://example.org")))
306 dependencies)))))
307 (commit "Initial commit."))
308 (proc (cons (channel
309 (name name)
310 (url directory))
311 channels))))))
312 (define-syntax with-channels
313 (syntax-rules (&initialized)
314 ((_ &initialized binding (name dependencies) rest ... exp)
315 (call-with-channel 'name dependencies binding
316 (lambda (binding)
317 (with-channels &initialized binding
318 rest ... exp))))
319 ((_ &initialized binding exp) exp)
320 ((_ binding rest ...)
321 (let ((binding '()))
322 (with-channels &initialized binding rest ...)))))
323
324 (with-channels
325 channels (a '()) (b '(a)) (c '(b))
326 (with-store store
327 (let* ((instances (latest-channel-instances store channels))
328 (resolve (channel-instance-dependency-resolver instances)))
329 (map (lambda (instance)
330 (list (channel-name (channel-instance-channel instance))
331 '=>
332 (map (compose channel-name channel-instance-channel)
333 (resolve instance))))
334 instances))))))
335
281(test-assert "channel-instances->manifest" 336(test-assert "channel-instances->manifest"
282 ;; Compute the manifest for a graph of instances and make sure we get a 337 ;; Compute the manifest for a graph of instances and make sure we get a
283 ;; derivation graph that mirrors the instance graph. This test also ensures 338 ;; derivation graph that mirrors the instance graph. This test also ensures