diff options
author | Ludovic Courtès <ludo@gnu.org> | 2017-04-05 15:19:15 +0200 |
---|---|---|
committer | Ludovic Courtès <ludo@gnu.org> | 2017-04-05 22:45:41 +0200 |
commit | f37f2b83fa95c1fe2bf01c4b8072cfc23d4c67ec (patch) | |
tree | bed6bac6a29ee4575fdbf34604bd380f0d5c2ff7 /tests | |
parent | 79f912c7106131f4179c727583d33500271361cd (diff) | |
download | guix-f37f2b83fa95c1fe2bf01c4b8072cfc23d4c67ec.tar guix-f37f2b83fa95c1fe2bf01c4b8072cfc23d4c67ec.tar.gz |
packages: Add 'package-mapping' and base 'package-input-rewriting' on it.
* guix/packages.scm (package-mapping): New procedure.
(package-input-rewriting): Rewrite in terms of 'package-mapping'.
* tests/packages.scm ("package-mapping"): New test.
* doc/guix.texi (Defining Packages): Document it.
Diffstat (limited to 'tests')
-rw-r--r-- | tests/packages.scm | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/tests/packages.scm b/tests/packages.scm index 51dc1ba2b0..930374dabf 100644 --- a/tests/packages.scm +++ b/tests/packages.scm @@ -886,6 +886,33 @@ (and (build-derivations %store (list drv)) (file-exists? (string-append out "/bin/make"))))))) +(test-equal "package-mapping" + 42 + (let* ((dep (dummy-package "chbouib" + (native-inputs `(("x" ,grep))))) + (p0 (dummy-package "example" + (inputs `(("foo" ,coreutils) + ("bar" ,grep) + ("baz" ,dep))))) + (transform (lambda (p) + (package (inherit p) (source 42)))) + (rewrite (package-mapping transform)) + (p1 (rewrite p0))) + (and (eq? p1 (rewrite p0)) + (eqv? 42 (package-source p1)) + (match (package-inputs p1) + ((("foo" dep1) ("bar" dep2) ("baz" dep3)) + (and (eq? dep1 (rewrite coreutils)) ;memoization + (eq? dep2 (rewrite grep)) + (eq? dep3 (rewrite dep)) + (eqv? 42 + (package-source dep1) (package-source dep2) + (package-source dep3)) + (match (package-native-inputs dep3) + ((("x" dep)) + (and (eq? dep (rewrite grep)) + (package-source dep)))))))))) + (test-assert "package-input-rewriting" (let* ((dep (dummy-package "chbouib" (native-inputs `(("x" ,grep))))) |