import: hackage: Evaluate "-any" and "-none" version comparison operators.
authorDanny Milosavljevic <dannym@scratchpost.org>
Thu, 12 Jul 2018 12:17:08 +0000 (14:17 +0200)
committerDanny Milosavljevic <dannym@scratchpost.org>
Thu, 12 Jul 2018 18:35:04 +0000 (20:35 +0200)
* guix/import/cabal.scm (eval-cabal): Modify.
* tests/hackage.scm (test-cabal-4): New variable and test.
(test-cabal-5): New variable and test.
(test-cabal-6): New variable and test.

guix/import/cabal.scm
tests/hackage.scm

index cd0a295..4cd09ca 100644 (file)
@@ -754,6 +754,8 @@ the ordering operation and the version."
            ((string= spec-op ">") (version>? comp-ver spec-ver))
            ((string= spec-op "<=") (not (version>? comp-ver spec-ver)))
            ((string= spec-op "<") (not (version>=? comp-ver spec-ver)))
+           ((string= spec-op "-any") #t)
+           ((string= spec-op "-none") #f)
            (else
             (raise (condition
                     (&message (message "Failed to evaluate 'impl' test."))))))
index a4de8be..e17851a 100644 (file)
@@ -69,6 +69,65 @@ library
       mtl        >= 2.0      && < 3
 ")
 
+;; Check "-any", "-none" when name is different.
+(define test-cabal-4
+  "name: foo
+version: 1.0.0
+homepage: http://test.org
+synopsis: synopsis
+description: description
+license: BSD3
+library
+  if impl(ghcjs -any)
+    Build-depends: ghc-a
+  if impl(ghc>=7.2&&<7.6)
+    Build-depends: ghc-b
+  if impl(ghc == 7.8)
+    Build-depends: 
+      HTTP       >= 4000.2.5 && < 4000.3,
+      mtl        >= 2.0      && < 3
+")
+
+;; Check "-any", "-none".
+(define test-cabal-5
+  "name: foo
+version: 1.0.0
+homepage: http://test.org
+synopsis: synopsis
+description: description
+license: BSD3
+library
+  if impl(ghc == 7.8)
+    Build-depends: 
+      HTTP       >= 4000.2.5 && < 4000.3,
+  if impl(ghc -any)
+    Build-depends: mtl        >= 2.0      && < 3
+  if impl(ghc>=7.2&&<7.6)
+    Build-depends: ghc-b
+")
+
+;; Check "custom-setup".
+(define test-cabal-6
+  "name: foo
+build-type: Custom
+version: 1.0.0
+homepage: http://test.org
+synopsis: synopsis
+description: description
+license: BSD3
+custom-setup
+  setup-depends: base >= 4.7 && < 5,
+                 Cabal >= 1.24,
+                 haskell-gi == 0.21.*
+library
+  if impl(ghc>=7.2&&<7.6)
+    Build-depends: ghc-b
+  if impl(ghc == 7.8)
+    Build-depends: 
+      HTTP       >= 4000.2.5 && < 4000.3,
+      mtl        >= 2.0      && < 3
+")
+
 ;; A fragment of a real Cabal file with minor modification to check precedence
 ;; of 'and' over 'or', missing final newline, spaces between keywords and
 ;; parentheses and between key and column.
@@ -139,6 +198,18 @@ library
   (eval-test-with-cabal test-cabal-3
                         #:cabal-environment '(("impl" . "ghc-7.8"))))
 
+(test-assert "hackage->guix-package test 4"
+  (eval-test-with-cabal test-cabal-4
+                        #:cabal-environment '(("impl" . "ghc-7.8"))))
+
+(test-assert "hackage->guix-package test 5"
+  (eval-test-with-cabal test-cabal-5
+                        #:cabal-environment '(("impl" . "ghc-7.8"))))
+
+(test-assert "hackage->guix-package test 6"
+  (eval-test-with-cabal test-cabal-6
+                        #:cabal-environment '(("impl" . "ghc-7.8"))))
+
 (test-assert "read-cabal test 1"
   (match (call-with-input-string test-read-cabal-1 read-cabal)
     ((("name" ("test-me"))