diff options
| author | Nicolas Graves <ngraves@ngraves.fr> | 2025-09-17 01:03:44 +0200 |
|---|---|---|
| committer | Ludovic Courtès <ludo@gnu.org> | 2025-10-01 11:04:16 +0200 |
| commit | 7a41349bed30d03032ee249d43dc64de5cefdd84 (patch) | |
| tree | 868f0bf411fc659e588f69e92f3c663c4cf3d1df /tests/import | |
| parent | 02f1ff69c647daa150cbff9d93fee25a6b43e152 (diff) | |
import: cran: Move tests to tests/import/cran.scm.
* tests/cran.scm: Move to tests/import/cran.scm.
* Makefile.am: Refresh it.
* CODEOWNERS: Refresh it.
* etc/teams.scm: Refresh it.
Signed-off-by: Ludovic Courtès <ludo@gnu.org>
Diffstat (limited to 'tests/import')
| -rw-r--r-- | tests/import/cran.scm | 137 |
1 files changed, 137 insertions, 0 deletions
diff --git a/tests/import/cran.scm b/tests/import/cran.scm new file mode 100644 index 00000000000..5c820b1ab32 --- /dev/null +++ b/tests/import/cran.scm | |||
| @@ -0,0 +1,137 @@ | |||
| 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> | ||
| 4 | ;;; | ||
| 5 | ;;; This file is part of GNU Guix. | ||
| 6 | ;;; | ||
| 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. | ||
| 11 | ;;; | ||
| 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. | ||
| 16 | ;;; | ||
| 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/>. | ||
| 19 | |||
| 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)) | ||
| 28 | |||
| 29 | (define description " | ||
| 30 | Package: My-Example | ||
| 31 | Type: Package | ||
| 32 | Title: Example package | ||
| 33 | Version: 1.2.3 | ||
| 34 | Date: 2015-12-10 | ||
| 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 this line is very long or perhaps the fact that | ||
| 40 | there is a colon : on the lines. | ||
| 41 | And: this line continues the description. | ||
| 42 | biocViews: 0 | ||
| 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 | ||
| 46 | later will be fine. | ||
| 47 | License: GPL (>= 3) | ||
| 48 | Imports: Rcpp (>= 0.11.5), proto, Scales | ||
| 49 | LinkingTo: Rcpp, BH | ||
| 50 | NeedsCompilation: yes | ||
| 51 | Repository: CRAN | ||
| 52 | Date/Publication: 2015-07-14 14:15:16 | ||
| 53 | ") | ||
| 54 | |||
| 55 | (define description-alist | ||
| 56 | (description->alist description)) | ||
| 57 | |||
| 58 | (define simple-alist | ||
| 59 | '(("Key" . "Value") | ||
| 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"))) | ||
| 63 | |||
| 64 | (test-begin "cran") | ||
| 65 | |||
| 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" | ||
| 72 | "Date/Publication"))) | ||
| 73 | (lset= string=? keys (map car description-alist)))) | ||
| 74 | |||
| 75 | (test-equal "listifyx: return empty list if key cannot be found" | ||
| 76 | '() | ||
| 77 | ((@@ (guix import cran) listify) simple-alist "Letters")) | ||
| 78 | |||
| 79 | (test-equal "listify: split comma-separated value into elements" | ||
| 80 | '("R" "Rcpp" "something" "whatever") | ||
| 81 | ((@@ (guix import cran) listify) simple-alist "SimpleList")) | ||
| 82 | |||
| 83 | (test-equal "listify: strip off parentheses" | ||
| 84 | '("R" "BH" "GenomicRanges") | ||
| 85 | ((@@ (guix import cran) listify) simple-alist "List")) | ||
| 86 | |||
| 87 | (test-equal "listify: ignore values that are no lists" | ||
| 88 | '() | ||
| 89 | ((@@ (guix import cran) listify) simple-alist "BadList")) | ||
| 90 | |||
| 91 | (test-equal "r-mininal is not a cran package" | ||
| 92 | #f | ||
| 93 | ((@@ (guix import cran) cran-package?) r-minimal)) | ||
| 94 | |||
| 95 | (test-assert "description->package" | ||
| 96 | ;; Replace network resources with sample data. | ||
| 97 | (mock ((guix build download) url-fetch | ||
| 98 | (lambda* (url file-name | ||
| 99 | #:key | ||
| 100 | (mirrors '()) verify-certificate?) | ||
| 101 | (with-output-to-file file-name | ||
| 102 | (lambda () | ||
| 103 | (display | ||
| 104 | (match url | ||
| 105 | ("mirror://cran/src/contrib/My-Example_1.2.3.tar.gz" | ||
| 106 | "source") | ||
| 107 | (_ (error "Unexpected URL: " url)))))))) | ||
| 108 | (match (description->package 'cran description-alist) | ||
| 109 | (('package | ||
| 110 | ('name "r-my-example") | ||
| 111 | ('version "1.2.3") | ||
| 112 | ('source ('origin | ||
| 113 | ('method 'url-fetch) | ||
| 114 | ('uri ('cran-uri "My-Example" 'version)) | ||
| 115 | ('sha256 | ||
| 116 | ('base32 | ||
| 117 | (? string? hash))))) | ||
| 118 | ('properties ('quasiquote (('upstream-name . "My-Example")))) | ||
| 119 | ('build-system 'r-build-system) | ||
| 120 | ('inputs ('list 'cairo)) | ||
| 121 | ('propagated-inputs | ||
| 122 | ('list 'r-bh 'r-proto 'r-rcpp 'r-scales)) | ||
| 123 | ('home-page "http://gnu.org/s/my-example") | ||
| 124 | ('synopsis "Example package") | ||
| 125 | ('description | ||
| 126 | "\ | ||
| 127 | This is a long description spanning multiple lines: and it could confuse the | ||
| 128 | parser that this line is very long or perhaps the fact that there is a colon : | ||
| 129 | on the lines. And: this line continues the description.") | ||
| 130 | ('license 'gpl3+)) | ||
| 131 | #t) | ||
| 132 | (x | ||
| 133 | (begin | ||
| 134 | (format #t "~s\n" x) | ||
| 135 | (pk 'fail x #f)))))) | ||
| 136 | |||
| 137 | (test-end "cran") | ||
