import-utils.scm 3.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. ;;; GNU Guix --- Functional package management for GNU
  2. ;;; Copyright © 2015, 2017 Ricardo Wurmus <rekado@elephly.net>
  3. ;;; Copyright © 2016 Ben Woodcroft <donttrustben@gmail.com>
  4. ;;;
  5. ;;; This file is part of GNU Guix.
  6. ;;;
  7. ;;; GNU Guix is free software; you can redistribute it and/or modify it
  8. ;;; under the terms of the GNU General Public License as published by
  9. ;;; the Free Software Foundation; either version 3 of the License, or (at
  10. ;;; your option) any later version.
  11. ;;;
  12. ;;; GNU Guix is distributed in the hope that it will be useful, but
  13. ;;; WITHOUT ANY WARRANTY; without even the implied warranty of
  14. ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15. ;;; GNU General Public License for more details.
  16. ;;;
  17. ;;; You should have received a copy of the GNU General Public License
  18. ;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
  19. (define-module (test-import-utils)
  20. #:use-module (guix tests)
  21. #:use-module (guix import utils)
  22. #:use-module ((guix licenses) #:prefix license:)
  23. #:use-module (guix packages)
  24. #:use-module (guix build-system)
  25. #:use-module (srfi srfi-64))
  26. (test-begin "import-utils")
  27. (test-equal "beautify-description: use double spacing"
  28. "This is a package. It is great. Trust me Mr. Hendrix."
  29. (beautify-description
  30. "This is a package. It is great. Trust me Mr. Hendrix."))
  31. (test-equal "beautify-description: transform fragment into sentence"
  32. "This package provides a function to establish world peace"
  33. (beautify-description "A function to establish world peace"))
  34. (test-equal "license->symbol"
  35. 'license:lgpl2.0
  36. (license->symbol license:lgpl2.0))
  37. (test-assert "alist->package with simple source"
  38. (let* ((meta '(("name" . "hello")
  39. ("version" . "2.10")
  40. ("source" .
  41. ;; Use a 'file://' URI so that we don't cause a download.
  42. ,(string-append "file://"
  43. (search-path %load-path "guix.scm")))
  44. ("build-system" . "gnu")
  45. ("home-page" . "https://gnu.org")
  46. ("synopsis" . "Say hi")
  47. ("description" . "This package says hi.")
  48. ("license" . "GPL-3.0+")))
  49. (pkg (alist->package meta)))
  50. (and (package? pkg)
  51. (license:license? (package-license pkg))
  52. (build-system? (package-build-system pkg))
  53. (origin? (package-source pkg)))))
  54. (test-assert "alist->package with explicit source"
  55. (let* ((meta '(("name" . "hello")
  56. ("version" . "2.10")
  57. ("source" . (("method" . "url-fetch")
  58. ("uri" . "mirror://gnu/hello/hello-2.10.tar.gz")
  59. ("sha256" .
  60. (("base32" .
  61. "0ssi1wpaf7plaswqqjwigppsg5fyh99vdlb9kzl7c9lng89ndq1i")))))
  62. ("build-system" . "gnu")
  63. ("home-page" . "https://gnu.org")
  64. ("synopsis" . "Say hi")
  65. ("description" . "This package says hi.")
  66. ("license" . "GPL-3.0+")))
  67. (pkg (alist->package meta)))
  68. (and (package? pkg)
  69. (license:license? (package-license pkg))
  70. (build-system? (package-build-system pkg))
  71. (origin? (package-source pkg))
  72. (equal? (origin-sha256 (package-source pkg))
  73. (base32 "0ssi1wpaf7plaswqqjwigppsg5fyh99vdlb9kzl7c9lng89ndq1i")))))
  74. (test-end "import-utils")