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/packages.scm | |
| parent | 79f912c7106131f4179c727583d33500271361cd (diff) | |
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/packages.scm')
| -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 51dc1ba2b0c..930374dabfa 100644 --- a/tests/packages.scm +++ b/tests/packages.scm | |||
| @@ -886,6 +886,33 @@ | |||
| 886 | (and (build-derivations %store (list drv)) | 886 | (and (build-derivations %store (list drv)) |
| 887 | (file-exists? (string-append out "/bin/make"))))))) | 887 | (file-exists? (string-append out "/bin/make"))))))) |
| 888 | 888 | ||
| 889 | (test-equal "package-mapping" | ||
| 890 | 42 | ||
| 891 | (let* ((dep (dummy-package "chbouib" | ||
| 892 | (native-inputs `(("x" ,grep))))) | ||
| 893 | (p0 (dummy-package "example" | ||
| 894 | (inputs `(("foo" ,coreutils) | ||
| 895 | ("bar" ,grep) | ||
| 896 | ("baz" ,dep))))) | ||
| 897 | (transform (lambda (p) | ||
| 898 | (package (inherit p) (source 42)))) | ||
| 899 | (rewrite (package-mapping transform)) | ||
| 900 | (p1 (rewrite p0))) | ||
| 901 | (and (eq? p1 (rewrite p0)) | ||
| 902 | (eqv? 42 (package-source p1)) | ||
| 903 | (match (package-inputs p1) | ||
| 904 | ((("foo" dep1) ("bar" dep2) ("baz" dep3)) | ||
| 905 | (and (eq? dep1 (rewrite coreutils)) ;memoization | ||
| 906 | (eq? dep2 (rewrite grep)) | ||
| 907 | (eq? dep3 (rewrite dep)) | ||
| 908 | (eqv? 42 | ||
| 909 | (package-source dep1) (package-source dep2) | ||
| 910 | (package-source dep3)) | ||
| 911 | (match (package-native-inputs dep3) | ||
| 912 | ((("x" dep)) | ||
| 913 | (and (eq? dep (rewrite grep)) | ||
| 914 | (package-source dep)))))))))) | ||
| 915 | |||
| 889 | (test-assert "package-input-rewriting" | 916 | (test-assert "package-input-rewriting" |
| 890 | (let* ((dep (dummy-package "chbouib" | 917 | (let* ((dep (dummy-package "chbouib" |
| 891 | (native-inputs `(("x" ,grep))))) | 918 | (native-inputs `(("x" ,grep))))) |
