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