import: Add PyPI importer.
[jackhill/guix/guix.git] / tests / snix.scm
1 ;;; GNU Guix --- Functional package management for GNU
2 ;;; Copyright © 2012, 2013 Ludovic Courtès <ludo@gnu.org>
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-snix)
20 #:use-module (guix import snix)
21 #:use-module ((guix utils) #:select (%nixpkgs-directory))
22 #:use-module (srfi srfi-1)
23 #:use-module (srfi srfi-64)
24 #:use-module (ice-9 match))
25
26 (define factorize-uri
27 (@@ (guix import snix) factorize-uri))
28
29 (define-syntax-rule (every? proc lists ...)
30 (not (not (every proc lists ...))))
31
32 (test-begin "snix")
33
34 (test-assert "factorize-uri"
35 (every? (match-lambda
36 ((uri version '-> expected)
37 (equal? (factorize-uri uri version)
38 expected)))
39 '(("http://example.com/foo.tgz" "1.0"
40 -> "http://example.com/foo.tgz")
41 ("http://example.com/foo-2.8.tgz" "2.8"
42 -> ("http://example.com/foo-" version ".tgz"))
43 ("http://example.com/2.8/foo-2.8.tgz" "2.8"
44 -> ("http://example.com/" version "/foo-" version ".tgz")))))
45
46 (test-skip (if (and (%nixpkgs-directory)
47 (file-exists? (string-append (%nixpkgs-directory)
48 "/default.nix")))
49 0
50 1))
51
52 (test-assert "nixpkgs->guix-package"
53 (match (nixpkgs->guix-package (%nixpkgs-directory) "guile")
54 (('package
55 ('name "guile")
56 ('version (? string?))
57 ('source ('origin _ ...))
58 ('build-system _)
59 ('inputs ('quasiquote (inputs ...)))
60 ('propagated-inputs ('quasiquote (pinputs ...)))
61 ('home-page (? string?))
62 ('synopsis (? string?))
63 ('description (? string?))
64 ('license (? symbol?)))
65 (and (member '("libffi" ,libffi) inputs)
66 (member '("gmp" ,gmp) pinputs)
67 #t))
68 (x
69 (pk 'fail x #f))))
70
71 (test-end "snix")
72
73 \f
74 (exit (= (test-runner-fail-count (test-runner-current)) 0))