summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorLudovic Courtès <ludo@gnu.org>2019-03-12 21:39:48 +0100
committerLudovic Courtès <ludo@gnu.org>2019-03-17 22:55:01 +0100
commitf258d8862852db9779945658b3a3f2b8a2a4c217 (patch)
tree901dd1a5d6f2a4e254012fb8cf644f9a796772b7 /tests
parent880916ac5228b9cfd6e65ac243d17f6bd12edaf9 (diff)
packages: Add 'package-input-rewriting/spec'.
* guix/packages.scm (package-input-rewriting/spec): New procedure. * tests/packages.scm ("package-input-rewriting/spec") ("package-input-rewriting/spec, partial match"): New tests. * doc/guix.texi (Defining Packages): Document it.
Diffstat (limited to 'tests')
-rw-r--r--tests/packages.scm51
1 files changed, 51 insertions, 0 deletions
diff --git a/tests/packages.scm b/tests/packages.scm
index 4e4bffc48c7..613b2f1221c 100644
--- a/tests/packages.scm
+++ b/tests/packages.scm
@@ -981,6 +981,57 @@
981 ((("x" dep)) 981 ((("x" dep))
982 (eq? dep findutils))))))))) 982 (eq? dep findutils)))))))))
983 983
984(test-assert "package-input-rewriting/spec"
985 (let* ((dep (dummy-package "chbouib"
986 (native-inputs `(("x" ,grep)))))
987 (p0 (dummy-package "example"
988 (inputs `(("foo" ,coreutils)
989 ("bar" ,grep)
990 ("baz" ,dep)))))
991 (rewrite (package-input-rewriting/spec
992 `(("coreutils" . ,(const sed))
993 ("grep" . ,(const findutils)))))
994 (p1 (rewrite p0))
995 (p2 (rewrite p0)))
996 (and (not (eq? p1 p0))
997 (eq? p1 p2) ;memoization
998 (string=? "example" (package-name p1))
999 (match (package-inputs p1)
1000 ((("foo" dep1) ("bar" dep2) ("baz" dep3))
1001 (and (string=? (package-full-name dep1)
1002 (package-full-name sed))
1003 (string=? (package-full-name dep2)
1004 (package-full-name findutils))
1005 (string=? (package-name dep3) "chbouib")
1006 (eq? dep3 (rewrite dep)) ;memoization
1007 (match (package-native-inputs dep3)
1008 ((("x" dep))
1009 (string=? (package-full-name dep)
1010 (package-full-name findutils))))))))))
1011
1012(test-assert "package-input-rewriting/spec, partial match"
1013 (let* ((dep (dummy-package "chbouib"
1014 (version "1")
1015 (native-inputs `(("x" ,grep)))))
1016 (p0 (dummy-package "example"
1017 (inputs `(("foo" ,coreutils)
1018 ("bar" ,dep)))))
1019 (rewrite (package-input-rewriting/spec
1020 `(("chbouib@123" . ,(const sed)) ;not matched
1021 ("grep" . ,(const findutils)))))
1022 (p1 (rewrite p0)))
1023 (and (not (eq? p1 p0))
1024 (string=? "example" (package-name p1))
1025 (match (package-inputs p1)
1026 ((("foo" dep1) ("bar" dep2))
1027 (and (string=? (package-full-name dep1)
1028 (package-full-name coreutils))
1029 (eq? dep2 (rewrite dep)) ;memoization
1030 (match (package-native-inputs dep2)
1031 ((("x" dep))
1032 (string=? (package-full-name dep)
1033 (package-full-name findutils))))))))))
1034
984(test-equal "package-patched-vulnerabilities" 1035(test-equal "package-patched-vulnerabilities"
985 '(("CVE-2015-1234") 1036 '(("CVE-2015-1234")
986 ("CVE-2016-1234" "CVE-2018-4567") 1037 ("CVE-2016-1234" "CVE-2018-4567")