2015-07-24 14:49:57 +00:00
|
|
|
;;; GNU Guix --- Functional package management for GNU
|
|
|
|
;;; Copyright © 2015 Ricardo Wurmus <rekado@elephly.net>
|
2017-05-04 09:52:33 +00:00
|
|
|
;;; Copyright © 2017 Mathieu Othacehe <m.othacehe@gmail.com>
|
2015-07-24 14:49:57 +00:00
|
|
|
;;;
|
|
|
|
;;; This file is part of GNU Guix.
|
|
|
|
;;;
|
|
|
|
;;; GNU Guix is free software; you can redistribute it and/or modify it
|
|
|
|
;;; under the terms of the GNU General Public License as published by
|
|
|
|
;;; the Free Software Foundation; either version 3 of the License, or (at
|
|
|
|
;;; your option) any later version.
|
|
|
|
;;;
|
|
|
|
;;; GNU Guix is distributed in the hope that it will be useful, but
|
|
|
|
;;; WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
;;; GNU General Public License for more details.
|
|
|
|
;;;
|
|
|
|
;;; You should have received a copy of the GNU General Public License
|
|
|
|
;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
|
|
|
|
(define-module (test-cran)
|
2017-05-04 09:52:33 +00:00
|
|
|
#:use-module (gnu packages statistics)
|
2015-07-24 14:49:57 +00:00
|
|
|
#:use-module (guix import cran)
|
|
|
|
#:use-module (guix tests)
|
2015-12-03 15:12:09 +00:00
|
|
|
#:use-module (srfi srfi-1)
|
2015-07-24 14:49:57 +00:00
|
|
|
#:use-module (srfi srfi-64)
|
2015-12-03 15:12:09 +00:00
|
|
|
#:use-module (srfi srfi-26)
|
2015-07-24 14:49:57 +00:00
|
|
|
#:use-module (ice-9 match))
|
|
|
|
|
2015-12-03 15:12:09 +00:00
|
|
|
(define description "
|
|
|
|
Package: My-Example
|
|
|
|
Type: Package
|
|
|
|
Title: Example package
|
|
|
|
Version: 1.2.3
|
|
|
|
Date: 2015-12-10
|
|
|
|
Author: Ricardo Wurmus
|
|
|
|
Maintainer: Guix Schmeeks <guix@gnu.org>
|
|
|
|
URL: http://gnu.org/s/my-example
|
|
|
|
Description: This is a long description
|
|
|
|
spanning multiple lines: and it could confuse the parser that
|
|
|
|
there is a colon : on the lines.
|
|
|
|
And: this line continues the description.
|
|
|
|
biocViews: 0
|
|
|
|
SystemRequirements: Cairo (>= 0)
|
|
|
|
Depends: A C++11 compiler. Version 4.6.* of g++ (as
|
|
|
|
currently in Rtools) is insufficient; versions 4.8.*, 4.9.* or
|
|
|
|
later will be fine.
|
|
|
|
License: GPL (>= 3)
|
|
|
|
Imports: Rcpp (>= 0.11.5), proto, Scales
|
|
|
|
LinkingTo: Rcpp, BH
|
|
|
|
NeedsCompilation: yes
|
|
|
|
Repository: CRAN
|
|
|
|
Date/Publication: 2015-07-14 14:15:16
|
|
|
|
")
|
2015-07-24 14:49:57 +00:00
|
|
|
|
2015-12-03 15:12:09 +00:00
|
|
|
(define description-alist
|
2020-01-16 20:47:36 +00:00
|
|
|
(description->alist description))
|
2015-12-03 15:12:09 +00:00
|
|
|
|
|
|
|
(define simple-alist
|
|
|
|
'(("Key" . "Value")
|
|
|
|
("SimpleList" . "R, Rcpp, something, whatever")
|
|
|
|
("BadList" . "This is not a real list, you know?")
|
|
|
|
("List" . "R (>= 2.2), BH (for no reason), GenomicRanges")))
|
2015-07-24 14:49:57 +00:00
|
|
|
|
|
|
|
(test-begin "cran")
|
|
|
|
|
2015-12-03 15:12:09 +00:00
|
|
|
(test-assert "description->alist: contains all valid keys"
|
|
|
|
(let ((keys '("Package" "Type" "Title" "Version" "Date"
|
|
|
|
"Author" "Maintainer" "URL" "Description"
|
|
|
|
"SystemRequirements" "Depends" "License"
|
|
|
|
"Imports" "biocViews" "LinkingTo"
|
|
|
|
"NeedsCompilation" "Repository"
|
|
|
|
"Date/Publication")))
|
|
|
|
(lset= string=? keys (map car description-alist))))
|
2015-07-24 14:49:57 +00:00
|
|
|
|
2020-01-16 20:47:36 +00:00
|
|
|
(test-equal "listifyx: return empty list if key cannot be found"
|
2015-07-24 14:49:57 +00:00
|
|
|
'()
|
2015-12-03 15:12:09 +00:00
|
|
|
((@@ (guix import cran) listify) simple-alist "Letters"))
|
|
|
|
|
|
|
|
(test-equal "listify: split comma-separated value into elements"
|
|
|
|
'("R" "Rcpp" "something" "whatever")
|
|
|
|
((@@ (guix import cran) listify) simple-alist "SimpleList"))
|
2015-07-24 14:49:57 +00:00
|
|
|
|
2015-12-03 15:12:09 +00:00
|
|
|
(test-equal "listify: strip off parentheses"
|
|
|
|
'("R" "BH" "GenomicRanges")
|
|
|
|
((@@ (guix import cran) listify) simple-alist "List"))
|
|
|
|
|
|
|
|
(test-equal "listify: ignore values that are no lists"
|
2015-07-24 14:49:57 +00:00
|
|
|
'()
|
2015-12-03 15:12:09 +00:00
|
|
|
((@@ (guix import cran) listify) simple-alist "BadList"))
|
|
|
|
|
2017-05-04 09:52:33 +00:00
|
|
|
(test-equal "r-mininal is not a cran package"
|
|
|
|
#f
|
|
|
|
((@@ (guix import cran) cran-package?) r-minimal))
|
|
|
|
|
2015-12-03 15:12:09 +00:00
|
|
|
(test-assert "description->package"
|
2015-07-24 14:49:57 +00:00
|
|
|
;; Replace network resources with sample data.
|
|
|
|
(mock ((guix build download) url-fetch
|
2016-11-10 10:58:43 +00:00
|
|
|
(lambda* (url file-name
|
|
|
|
#:key
|
|
|
|
(mirrors '()) verify-certificate?)
|
2015-07-24 14:49:57 +00:00
|
|
|
(with-output-to-file file-name
|
|
|
|
(lambda ()
|
|
|
|
(display
|
|
|
|
(match url
|
2015-12-03 15:12:09 +00:00
|
|
|
("mirror://cran/src/contrib/My-Example_1.2.3.tar.gz"
|
2015-07-24 14:49:57 +00:00
|
|
|
"source")
|
|
|
|
(_ (error "Unexpected URL: " url))))))))
|
2020-01-16 20:47:36 +00:00
|
|
|
(match (description->package 'cran description-alist)
|
2015-07-24 14:49:57 +00:00
|
|
|
(('package
|
2015-12-03 15:12:09 +00:00
|
|
|
('name "r-my-example")
|
2015-07-24 14:49:57 +00:00
|
|
|
('version "1.2.3")
|
|
|
|
('source ('origin
|
|
|
|
('method 'url-fetch)
|
2015-12-03 15:12:09 +00:00
|
|
|
('uri ('cran-uri "My-Example" 'version))
|
2015-07-24 14:49:57 +00:00
|
|
|
('sha256
|
|
|
|
('base32
|
|
|
|
(? string? hash)))))
|
2015-12-03 15:12:09 +00:00
|
|
|
('properties ('quasiquote (('upstream-name . "My-Example"))))
|
2015-07-24 14:49:57 +00:00
|
|
|
('build-system 'r-build-system)
|
|
|
|
('inputs
|
|
|
|
('quasiquote
|
|
|
|
(("cairo" ('unquote 'cairo)))))
|
|
|
|
('propagated-inputs
|
|
|
|
('quasiquote
|
2015-12-03 15:12:09 +00:00
|
|
|
(("r-bh" ('unquote 'r-bh))
|
|
|
|
("r-proto" ('unquote 'r-proto))
|
2015-07-24 14:49:57 +00:00
|
|
|
("r-rcpp" ('unquote 'r-rcpp))
|
|
|
|
("r-scales" ('unquote 'r-scales)))))
|
2015-12-03 15:12:09 +00:00
|
|
|
('home-page "http://gnu.org/s/my-example")
|
|
|
|
('synopsis "Example package")
|
|
|
|
('description
|
|
|
|
"This is a long description spanning multiple lines: \
|
|
|
|
and it could confuse the parser that there is a colon : on the \
|
|
|
|
lines. And: this line continues the description.")
|
2017-03-08 14:22:07 +00:00
|
|
|
('license 'gpl3+))
|
|
|
|
#t)
|
2015-07-24 14:49:57 +00:00
|
|
|
(x
|
|
|
|
(begin
|
|
|
|
(format #t "~s\n" x)
|
|
|
|
(pk 'fail x #f))))))
|
|
|
|
|
|
|
|
(test-end "cran")
|