diff options
author | Mark H Weaver <mhw@netris.org> | 2015-01-11 09:38:49 -0500 |
---|---|---|
committer | Mark H Weaver <mhw@netris.org> | 2015-01-11 09:38:49 -0500 |
commit | 77448857311318fc9cd866afcb85ca98fccdb25b (patch) | |
tree | efed3a71d1f7b2c2cc292e7e4ba1884c4d26a9e4 /tests | |
parent | 62c155c0bcbc0d71b1bc35e966193b6e8de03246 (diff) | |
parent | 0009ed71ad288358cbc7828954b5e1a3f18fd525 (diff) | |
download | gnu-guix-77448857311318fc9cd866afcb85ca98fccdb25b.tar gnu-guix-77448857311318fc9cd866afcb85ca98fccdb25b.tar.gz |
Merge branch 'master' into core-updates
Diffstat (limited to 'tests')
-rw-r--r-- | tests/cpan.scm | 107 | ||||
-rw-r--r-- | tests/derivations.scm | 13 | ||||
-rw-r--r-- | tests/lint.scm | 1 | ||||
-rw-r--r-- | tests/pypi.scm | 11 |
4 files changed, 121 insertions, 11 deletions
diff --git a/tests/cpan.scm b/tests/cpan.scm new file mode 100644 index 0000000000..af7b36e684 --- /dev/null +++ b/tests/cpan.scm @@ -0,0 +1,107 @@ +;;; GNU Guix --- Functional package management for GNU +;;; Copyright © 2015 Eric Bavier <bavier@member.fsf.org> +;;; +;;; This file is part of GNU Guix. +;;; +;;; GNU Guix is free software; you can redistribute it and/or modify it +;;; under the terms of the GNU General Public License as published by +;;; the Free Software Foundation; either version 3 of the License, or (at +;;; your option) any later version. +;;; +;;; GNU Guix is distributed in the hope that it will be useful, but +;;; WITHOUT ANY WARRANTY; without even the implied warranty of +;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +;;; GNU General Public License for more details. +;;; +;;; You should have received a copy of the GNU General Public License +;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>. + +(define-module (test-cpan) + #:use-module (guix import cpan) + #:use-module (guix base32) + #:use-module (guix hash) + #:use-module (guix tests) + #:use-module (srfi srfi-64) + #:use-module (ice-9 match)) + +(define test-json + "{ + \"metadata\" : { + \"prereqs\" : { + \"configure\" : { + \"requires\" : { + \"ExtUtils::MakeMaker\" : \"0\", + \"Module::Build\" : \"0.28\" + } + }, + \"runtime\" : { + \"requires\" : { + \"Getopt::Std\" : \"0\", + \"Test::Script\" : \"1.05\", + } + } + } + \"name\" : \"Foo-Bar\", + \"version\" : \"0.1\" + } + \"name\" : \"Foo-Bar-0.1\", + \"distribution\" : \"Foo-Bar\", + \"license\" : [ + \"perl_5\" + ], + \"abstract\" : \"Fizzle Fuzz\", + \"download_url\" : \"http://example.com/Foo-Bar-0.1.tar.gz\", + \"author\" : \"GUIX\", + \"version\" : \"0.1\" +}") + +(define test-source + "foobar") + +(test-begin "cpan") + +(test-assert "cpan->guix-package" + ;; Replace network resources with sample data. + (mock ((guix build download) url-fetch + (lambda* (url file-name #:key (mirrors '())) + (with-output-to-file file-name + (lambda () + (display + (match url + ("http://api.metacpan.org/release/Foo-Bar" + test-json) + ("http://example.com/Foo-Bar-0.1.tar.gz" + test-source) + (_ (error "Unexpected URL: " url)))))))) + (match (cpan->guix-package "Foo::Bar") + (('package + ('name "perl-foo-bar") + ('version "0.1") + ('source ('origin + ('method 'url-fetch) + ('uri ('string-append "http://example.com/Foo-Bar-" + 'version ".tar.gz")) + ('sha256 + ('base32 + (? string? hash))))) + ('build-system 'perl-build-system) + ('native-inputs + ('quasiquote + (("perl-module-build" ('unquote 'perl-module-build))))) + ('inputs + ('quasiquote + (("perl-test-script" ('unquote 'perl-test-script))))) + ('home-page "http://search.cpan.org/dist/Foo-Bar") + ('synopsis "Fizzle Fuzz") + ('description 'fill-in-yourself!) + ('license 'gpl1+)) + (string=? (bytevector->nix-base32-string + (call-with-input-string test-source port-sha256)) + hash)) + (x + (pk 'fail x #f))))) + +(test-end "cpan") + + +(exit (= (test-runner-fail-count (test-runner-current)) 0)) diff --git a/tests/derivations.scm b/tests/derivations.scm index 4b36758c25..8e592ab6a1 100644 --- a/tests/derivations.scm +++ b/tests/derivations.scm @@ -1,5 +1,5 @@ ;;; GNU Guix --- Functional package management for GNU -;;; Copyright © 2012, 2013, 2014 Ludovic Courtès <ludo@gnu.org> +;;; Copyright © 2012, 2013, 2014, 2015 Ludovic Courtès <ludo@gnu.org> ;;; ;;; This file is part of GNU Guix. ;;; @@ -178,6 +178,14 @@ (let ((drv (derivation %store "foo-0.0" %bash '()))) (derivation-name drv))) +(test-equal "derivation-output-names" + '(("out") ("bar" "chbouib")) + (let ((drv1 (derivation %store "foo-0.0" %bash '())) + (drv2 (derivation %store "foo-0.0" %bash '() + #:outputs '("bar" "chbouib")))) + (list (derivation-output-names drv1) + (derivation-output-names drv2)))) + (test-assert "offloadable-derivation?" (and (offloadable-derivation? (derivation %store "foo" %bash '())) (not (offloadable-derivation? @@ -581,7 +589,8 @@ (derivation-prerequisites-to-build store drv)) ((build* download*) (derivation-prerequisites-to-build store drv - #:use-substitutes? #f))) + #:substitutable? + (const #f)))) (and (null? build) (equal? download (list output)) (null? download*) diff --git a/tests/lint.scm b/tests/lint.scm index 2aebbffd0a..c6931329d6 100644 --- a/tests/lint.scm +++ b/tests/lint.scm @@ -1,6 +1,7 @@ ;;; GNU Guix --- Functional package management for GNU ;;; Copyright © 2012, 2013 Cyril Roelandt <tipecaml@gmail.com> ;;; Copyright © 2014 Eric Bavier <bavier@member.fsf.org> +;;; Copyright © 2014 Ludovic Courtès <ludo@gnu.org> ;;; ;;; This file is part of GNU Guix. ;;; diff --git a/tests/pypi.scm b/tests/pypi.scm index 124c512d54..45cf7cac4f 100644 --- a/tests/pypi.scm +++ b/tests/pypi.scm @@ -20,17 +20,10 @@ #:use-module (guix import pypi) #:use-module (guix base32) #:use-module (guix hash) + #:use-module (guix tests) #:use-module (srfi srfi-64) #:use-module (ice-9 match)) -(define-syntax-rule (mock (module proc replacement) body ...) - (let* ((m (resolve-module 'module)) - (original (module-ref m 'proc))) - (dynamic-wind - (lambda () (module-set! m 'proc replacement)) - (lambda () body ...) - (lambda () (module-set! m 'proc original))))) - (define test-json "{ \"info\": { @@ -60,7 +53,7 @@ (test-assert "pypi->guix-package" ;; Replace network resources with sample data. - (mock ((guix import pypi) url-fetch + (mock ((guix import utils) url-fetch (lambda (url file-name) (with-output-to-file file-name (lambda () |