1 ;;; GNU Guix --- Functional package management for GNU
2 ;;; Copyright © 2021 Xinglu Chen <public@yoctocell.xyz>
3 ;;; Copyright © 2021 Sarah Morgensen <iskarian@mgsn.dev>
5 ;;; This file is part of GNU Guix.
7 ;;; GNU Guix is free software; you can redistribute it and/or modify it
8 ;;; under the terms of the GNU General Public License as published by
9 ;;; the Free Software Foundation; either version 3 of the License, or (at
10 ;;; your option) any later version.
12 ;;; GNU Guix is distributed in the hope that it will be useful, but
13 ;;; WITHOUT ANY WARRANTY; without even the implied warranty of
14 ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 ;;; GNU General Public License for more details.
17 ;;; You should have received a copy of the GNU General Public License
18 ;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
20 (define-module (test-eggs)
21 #:use-module (guix import egg)
22 #:use-module (guix gexp)
23 #:use-module (guix base32)
24 #:use-module (gcrypt hash)
25 #:use-module (guix tests)
26 #:use-module ((guix build syscalls) #:select (mkdtemp!))
27 #:use-module ((guix build utils) #:select (delete-file-recursively mkdir-p which))
28 #:use-module ((guix utils) #:select (call-with-temporary-output-file))
29 #:use-module (srfi srfi-1)
30 #:use-module (srfi srfi-64)
31 #:use-module (web uri)
32 #:use-module (ice-9 match))
35 '((synopsis "Example egg")
38 (test-dependencies test srfi-1)
39 (foreign-dependencies libgit2)
40 (build-dependencies begin-syntax)
41 (dependencies datatype)
45 '((synopsis "Example egg")
48 (test-dependencies test)
49 (foreign-dependencies libgit2)
50 (build-dependencies begin-syntax)
51 (dependencies datatype)
52 (author "Alice Bobson")))
54 (define test-egg-1-file "/tmp/guix-egg-1")
55 (define test-egg-2-file "/tmp/guix-egg-2")
59 (test-equal "guix-package->egg-name"
61 (guix-package->egg-name
62 (dummy-package "dummy"
63 (name "chicken-bar"))))
65 ;; Copied from tests/hackage.scm
66 (define-syntax-rule (define-package-matcher name pattern)
70 (x (pk 'fail x #f)))))
72 (define (eval-test-with-egg-file egg-name egg-test egg-file matcher)
73 (call-with-output-file egg-file
75 (write egg-test port)))
76 (matcher (egg->guix-package egg-name
79 (string-append egg-name "-egg")
82 (define-package-matcher match-chicken-foo
86 ('source (? file-like? source))
87 ('build-system 'chicken-build-system)
88 ('arguments ('quasiquote ('#:egg-name "foo")))
90 ('list 'chicken-test 'chicken-srfi-1 'chicken-begin-syntax))
91 ('inputs ('list 'libgit2))
92 ('propagated-inputs ('list 'chicken-datatype))
93 ('home-page "https://wiki.call-cc.org/egg/foo")
94 ('synopsis "Example egg")
96 ('license '(list license:gpl3 license:expat))))
98 (define-package-matcher match-chicken-bar
100 ('name "chicken-bar")
102 ('source (? file-like? source))
103 ('build-system 'chicken-build-system)
104 ('arguments ('quasiquote ('#:egg-name "bar")))
105 ('native-inputs ('list 'chicken-test 'chicken-begin-syntax))
106 ('inputs ('list 'libgit2))
107 ('propagated-inputs ('list 'chicken-datatype))
108 ('home-page "https://wiki.call-cc.org/egg/bar")
109 ('synopsis "Example egg")
111 ('license 'license:gpl3+)))
113 (test-assert "egg->guix-package local file, multiple licenses"
114 (eval-test-with-egg-file "foo" test-egg-1 test-egg-1-file match-chicken-foo))
116 (test-assert "egg->guix-package local file, single license"
117 (eval-test-with-egg-file "bar" test-egg-2 test-egg-2-file match-chicken-bar))