texlive.scm 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  1. ;;; GNU Guix --- Functional package management for GNU
  2. ;;; Copyright © 2017 Ricardo Wurmus <rekado@elephly.net>
  3. ;;;
  4. ;;; This file is part of GNU Guix.
  5. ;;;
  6. ;;; GNU Guix is free software; you can redistribute it and/or modify it
  7. ;;; under the terms of the GNU General Public License as published by
  8. ;;; the Free Software Foundation; either version 3 of the License, or (at
  9. ;;; your option) any later version.
  10. ;;;
  11. ;;; GNU Guix is distributed in the hope that it will be useful, but
  12. ;;; WITHOUT ANY WARRANTY; without even the implied warranty of
  13. ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. ;;; GNU General Public License for more details.
  15. ;;;
  16. ;;; You should have received a copy of the GNU General Public License
  17. ;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
  18. (define-module (test-texlive)
  19. #:use-module (gnu packages tex)
  20. #:use-module (guix import texlive)
  21. #:use-module (guix tests)
  22. #:use-module (guix build utils)
  23. #:use-module (srfi srfi-1)
  24. #:use-module (srfi srfi-64)
  25. #:use-module (srfi srfi-26)
  26. #:use-module (ice-9 match))
  27. (test-begin "texlive")
  28. (define xml
  29. "\
  30. <entry id=\"foo\">
  31. <name>foo</name>
  32. <caption>Foomatic frobnication in LuaLaTeX</caption>
  33. <authorref id=\"rekado\"/>
  34. <license type=\"lppl1.3\"/>
  35. <version number=\"2.6a\"/>
  36. <description>
  37. <p>
  38. Foo is a package for LuaLaTeX. It provides an interface to frobnicate gimbals
  39. in a foomatic way with the LuaTeX engine.
  40. </p>
  41. <p>
  42. The package requires the bar and golly
  43. bundles for extremely special specialties.
  44. </p>
  45. </description>
  46. <ctan path=\"/macros/latex/contrib/foo\" file=\"true\"/>
  47. <texlive location=\"foo\"/>
  48. <keyval key=\"topic\" value=\"tests\"/>
  49. null
  50. </entry>")
  51. (define sxml
  52. '(*TOP* (entry (@ (id "foo"))
  53. (name "foo")
  54. (caption "Foomatic frobnication in LuaLaTeX")
  55. (authorref (@ (id "rekado")))
  56. (license (@ (type "lppl1.3")))
  57. (version (@ (number "2.6a")))
  58. (description
  59. (p "\n Foo is a package for LuaLaTeX. It provides an interface to frobnicate gimbals\n in a foomatic way with the LuaTeX engine.\n ")
  60. (p "\n The package requires the bar and golly\n bundles for extremely special specialties.\n "))
  61. (ctan (@ (path "/macros/latex/contrib/foo") (file "true")))
  62. (texlive (@ (location "foo")))
  63. (keyval (@ (value "tests") (key "topic")))
  64. "\n null\n")))
  65. (test-equal "fetch-sxml: returns SXML for valid XML"
  66. sxml
  67. (mock ((guix http-client) http-fetch
  68. (lambda (url)
  69. xml))
  70. ((@@ (guix import texlive) fetch-sxml) "foo")))
  71. ;; TODO:
  72. (test-assert "sxml->package"
  73. ;; Replace network resources with sample data.
  74. (mock ((guix build svn) svn-fetch
  75. (lambda* (url revision directory
  76. #:key (svn-command "svn")
  77. (user-name #f)
  78. (password #f))
  79. (mkdir-p directory)
  80. (with-output-to-file (string-append directory "/foo")
  81. (lambda ()
  82. (display "source")))))
  83. (let ((result ((@@ (guix import texlive) sxml->package) sxml)))
  84. (match result
  85. (('package
  86. ('name "texlive-latex-foo")
  87. ('version "2.6a")
  88. ('source ('origin
  89. ('method 'svn-fetch)
  90. ('uri ('texlive-ref "latex" "foo"))
  91. ('sha256
  92. ('base32
  93. (? string? hash)))))
  94. ('build-system 'texlive-build-system)
  95. ('arguments ('quote (#:tex-directory "latex/foo")))
  96. ('home-page "http://www.ctan.org/pkg/foo")
  97. ('synopsis "Foomatic frobnication in LuaLaTeX")
  98. ('description
  99. "Foo is a package for LuaLaTeX. It provides an interface to \
  100. frobnicate gimbals in a foomatic way with the LuaTeX engine. The package \
  101. requires the bar and golly bundles for extremely special specialties.")
  102. ('license 'lppl1.3+))
  103. #t)
  104. (_
  105. (begin
  106. (format #t "~s\n" result)
  107. (pk 'fail result #f)))))))
  108. (test-end "texlive")