summaryrefslogtreecommitdiff
path: root/tests/transformations.scm
diff options
context:
space:
mode:
authorLudovic Courtès <ludovic.courtes@inria.fr>2022-09-23 19:04:29 +0200
committerLudovic Courtès <ludo@gnu.org>2022-09-29 22:59:49 +0200
commit28ade1bab207974cce6a014e7187968511fc5526 (patch)
treee0a79545d3460fca04a72c31083f2e74e4c5af53 /tests/transformations.scm
parent1bf18818c66fbdd329211e18c85ccd310fa74890 (diff)
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.
Diffstat (limited to 'tests/transformations.scm')
-rw-r--r--tests/transformations.scm32
1 files changed, 25 insertions, 7 deletions
diff --git a/tests/transformations.scm b/tests/transformations.scm
index dbfe5235188..47b1fc650dd 100644
--- a/tests/transformations.scm
+++ b/tests/transformations.scm
@@ -103,16 +103,11 @@
103 "sha256" f)))))))))) 103 "sha256" f))))))))))
104 104
105(test-assert "options->transformation, with-source, no matches" 105(test-assert "options->transformation, with-source, no matches"
106 ;; When a transformation in not applicable, a warning must be raised.
107 (let* ((p (dummy-package "foobar")) 106 (let* ((p (dummy-package "foobar"))
108 (s (search-path %load-path "guix.scm")) 107 (s (search-path %load-path "guix.scm"))
109 (t (options->transformation `((with-source . ,s))))) 108 (t (options->transformation `((with-source . ,s)))))
110 (let* ((port (open-output-string)) 109 (eq? (package-source (t p))
111 (new (parameterize ((guix-warning-port port)) 110 (package-source p))))
112 (t p))))
113 (and (eq? new p)
114 (string-contains (get-output-string port)
115 "had no effect")))))
116 111
117(test-assert "options->transformation, with-source, PKG=URI" 112(test-assert "options->transformation, with-source, PKG=URI"
118 (let* ((p (dummy-package "foo")) 113 (let* ((p (dummy-package "foo"))
@@ -147,6 +142,29 @@
147 (add-to-store store (basename s) #t 142 (add-to-store store (basename s) #t
148 "sha256" s))))))) 143 "sha256" s)))))))
149 144
145(test-assert "options->transformation, with-source, in depth"
146 (let* ((p0 (dummy-package "foo" (version "0.0")))
147 (s (search-path %load-path "guix.scm"))
148 (f (string-append "foo@42.0=" s))
149 (t (options->transformation `((with-source . ,f))))
150 (p1 (dummy-package "bar" (inputs (list p0))))
151 (p2 (dummy-package "baz" (inputs (list p1)))))
152 (with-store store
153 (let ((new (t p2)))
154 (and (not (eq? new p2))
155 (match (package-inputs new)
156 ((("bar" p1*))
157 (match (package-inputs p1*)
158 ((("foo" p0*))
159 (and (not (eq? p0* p0))
160 (string=? (package-name p0*) (package-name p0))
161 (string=? (package-version p0*) "42.0")
162 (string=? (add-to-store store (basename s) #t
163 "sha256" s)
164 (run-with-store store
165 (lower-object
166 (package-source p0*))))))))))))))
167
150(test-assert "options->transformation, with-input" 168(test-assert "options->transformation, with-input"
151 (let* ((p (dummy-package "guix.scm" 169 (let* ((p (dummy-package "guix.scm"
152 (inputs `(("foo" ,(specification->package "coreutils")) 170 (inputs `(("foo" ,(specification->package "coreutils"))