guix: Add elm-build-system.
[jackhill/guix/guix.git] / tests / elm.scm
CommitLineData
aefcfdd0
PM
1;;; GNU Guix --- Functional package management for GNU
2;;; Copyright © 2022 Philip McGrath <philip@philipmcgrath.com>
3;;;
4;;; This file is part of GNU Guix.
5;;;
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.
10;;;
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.
15;;;
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/>.
18
19(define-module (test-elm)
20 #:use-module (guix build-system elm)
21 #:use-module (srfi srfi-64))
22
23(test-begin "elm")
24
25(test-group "elm->package-name and infer-elm-package-name"
26 (test-group "round trip"
27 ;; Cases when our heuristics can find the upstream name.
28 (define-syntax-rule (test-round-trip elm guix)
29 (test-group elm
30 (test-equal "elm->package-name" guix
31 (elm->package-name elm))
32 (test-equal "infer-elm-package-name" elm
33 (infer-elm-package-name guix))))
34 (test-round-trip "elm/core" "elm-core")
35 (test-round-trip "elm/html" "elm-html")
36 (test-round-trip "elm-explorations/markdown" "elm-explorations-markdown")
37 (test-round-trip "elm-explorations/test" "elm-explorations-test")
38 (test-round-trip "elm-explorations/foo-bar" "elm-explorations-foo-bar")
39 (test-round-trip "elm/explorations" "elm-explorations")
40 (test-round-trip "terezka/intervals" "elm-terezka-intervals")
41 (test-round-trip "justinmimbs/time-extra" "elm-justinmimbs-time-extra")
42 (test-round-trip "danhandrea/elm-date-format"
43 "elm-danhandrea-elm-date-format"))
44 (test-group "upstream-name needed"
45 ;; Upstream names that our heuristic can't infer. We still check that the
46 ;; round-trip behavior of 'infer-elm-package-name' works as promised for
47 ;; the hypothetical Elm name it doesn't infer.
48 (define-syntax-rule (test-upstream-needed elm guix inferred)
49 (test-group elm
50 (test-equal "elm->package-name" guix
51 (elm->package-name elm))
52 (test-group "infer-elm-package-name"
53 (test-equal "infers other name" inferred
54 (infer-elm-package-name guix))
55 (test-equal "infered name round-trips" guix
56 (elm->package-name inferred)))))
57 (test-upstream-needed "elm/virtual-dom"
58 "elm-virtual-dom"
59 "virtual/dom")
60 (test-upstream-needed "elm/project-metadata-utils"
61 "elm-project-metadata-utils"
62 "project/metadata-utils")
63 (test-upstream-needed "explorations/foo"
64 "elm-explorations-foo"
65 "elm-explorations/foo")
66 (test-upstream-needed "explorations/foo-bar"
67 "elm-explorations-foo-bar"
68 "elm-explorations/foo-bar")
69 (test-upstream-needed "explorations-central/foo"
70 "elm-explorations-central-foo"
71 "elm-explorations/central-foo")
72 (test-upstream-needed "explorations-central/foo-bar"
73 "elm-explorations-central-foo-bar"
74 "elm-explorations/central-foo-bar")
75 (test-upstream-needed "elm-xyz/foo"
76 "elm-xyz-foo"
77 "xyz/foo")
78 (test-upstream-needed "elm-xyz/foo-bar"
79 "elm-xyz-foo-bar"
80 "xyz/foo-bar")
81 (test-upstream-needed "elm-explorations-xyz/foo"
82 "elm-explorations-xyz-foo"
83 "elm-explorations/xyz-foo")
84 (test-upstream-needed "elm-explorations-xyz/foo-bar"
85 "elm-explorations-xyz-foo-bar"
86 "elm-explorations/xyz-foo-bar"))
87 (test-group "no inferred Elm name"
88 ;; Cases that 'infer-elm-package-name' should not attempt to handle,
89 ;; because 'elm->package-name' would never produce such names.
90 (define-syntax-rule (test-not-inferred guix)
91 (test-assert guix (not (infer-elm-package-name guix))))
92 (test-not-inferred "elm")
93 (test-not-inferred "guile")
94 (test-not-inferred "gcc-toolchain")
95 (test-not-inferred "font-adobe-source-sans-pro")))
96
97(test-end "elm")