1 ;;; GNU Guix --- Functional package management for GNU
2 ;;; Copyright © 2015 Federico Beffa <beffa@fbengineering.ch>
4 ;;; This file is part of GNU Guix.
6 ;;; GNU Guix is free software; you can redistribute it and/or modify it
7 ;;; under the terms of the GNU General Public License as published by
8 ;;; the Free Software Foundation; either version 3 of the License, or (at
9 ;;; your option) any later version.
11 ;;; GNU Guix is distributed in the hope that it will be useful, but
12 ;;; WITHOUT ANY WARRANTY; without even the implied warranty of
13 ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 ;;; GNU General Public License for more details.
16 ;;; You should have received a copy of the GNU General Public License
17 ;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
19 (define-module (test-hackage)
20 #:use-module (guix import cabal)
21 #:use-module (guix import hackage)
22 #:use-module (guix tests)
23 #:use-module (srfi srfi-64)
24 #:use-module (ice-9 match))
29 homepage: http://test.org
31 description: description
35 HTTP >= 4000.2.5 && < 4000.3,
42 homepage: http://test.org
44 description: description
48 HTTP >= 4000.2.5 && < 4000.3,
53 ;; Check compiler implementation test with and without spaces.
57 homepage: http://test.org
59 description: description
62 if impl(ghc >= 7.2 && < 7.6)
64 if impl(ghc>=7.2&&<7.6)
68 HTTP >= 4000.2.5 && < 4000.3,
72 ;; Check "-any", "-none" when name is different.
76 homepage: http://test.org
78 description: description
83 if impl(ghc>=7.2&&<7.6)
87 HTTP >= 4000.2.5 && < 4000.3,
91 ;; Check "-any", "-none".
95 homepage: http://test.org
97 description: description
102 HTTP >= 4000.2.5 && < 4000.3,
104 Build-depends: mtl >= 2.0 && < 3
105 if impl(ghc>=7.2&&<7.6)
109 ;; Check "custom-setup".
114 homepage: http://test.org
116 description: description
119 setup-depends: base >= 4.7 && < 5,
123 if impl(ghc>=7.2&&<7.6)
127 HTTP >= 4000.2.5 && < 4000.3,
131 ;; A fragment of a real Cabal file with minor modification to check precedence
132 ;; of 'and' over 'or', missing final newline, spaces between keywords and
133 ;; parentheses and between key and column.
134 (define test-read-cabal-1
137 -- Choose which library versions to use.
139 Build-depends: base >= 4.8 && < 5
142 Build-depends: base >= 4 && < 4.8
145 Build-depends: base >= 3 && < 4
147 Build-depends: base < 3
148 if flag(base4point8) || flag (base4) && flag(base3)
149 Build-depends: random
150 Build-depends : containers
152 -- Modules that are always built.
154 Test.QuickCheck.Exception")
156 (test-begin "hackage")
158 (define* (eval-test-with-cabal test-cabal #:key (cabal-environment '()))
160 ((guix import hackage) hackage-fetch
161 (lambda (name-version)
162 (call-with-input-string test-cabal
164 (match (hackage->guix-package "foo" #:cabal-environment cabal-environment)
171 ('uri ('string-append
172 "https://hackage.haskell.org/package/foo/foo-"
178 ('build-system 'haskell-build-system)
181 (("ghc-http" ('unquote 'ghc-http))
182 ("ghc-mtl" ('unquote 'ghc-mtl)))))
183 ('home-page "http://test.org")
184 ('synopsis (? string?))
185 ('description (? string?))
191 (test-assert "hackage->guix-package test 1"
192 (eval-test-with-cabal test-cabal-1))
194 (test-assert "hackage->guix-package test 2"
195 (eval-test-with-cabal test-cabal-2))
197 (test-assert "hackage->guix-package test 3"
198 (eval-test-with-cabal test-cabal-3
199 #:cabal-environment '(("impl" . "ghc-7.8"))))
201 (test-assert "hackage->guix-package test 4"
202 (eval-test-with-cabal test-cabal-4
203 #:cabal-environment '(("impl" . "ghc-7.8"))))
205 (test-assert "hackage->guix-package test 5"
206 (eval-test-with-cabal test-cabal-5
207 #:cabal-environment '(("impl" . "ghc-7.8"))))
209 (test-assert "hackage->guix-package test 6"
210 (eval-test-with-cabal test-cabal-6
211 #:cabal-environment '(("impl" . "ghc-7.8"))))
213 (test-assert "read-cabal test 1"
214 (match (call-with-input-string test-read-cabal-1 read-cabal)
215 ((("name" ("test-me"))
217 (('if ('flag "base4point8")
218 (("build-depends" ("base >= 4.8 && < 5")))
219 (('if ('flag "base4")
220 (("build-depends" ("base >= 4 && < 4.8")))
221 (('if ('flag "base3")
222 (("build-depends" ("base >= 3 && < 4")))
223 (("build-depends" ("base < 3"))))))))
224 ('if ('or ('flag "base4point8")
225 ('and ('flag "base4") ('flag "base3")))
226 (("build-depends" ("random")))
228 ("build-depends" ("containers"))
229 ("exposed-modules" ("Test.QuickCheck.Exception")))))
231 (x (pk 'fail x #f))))