| 1 | ;;; GNU Guix --- Functional package management for GNU |
| 2 | ;;; Copyright © 2012, 2013, 2015 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 (srfi srfi-1) |
| 22 | #:use-module (srfi srfi-64) |
| 23 | #:use-module (ice-9 match)) |
| 24 | |
| 25 | (define %nixpkgs-directory |
| 26 | (getenv "NIXPKGS")) |
| 27 | |
| 28 | (define factorize-uri |
| 29 | (@@ (guix import snix) factorize-uri)) |
| 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 | |
| 48 | (test-skip (if (and %nixpkgs-directory |
| 49 | (file-exists? (string-append %nixpkgs-directory |
| 50 | "/default.nix"))) |
| 51 | 0 |
| 52 | 1)) |
| 53 | |
| 54 | (test-assert "nixpkgs->guix-package" |
| 55 | (match (nixpkgs->guix-package %nixpkgs-directory "guile") |
| 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?)) |
| 66 | ('license (? symbol?))) |
| 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") |