aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDanny Milosavljevic <dannym@scratchpost.org>2018-07-12 14:17:08 +0200
committerDanny Milosavljevic <dannym@scratchpost.org>2018-07-12 20:35:04 +0200
commite39a44f34010e4439fc3fc4925b3f26b7ca6d719 (patch)
tree9b7f421cc46d3a6be4067622f4c5e7703ec8aa9d
parentfd115bee31d04f1277560b82bb982e6aa19fc977 (diff)
downloadgnu-guix-e39a44f34010e4439fc3fc4925b3f26b7ca6d719.tar
gnu-guix-e39a44f34010e4439fc3fc4925b3f26b7ca6d719.tar.gz
import: hackage: Evaluate "-any" and "-none" version comparison operators.
* 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.
-rw-r--r--guix/import/cabal.scm2
-rw-r--r--tests/hackage.scm71
2 files changed, 73 insertions, 0 deletions
diff --git a/guix/import/cabal.scm b/guix/import/cabal.scm
index cd0a2953c6..4cd09cac29 100644
--- a/guix/import/cabal.scm
+++ b/guix/import/cabal.scm
@@ -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."))))))
diff --git a/tests/hackage.scm b/tests/hackage.scm
index a4de8be91e..e17851a213 100644
--- a/tests/hackage.scm
+++ b/tests/hackage.scm
@@ -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"))