1 ;;; GNU Guix --- Functional package management for GNU
2 ;;; Copyright © 2015 Eric Bavier <bavier@member.fsf.org>
4 ;;; This file is part of GNU Guix.
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.
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.
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/>.
19 (define-module (test-cpan)
20 #:use-module (guix import cpan)
21 #:use-module (guix base32)
22 #:use-module (guix hash)
23 #:use-module (guix tests)
24 #:use-module (guix grafts)
25 #:use-module (srfi srfi-64)
26 #:use-module (ice-9 match))
28 ;; Globally disable grafts because they can trigger early builds.
37 \"Test::Script\" : \"1.05\",
41 \"name\" : \"Foo-Bar\",
44 \"name\" : \"Foo-Bar-0.1\",
45 \"distribution\" : \"Foo-Bar\",
49 \"abstract\" : \"Fizzle Fuzz\",
50 \"download_url\" : \"http://example.com/Foo-Bar-0.1.tar.gz\",
51 \"author\" : \"Guix\",
60 (test-assert "cpan->guix-package"
61 ;; Replace network resources with sample data.
62 (mock ((guix build download) url-fetch
63 (lambda* (url file-name #:key (mirrors '()))
64 (with-output-to-file file-name
68 ("http://api.metacpan.org/release/Foo-Bar"
70 ("http://api.metacpan.org/module/Test::Script"
71 "{ \"distribution\" : \"Test-Script\" }")
72 ("http://example.com/Foo-Bar-0.1.tar.gz"
74 (_ (error "Unexpected URL: " url))))))))
75 (match (cpan->guix-package "Foo::Bar")
77 ('name "perl-foo-bar")
81 ('uri ('string-append "http://example.com/Foo-Bar-"
86 ('build-system 'perl-build-system)
89 (("perl-test-script" ('unquote 'perl-test-script)))))
90 ('home-page "http://search.cpan.org/dist/Foo-Bar")
91 ('synopsis "Fizzle Fuzz")
92 ('description 'fill-in-yourself!)
93 ('license (package-license perl)))
94 (string=? (bytevector->nix-base32-string
95 (call-with-input-string test-source port-sha256))