From c3fbaee34548fbfb1617dc7fccc94c598efbd7a6 Mon Sep 17 00:00:00 2001 From: Lars-Dominik Braun Date: Sun, 22 May 2022 10:56:01 +0200 Subject: import: cabal: Support library names * guix/import/cabal.scm (make-cabal-parser): Add name to section. (is-lib): Add optional name to regular expression. (lex-rx-res): Support selecting different substring. (lex-lib): Match 2nd substring from IS-LIB. (lex-line): Adapt to changes for lex-lib. (cabal-library): Add name field and export CABAL-LIBRARY-NAME. (eval): Remove special case for 'library, which is not required any more. (make-cabal-section): Move special case for LIBRARY. * tests/hackage.scm (test-read-cabal-library-name): New variable. ("read-cabal test 1"): Adapt testcase to changed internal structure. ("read-cabal test: library name"): New testcase. --- tests/hackage.scm | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) (limited to 'tests') diff --git a/tests/hackage.scm b/tests/hackage.scm index d7ecd0cc21..85a5c2115c 100644 --- a/tests/hackage.scm +++ b/tests/hackage.scm @@ -172,6 +172,15 @@ common defaults } ") +;; Test library with (since Cabal 2.0) and without names. +(define test-read-cabal-library-name + "name: test-me +library foobar + build-depends: foo, bar +library + build-depends: bar, baz +") + (test-begin "hackage") (define-syntax-rule (define-package-matcher name pattern) @@ -507,7 +516,7 @@ executable cabal (test-assert "read-cabal test 1" (match (call-with-input-string test-read-cabal-1 read-cabal) ((("name" ("test-me")) - ('section 'library + ('section 'library #f (('if ('flag "base4point8") (("build-depends" ("base >= 4.8 && < 5"))) (('if ('flag "base4") @@ -543,6 +552,16 @@ executable cabal #t) (x (pk 'fail x #f)))) +(test-assert "read-cabal test: library name" + (match (call-with-input-string test-read-cabal-library-name read-cabal) + ((("name" ("test-me")) + ('section 'library "foobar" + (("build-depends" ("foo, bar")))) + ('section 'library #f + (("build-depends" ("bar, baz"))))) + #t) + (x (pk 'fail x #f)))) + (define test-cabal-import "name: foo version: 1.0.0 -- cgit 1.4.1