From 69f132554c6bd23df4610a21e636bde5f0578174 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ludovic=20Court=C3=A8s?= Date: Wed, 15 Jan 2020 18:05:26 +0100 Subject: import: cpan: Rewrite to use 'define-json-mapping'. * guix/import/cpan.scm (, ): New JSON-mapped record types. (metacpan-url->mirror-url): New procedure. (cpan-source-url): Rewrite in terms of it. (cpan-version): Remove. (cpan-module->sexp): Rewrite to take a instead of an alist, and rename 'meta' to 'release'. [convert-inputs]: Rewrite to use 'cpan-release-dependencies'. Update calls to 'convert-inputs' to pass a list of symbols. Replace 'assoc-ref' calls with the appropriate field accessors. (cpan->guix-package): Rename 'module-meta' to 'release'. (latest-release): Likewise, and use the appropriate accessors. * tests/cpan.scm (test-json): Remove "prereqs" record; add "dependency" list. ("source-url-http", "source-url-https"): Remove. ("metacpan-url->mirror-url, http") ("metacpan-url->mirror-url, https"): New tests. --- tests/cpan.scm | 33 ++++++++++++++++----------------- 1 file changed, 16 insertions(+), 17 deletions(-) (limited to 'tests') diff --git a/tests/cpan.scm b/tests/cpan.scm index 189dd027e6..043d401032 100644 --- a/tests/cpan.scm +++ b/tests/cpan.scm @@ -1,6 +1,7 @@ ;;; GNU Guix --- Functional package management for GNU ;;; Copyright © 2015 Eric Bavier ;;; Copyright © 2016 Alex Sassmannshausen +;;; Copyright © 2020 Ludovic Courtès ;;; ;;; This file is part of GNU Guix. ;;; @@ -32,13 +33,6 @@ (define test-json "{ \"metadata\" : { - \"prereqs\" : { - \"runtime\" : { - \"requires\" : { - \"Test::Script\" : \"1.05\", - } - } - } \"name\" : \"Foo-Bar\", \"version\" : \"0.1\" } @@ -47,6 +41,13 @@ \"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\", @@ -107,16 +108,14 @@ (x (pk 'fail x #f)))))) -(test-equal "source-url-http" - ((@@ (guix import cpan) cpan-source-url) - `(("download_url" . - "http://cpan.metacpan.org/authors/id/T/TE/TEST/Foo-Bar-0.1.tar.gz"))) - "mirror://cpan/authors/id/T/TE/TEST/Foo-Bar-0.1.tar.gz") +(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 "source-url-https" - ((@@ (guix import cpan) cpan-source-url) - `(("download_url" . - "https://cpan.metacpan.org/authors/id/T/TE/TEST/Foo-Bar-0.1.tar.gz"))) - "mirror://cpan/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") -- cgit v1.2.3