;;; GNU Guix --- Functional package management for GNU ;;; Copyright © 2015 Eric Bavier <bavier@member.fsf.org> ;;; Copyright © 2016 Alex Sassmannshausen <alex@pompo.co> ;;; Copyright © 2020, 2023 Ludovic Courtès <ludo@gnu.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 upstream) #:use-module ((guix download) #:select (url-fetch)) #:use-module (gcrypt hash) #:use-module (guix tests) #:use-module (guix tests http) #:use-module ((guix store) #:select (%graft?)) #:use-module (srfi srfi-64) #:use-module (web client) #:use-module (ice-9 match)) ;; Globally disable grafts because they can trigger early builds. (%graft? #f) (define test-json "{ \"metadata\" : { \"name\" : \"Foo-Bar\", \"version\" : \"0.1\" } \"name\" : \"Foo-Bar-0.1\", \"distribution\" : \"Foo-Bar\", \"license\" : [ \"perl_5\" ], \"dependency\": [ { \"relationship\": \"requires\", \"phase\": \"runtime\", \"version\": \"1.05\", \"module\": \"Test::Script\" } ], \"abstract\" : \"Fizzle Fuzz\", \"download_url\" : \"http://example.com/Foo-Bar-0.1.tar.gz\", \"author\" : \"Guix\", \"version\" : \"0.1\" }") (define test-source "foobar") ;; Avoid collisions with other tests. (%http-server-port 10400) (test-begin "cpan") (test-assert "cpan->guix-package" (with-http-server `((200 ,test-json) (200 ,test-source) (200 "{ \"distribution\" : \"Test-Script\" }")) (parameterize ((%metacpan-base-url (%local-url)) (current-http-proxy (%local-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) (propagated-inputs (list perl-test-script)) (home-page "https://metacpan.org/release/Foo-Bar") (synopsis "Fizzle Fuzz") (description fill-in-yourself!) (license perl-license)) (string=? (bytevector->nix-base32-string (call-with-input-string test-source port-sha256)) hash)) (x (pk 'fail x #f)))))) (test-equal "package-latest-release" (list '("http://example.com/Foo-Bar-0.1.tar.gz") #f (list (upstream-input (name "Test-Script") (downstream-name "perl-test-script") (type 'propagated)))) (with-http-server `((200 ,test-json) (200 "{ \"distribution\" : \"Test-Script\" }") (200 ,test-source)) (parameterize ((%metacpan-base-url (%local-url)) (current-http-proxy (%local-url))) (define source (package-latest-release (dummy-package "perl-test-script" (version "0.0.0") (source (dummy-origin (method url-fetch) (uri "mirror://cpan/Foo-Bar-0.0.0.tgz")))) (list %cpan-updater))) (list (upstream-source-urls source) (upstream-source-signature-urls source) (upstream-source-inputs source))))) (test-equal "metacpan-url->mirror-url, http" "mirror://cpan/authors/id/T/TE/TEST/Foo-Bar-0.1.tar.gz" (metacpan-url->mirror-url "http://cpan.metacpan.org/authors/id/T/TE/TEST/Foo-Bar-0.1.tar.gz")) (test-equal "metacpan-url->mirror-url, https" "mirror://cpan/authors/id/T/TE/TEST/Foo-Bar-0.1.tar.gz" (metacpan-url->mirror-url "https://cpan.metacpan.org/authors/id/T/TE/TEST/Foo-Bar-0.1.tar.gz")) (test-end "cpan")
ut/tests/channels.scm?id=821aa687b439f509bec124f14e529d6da756132c'>about -rw-r--r--combinators.scm3045logplainabout -rw-r--r--containers.scm10924logplainabout -rw-r--r--cpan.scm3659logplainabout -rw-r--r--cpio.scm3154logplainabout -rw-r--r--cran.scm4994logplainabout -rw-r--r--crate.scm15560logplainabout -rw-r--r--cve-sample.json46446logplainabout -rw-r--r--cve.scm3672logplainabout -rw-r--r--debug-link.scm6709logplainabout -rw-r--r--derivations.scm62328logplainabout -rw-r--r--discovery.scm2540logplainabout -rw-r--r--elpa.scm2850logplainabout -rw-r--r--file-systems.scm2686logplainabout -rw-r--r--gem.scm6473logplainabout -rw-r--r--gexp.scm61752logplainabout -rw-r--r--git.scm5068logplainabout -rw-r--r--glob.scm2331logplainabout -rw-r--r--gnu-maintenance.scm1688logplainabout -rw-r--r--grafts.scm22364logplainabout -rw-r--r--graph.scm17011logplainabout -rw-r--r--gremlin.scm3478logplainabout -rw-r--r--guix-archive.sh2855logplainabout -rw-r--r--guix-authenticate.sh2963logplainabout -rw-r--r--guix-build-branch.sh2222logplainabout -rw-r--r--guix-build.sh9999logplainabout -rw-r--r--guix-daemon.sh8336logplainabout -rw-r--r--guix-describe.sh1405logplainabout -rw-r--r--guix-download.sh1593logplainabout -rw-r--r--guix-environment-container.sh5741logplainabout -rw-r--r--guix-environment.sh8861logplainabout -rw-r--r--guix-gc.sh2819logplainabout -rw-r--r--guix-graph.sh2627logplainabout -rw-r--r--guix-hash.sh2266logplainabout -rw-r--r--guix-lint.sh2579logplainabout -rw-r--r--guix-pack-localstatedir.sh2565logplainabout -rw-r--r--guix-pack-relocatable.sh3289logplainabout -rw-r--r--guix-pack.sh4629logplainabout -rw-r--r--guix-package-aliases.sh1927logplainabout -rw-r--r--guix-package-net.sh7277logplainabout -rw-r--r--guix-package.sh15437logplainabout -rw-r--r--guix-system.sh9523logplainabout -rw-r--r--hackage.scm10660logplainabout -rw-r--r--import-utils.scm6173logplainabout -rw-r--r--inferior.scm10268logplainabout -rw-r--r--lint.scm37909logplainabout -rw-r--r--lzlib.scm4749logplainabout -rw-r--r--modules.scm2582logplainabout -rw-r--r--monads.scm9099logplainabout -rw-r--r--nar.scm21502logplainabout -rw-r--r--networking.scm4056logplainabout -rw-r--r--opam.scm7629logplainabout -rw-r--r--pack.scm10180logplainabout -rw-r--r--packages.scm58680logplainabout -rw-r--r--pki.scm5220logplainabout -rw-r--r--print.scm2561logplainabout -rw-r--r--processes.scm4691logplainabout -rw-r--r--profiles.scm28633logplainabout -rw-r--r--publish.scm25948logplainabout -rw-r--r--pypi.scm13645logplainabout -rw-r--r--records.scm15123logplainabout -rw-r--r--scripts-build.scm12015logplainabout -rw-r--r--scripts.scm2034logplainabout -rw-r--r--search-paths.scm1768logplainabout -rw-r--r--services.scm11536logplainabout -rw-r--r--sets.scm1507logplainabout -rw-r--r--signing-key.pub302logplainabout -rw-r--r--signing-key.sec983logplainabout -rw-r--r--size.scm4576logplainabout -rw-r--r--snix.scm2504logplainabout -rw-r--r--status.scm12235logplainabout -rw-r--r--store-database.scm3718logplainabout -rw-r--r--store-deduplication.scm4533logplainabout -rw-r--r--store-roots.scm1899logplainabout -rw-r--r--store.scm50694logplainabout -rw-r--r--substitute.scm21770logplainabout -rw-r--r--swh.scm3834logplainabout -rw-r--r--syscalls.scm19724logplainabout -rw-r--r--system.scm5143logplainabout -rw-r--r--test.drv5922logplainabout -rw-r--r--texlive.scm4493logplainabout -rw-r--r--ui.scm8859logplainabout -rw-r--r--union.scm9714logplainabout -rw-r--r--upstream.scm1963logplainabout -rw-r--r--utils.scm9783logplainabout -rw-r--r--uuid.scm2755logplainabout -rw-r--r--workers.scm2172logplainabout -rw-r--r--zlib.scm2237logplainabout