aboutsummaryrefslogtreecommitdiff
path: root/tests/packages.scm
diff options
context:
space:
mode:
authorLudovic Courtès <ludo@gnu.org>2022-10-01 16:56:19 +0200
committerLudovic Courtès <ludo@gnu.org>2022-10-10 11:16:07 +0200
commitb6bc4c109b807c646e99ec40360e681122d85b2c (patch)
tree02afbe98458dd5c23e057dbacb433d77d8072457 /tests/packages.scm
parent79b390a207adc70a1169c80e52c590d8b358f488 (diff)
downloadguix-b6bc4c109b807c646e99ec40360e681122d85b2c.tar
guix-b6bc4c109b807c646e99ec40360e681122d85b2c.tar.gz
packages: Raise an exception for invalid 'license' values.
This is written in such a way that the type check turns into a no-op at macro-expansion time for trivial cases: > ,optimize (validate-license gpl3+) $18 = gpl3+ > ,optimize (validate-license (list gpl3+ gpl2+)) $19 = (list gpl3+ gpl2+) * guix/packages.scm (valid-license-value?, validate-license): New macros. (<package>)[license]: Add 'sanitize' option. (&package-license-error): New error condition type. * tests/packages.scm ("license type checking"): New test.
Diffstat (limited to 'tests/packages.scm')
-rw-r--r--tests/packages.scm7
1 files changed, 7 insertions, 0 deletions
diff --git a/tests/packages.scm b/tests/packages.scm
index 6cbc34ba0b..dc03b13417 100644
--- a/tests/packages.scm
+++ b/tests/packages.scm
@@ -94,6 +94,13 @@
(write
(dummy-package "foo" (location #f)))))))
+(test-equal "license type checking"
+ 'bad-license
+ (guard (c ((package-license-error? c)
+ (package-error-invalid-license c)))
+ (dummy-package "foo"
+ (license 'bad-license))))
+
(test-assert "hidden-package"
(and (hidden-package? (hidden-package (dummy-package "foo")))
(not (hidden-package? (dummy-package "foo")))))