gnu: linux-libre@5.4: Update to 5.4.66.
[jackhill/guix/guix.git] / tests / snix.scm
CommitLineData
233e7676 1;;; GNU Guix --- Functional package management for GNU
f073e523 2;;; Copyright © 2012, 2013, 2015 Ludovic Courtès <ludo@gnu.org>
10226c05 3;;;
233e7676 4;;; This file is part of GNU Guix.
10226c05 5;;;
233e7676 6;;; GNU Guix is free software; you can redistribute it and/or modify it
10226c05
LC
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;;;
233e7676 11;;; GNU Guix is distributed in the hope that it will be useful, but
10226c05
LC
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
233e7676 17;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
10226c05
LC
18
19(define-module (test-snix)
1b3e9685 20 #:use-module (guix import snix)
10226c05
LC
21 #:use-module (srfi srfi-1)
22 #:use-module (srfi srfi-64)
23 #:use-module (ice-9 match))
24
f073e523
LC
25(define %nixpkgs-directory
26 (getenv "NIXPKGS"))
27
10226c05 28(define factorize-uri
1b3e9685 29 (@@ (guix import snix) factorize-uri))
10226c05
LC
30
31(define-syntax-rule (every? proc lists ...)
32 (not (not (every proc lists ...))))
33
34(test-begin "snix")
35
36(test-assert "factorize-uri"
37 (every? (match-lambda
38 ((uri version '-> expected)
39 (equal? (factorize-uri uri version)
40 expected)))
41 '(("http://example.com/foo.tgz" "1.0"
42 -> "http://example.com/foo.tgz")
43 ("http://example.com/foo-2.8.tgz" "2.8"
44 -> ("http://example.com/foo-" version ".tgz"))
45 ("http://example.com/2.8/foo-2.8.tgz" "2.8"
46 -> ("http://example.com/" version "/foo-" version ".tgz")))))
47
f073e523
LC
48(test-skip (if (and %nixpkgs-directory
49 (file-exists? (string-append %nixpkgs-directory
10226c05
LC
50 "/default.nix")))
51 0
52 1))
53
54(test-assert "nixpkgs->guix-package"
f073e523 55 (match (nixpkgs->guix-package %nixpkgs-directory "guile")
10226c05
LC
56 (('package
57 ('name "guile")
58 ('version (? string?))
59 ('source ('origin _ ...))
60 ('build-system _)
61 ('inputs ('quasiquote (inputs ...)))
62 ('propagated-inputs ('quasiquote (pinputs ...)))
63 ('home-page (? string?))
64 ('synopsis (? string?))
65 ('description (? string?))
ad85c617 66 ('license (? symbol?)))
10226c05
LC
67 (and (member '("libffi" ,libffi) inputs)
68 (member '("gmp" ,gmp) pinputs)
69 #t))
70 (x
71 (pk 'fail x #f))))
72
73(test-end "snix")