texlive.scm 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  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 tests http)
  23. #:use-module (guix build utils)
  24. #:use-module (srfi srfi-1)
  25. #:use-module (srfi srfi-64)
  26. #:use-module (srfi srfi-26)
  27. #:use-module (web client)
  28. #:use-module (ice-9 match))
  29. (test-begin "texlive")
  30. (define xml
  31. "\
  32. <entry id=\"foo\">
  33. <name>foo</name>
  34. <caption>Foomatic frobnication in LuaLaTeX</caption>
  35. <authorref id=\"rekado\"/>
  36. <license type=\"lppl1.3\"/>
  37. <version number=\"2.6a\"/>
  38. <description>
  39. <p>
  40. Foo is a package for LuaLaTeX. It provides an interface to frobnicate gimbals
  41. in a foomatic way with the LuaTeX engine.
  42. </p>
  43. <p>
  44. The package requires the bar and golly
  45. bundles for extremely special specialties.
  46. </p>
  47. </description>
  48. <ctan path=\"/macros/latex/contrib/foo\" file=\"true\"/>
  49. <texlive location=\"foo\"/>
  50. <keyval key=\"topic\" value=\"tests\"/>
  51. null
  52. </entry>")
  53. (define sxml
  54. '(*TOP* (entry (@ (id "foo"))
  55. (name "foo")
  56. (caption "Foomatic frobnication in LuaLaTeX")
  57. (authorref (@ (id "rekado")))
  58. (license (@ (type "lppl1.3")))
  59. (version (@ (number "2.6a")))
  60. (description
  61. (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 ")
  62. (p "\n The package requires the bar and golly\n bundles for extremely special specialties.\n "))
  63. (ctan (@ (path "/macros/latex/contrib/foo") (file "true")))
  64. (texlive (@ (location "foo")))
  65. (keyval (@ (value "tests") (key "topic")))
  66. "\n null\n")))
  67. (test-equal "fetch-sxml: returns SXML for valid XML"
  68. sxml
  69. (with-http-server `((200 ,xml))
  70. (parameterize ((current-http-proxy (%local-url)))
  71. (fetch-sxml "foo"))))
  72. ;; TODO:
  73. (test-assert "sxml->package"
  74. ;; Replace network resources with sample data.
  75. (mock ((guix build svn) svn-fetch
  76. (lambda* (url revision directory
  77. #:key (svn-command "svn")
  78. (user-name #f)
  79. (password #f))
  80. (mkdir-p directory)
  81. (with-output-to-file (string-append directory "/foo")
  82. (lambda ()
  83. (display "source")))))
  84. (let ((result (sxml->package sxml)))
  85. (match result
  86. (('package
  87. ('name "texlive-latex-foo")
  88. ('version "2.6a")
  89. ('source ('origin
  90. ('method 'svn-fetch)
  91. ('uri ('texlive-ref "latex" "foo"))
  92. ('sha256
  93. ('base32
  94. (? string? hash)))))
  95. ('build-system 'texlive-build-system)
  96. ('arguments ('quote (#:tex-directory "latex/foo")))
  97. ('home-page "http://www.ctan.org/pkg/foo")
  98. ('synopsis "Foomatic frobnication in LuaLaTeX")
  99. ('description
  100. "Foo is a package for LuaLaTeX. It provides an interface to \
  101. frobnicate gimbals in a foomatic way with the LuaTeX engine. The package \
  102. requires the bar and golly bundles for extremely special specialties.")
  103. ('license 'lppl1.3+))
  104. #t)
  105. (_
  106. (begin
  107. (format #t "~s\n" result)
  108. (pk 'fail result #f)))))))
  109. (test-end "texlive")