Commit | Line | Data |
---|---|---|
afbc9419 RW |
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) | |
6f918d69 | 23 | #:use-module (guix tests http) |
afbc9419 RW |
24 | #:use-module (guix build utils) |
25 | #:use-module (srfi srfi-1) | |
26 | #:use-module (srfi srfi-64) | |
27 | #:use-module (srfi srfi-26) | |
6f918d69 | 28 | #:use-module (web client) |
afbc9419 RW |
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 | ||
6f918d69 LC |
72 | ;; Avoid collisions with other tests. |
73 | (%http-server-port 10200) | |
74 | ||
afbc9419 RW |
75 | (test-equal "fetch-sxml: returns SXML for valid XML" |
76 | sxml | |
6f918d69 LC |
77 | (with-http-server `((200 ,xml)) |
78 | (parameterize ((current-http-proxy (%local-url))) | |
79 | (fetch-sxml "foo")))) | |
afbc9419 RW |
80 | |
81 | ;; TODO: | |
82 | (test-assert "sxml->package" | |
83 | ;; Replace network resources with sample data. | |
84 | (mock ((guix build svn) svn-fetch | |
85 | (lambda* (url revision directory | |
86 | #:key (svn-command "svn") | |
87 | (user-name #f) | |
88 | (password #f)) | |
89 | (mkdir-p directory) | |
90 | (with-output-to-file (string-append directory "/foo") | |
91 | (lambda () | |
92 | (display "source"))))) | |
6f918d69 | 93 | (let ((result (sxml->package sxml))) |
afbc9419 RW |
94 | (match result |
95 | (('package | |
96 | ('name "texlive-latex-foo") | |
97 | ('version "2.6a") | |
98 | ('source ('origin | |
99 | ('method 'svn-fetch) | |
100 | ('uri ('texlive-ref "latex" "foo")) | |
101 | ('sha256 | |
102 | ('base32 | |
103 | (? string? hash))))) | |
104 | ('build-system 'texlive-build-system) | |
105 | ('arguments ('quote (#:tex-directory "latex/foo"))) | |
106 | ('home-page "http://www.ctan.org/pkg/foo") | |
107 | ('synopsis "Foomatic frobnication in LuaLaTeX") | |
108 | ('description | |
109 | "Foo is a package for LuaLaTeX. It provides an interface to \ | |
110 | frobnicate gimbals in a foomatic way with the LuaTeX engine. The package \ | |
111 | requires the bar and golly bundles for extremely special specialties.") | |
112 | ('license 'lppl1.3+)) | |
113 | #t) | |
114 | (_ | |
115 | (begin | |
116 | (format #t "~s\n" result) | |
117 | (pk 'fail result #f))))))) | |
118 | ||
119 | (test-end "texlive") |