1
0
mirror of https://git.savannah.gnu.org/git/guix.git synced 2026-05-22 17:16:01 +02:00

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.
This commit is contained in:
Ludovic Courtès
2022-10-01 16:56:19 +02:00
parent 79b390a207
commit b6bc4c109b
2 changed files with 46 additions and 1 deletions
+7
View File
@@ -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")))))