summary refs log tree commit diff
path: root/tests/hackage.scm
diff options
context:
space:
mode:
authorPhilip Munksgaard <philip@munksgaard.me>2021-06-18 14:48:13 +0200
committerLudovic Courtès <ludo@gnu.org>2021-06-25 15:12:05 +0200
commitdfac3e643a924ccefc997b4433a0b5c35928d657 (patch)
tree3b2d9ff4c6753b90eed90cbef63cd510d65dcf01 /tests/hackage.scm
parent7916201c4da9a29abc0ac1ef3ee80c8e3efdcf72 (diff)
downloadguix-dfac3e643a924ccefc997b4433a0b5c35928d657.tar.gz
import: hackage: Support "common" field and imports
Fixes <https://issues.guix.gnu.org/48701>.

* guix/import/cabal.scm (make-cabal-parser): Modify.
(is-common): New variable.
(lex-common): New procedure.
(is-id): Modify.
(eval-cabal): Modify.
* tests/hackage.scm ("hackage->guix-package test cabal import") New test.

Signed-off-by: Ludovic Courtès <ludo@gnu.org>
Diffstat (limited to 'tests/hackage.scm')
-rw-r--r--tests/hackage.scm42
1 files changed, 42 insertions, 0 deletions
diff --git a/tests/hackage.scm b/tests/hackage.scm
index 66a13d9881..53972fc643 100644
--- a/tests/hackage.scm
+++ b/tests/hackage.scm
@@ -388,4 +388,46 @@ executable cabal
      #t)
     (x (pk 'fail x #f))))
 
+(define test-cabal-import
+  "name: foo
+version: 1.0.0
+homepage: http://test.org
+synopsis: synopsis
+description: description
+license: BSD3
+common commons
+  build-depends:
+    HTTP       >= 4000.2.5 && < 4000.3,
+    mtl        >= 2.0      && < 3
+
+executable cabal
+  import: commons
+")
+
+(define-package-matcher match-ghc-foo-import
+  ('package
+    ('name "ghc-foo")
+    ('version "1.0.0")
+    ('source
+     ('origin
+       ('method 'url-fetch)
+       ('uri ('string-append
+              "https://hackage.haskell.org/package/foo/foo-"
+              'version
+              ".tar.gz"))
+       ('sha256
+        ('base32
+         (? string? hash)))))
+    ('build-system 'haskell-build-system)
+    ('inputs
+     ('quasiquote
+      (("ghc-http" ('unquote 'ghc-http)))))
+    ('home-page "http://test.org")
+    ('synopsis (? string?))
+    ('description (? string?))
+    ('license 'license:bsd-3)))
+
+(test-assert "hackage->guix-package test cabal import"
+  (eval-test-with-cabal test-cabal-import match-ghc-foo-import))
+
 (test-end "hackage")