1 ;;; GNU Guix --- Functional package management for GNU
2 ;;; Copyright © 2015 Ricardo Wurmus <rekado@elephly.net>
3 ;;; Copyright © 2017 Mathieu Othacehe <m.othacehe@gmail.com>
5 ;;; This file is part of GNU Guix.
7 ;;; GNU Guix is free software; you can redistribute it and/or modify it
8 ;;; under the terms of the GNU General Public License as published by
9 ;;; the Free Software Foundation; either version 3 of the License, or (at
10 ;;; your option) any later version.
12 ;;; GNU Guix is distributed in the hope that it will be useful, but
13 ;;; WITHOUT ANY WARRANTY; without even the implied warranty of
14 ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 ;;; GNU General Public License for more details.
17 ;;; You should have received a copy of the GNU General Public License
18 ;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
20 (define-module (test-cran)
21 #:use-module (gnu packages statistics)
22 #:use-module (guix import cran)
23 #:use-module (guix tests)
24 #:use-module (srfi srfi-1)
25 #:use-module (srfi srfi-64)
26 #:use-module (srfi srfi-26)
27 #:use-module (ice-9 match))
32 Title: Example package
35 Author: Ricardo Wurmus
36 Maintainer: Guix Schmeeks <guix@gnu.org>
37 URL: http://gnu.org/s/my-example
38 Description: This is a long description
39 spanning multiple lines: and it could confuse the parser that
40 there is a colon : on the lines.
41 And: this line continues the description.
43 SystemRequirements: Cairo (>= 0)
44 Depends: A C++11 compiler. Version 4.6.* of g++ (as
45 currently in Rtools) is insufficient; versions 4.8.*, 4.9.* or
48 Imports: Rcpp (>= 0.11.5), proto, Scales
52 Date/Publication: 2015-07-14 14:15:16
55 (define description-alist
56 ((@@ (guix import cran) description->alist) description))
60 ("SimpleList" . "R, Rcpp, something, whatever")
61 ("BadList" . "This is not a real list, you know?")
62 ("List" . "R (>= 2.2), BH (for no reason), GenomicRanges")))
66 (test-assert "description->alist: contains all valid keys"
67 (let ((keys '("Package" "Type" "Title" "Version" "Date"
68 "Author" "Maintainer" "URL" "Description"
69 "SystemRequirements" "Depends" "License"
70 "Imports" "biocViews" "LinkingTo"
71 "NeedsCompilation" "Repository"
73 (lset= string=? keys (map car description-alist))))
75 (test-equal "listify: return empty list if key cannot be found"
77 ((@@ (guix import cran) listify) simple-alist "Letters"))
79 (test-equal "listify: split comma-separated value into elements"
80 '("R" "Rcpp" "something" "whatever")
81 ((@@ (guix import cran) listify) simple-alist "SimpleList"))
83 (test-equal "listify: strip off parentheses"
84 '("R" "BH" "GenomicRanges")
85 ((@@ (guix import cran) listify) simple-alist "List"))
87 (test-equal "listify: ignore values that are no lists"
89 ((@@ (guix import cran) listify) simple-alist "BadList"))
91 (test-equal "r-mininal is not a cran package"
93 ((@@ (guix import cran) cran-package?) r-minimal))
95 (test-assert "description->package"
96 ;; Replace network resources with sample data.
97 (mock ((guix build download) url-fetch
98 (lambda* (url file-name
100 (mirrors '()) verify-certificate?)
101 (with-output-to-file file-name
105 ("mirror://cran/src/contrib/My-Example_1.2.3.tar.gz"
107 (_ (error "Unexpected URL: " url))))))))
108 (match ((@@ (guix import cran) description->package) 'cran description-alist)
110 ('name "r-my-example")
114 ('uri ('cran-uri "My-Example" 'version))
118 ('properties ('quasiquote (('upstream-name . "My-Example"))))
119 ('build-system 'r-build-system)
122 (("cairo" ('unquote 'cairo)))))
125 (("r-bh" ('unquote 'r-bh))
126 ("r-proto" ('unquote 'r-proto))
127 ("r-rcpp" ('unquote 'r-rcpp))
128 ("r-scales" ('unquote 'r-scales)))))
129 ('home-page "http://gnu.org/s/my-example")
130 ('synopsis "Example package")
132 "This is a long description spanning multiple lines: \
133 and it could confuse the parser that there is a colon : on the \
134 lines. And: this line continues the description.")