From 28ade1bab207974cce6a014e7187968511fc5526 Mon Sep 17 00:00:00 2001 From: Ludovic Courtès Date: Fri, 23 Sep 2022 19:04:29 +0200 Subject: transformations: '--with-source' now operates in depth. The '--with-source' option is the first one that was implemented, and it's the only one that would operate only on leaf packages rather than traversing the dependency graph. This change makes it consistent with the rest of the transformation options. * guix/transformations.scm (evaluate-source-replacement-specs): New procedure. (transform-package-source): Rewrite using it. * tests/transformations.scm ("options->transformation, with-source, no matches"): Rewrite since we no longer get a warning. ("options->transformation, with-source, in depth"): New test. * doc/guix.texi (Package Transformation Options): Adjust examples. --- tests/transformations.scm | 32 +++++++++++++++++++++++++------- 1 file changed, 25 insertions(+), 7 deletions(-) (limited to 'tests') diff --git a/tests/transformations.scm b/tests/transformations.scm index dbfe523518..47b1fc650d 100644 --- a/tests/transformations.scm +++ b/tests/transformations.scm @@ -103,16 +103,11 @@ (define-module (test-transformations) "sha256" f)))))))))) (test-assert "options->transformation, with-source, no matches" - ;; When a transformation in not applicable, a warning must be raised. (let* ((p (dummy-package "foobar")) (s (search-path %load-path "guix.scm")) (t (options->transformation `((with-source . ,s))))) - (let* ((port (open-output-string)) - (new (parameterize ((guix-warning-port port)) - (t p)))) - (and (eq? new p) - (string-contains (get-output-string port) - "had no effect"))))) + (eq? (package-source (t p)) + (package-source p)))) (test-assert "options->transformation, with-source, PKG=URI" (let* ((p (dummy-package "foo")) @@ -147,6 +142,29 @@ (define-module (test-transformations) (add-to-store store (basename s) #t "sha256" s))))))) +(test-assert "options->transformation, with-source, in depth" + (let* ((p0 (dummy-package "foo" (version "0.0"))) + (s (search-path %load-path "guix.scm")) + (f (string-append "foo@42.0=" s)) + (t (options->transformation `((with-source . ,f)))) + (p1 (dummy-package "bar" (inputs (list p0)))) + (p2 (dummy-package "baz" (inputs (list p1))))) + (with-store store + (let ((new (t p2))) + (and (not (eq? new p2)) + (match (package-inputs new) + ((("bar" p1*)) + (match (package-inputs p1*) + ((("foo" p0*)) + (and (not (eq? p0* p0)) + (string=? (package-name p0*) (package-name p0)) + (string=? (package-version p0*) "42.0") + (string=? (add-to-store store (basename s) #t + "sha256" s) + (run-with-store store + (lower-object + (package-source p0*)))))))))))))) + (test-assert "options->transformation, with-input" (let* ((p (dummy-package "guix.scm" (inputs `(("foo" ,(specification->package "coreutils")) -- cgit v1.2.3