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