1 ;;; GNU Guix --- Functional package management for GNU
2 ;;; Copyright © 2021 Xinglu Chen <public@yoctocell.xyz>
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-eggs)
20 #:use-module (guix import egg)
21 #:use-module (guix gexp)
22 #:use-module (guix base32)
23 #:use-module (gcrypt hash)
24 #:use-module (guix tests)
25 #:use-module ((guix build syscalls) #:select (mkdtemp!))
26 #:use-module ((guix build utils) #:select (delete-file-recursively mkdir-p which))
27 #:use-module ((guix utils) #:select (call-with-temporary-output-file))
28 #:use-module (srfi srfi-1)
29 #:use-module (srfi srfi-64)
30 #:use-module (web uri)
31 #:use-module (ice-9 match))
34 '((synopsis "Example egg")
37 (test-dependencies test srfi-1)
38 (foreign-dependencies libgit2)
39 (build-dependencies begin-syntax)
40 (dependencies datatype)
44 '((synopsis "Example egg")
47 (test-dependencies test)
48 (foreign-dependencies libgit2)
49 (build-dependencies begin-syntax)
50 (dependencies datatype)
51 (author "Alice Bobson")))
53 (define test-egg-1-file "/tmp/guix-egg-1")
54 (define test-egg-2-file "/tmp/guix-egg-2")
58 (test-equal "guix-package->egg-name"
60 (guix-package->egg-name
61 (dummy-package "dummy"
62 (name "chicken-bar"))))
64 ;; Copied from tests/hackage.scm
65 (define-syntax-rule (define-package-matcher name pattern)
69 (x (pk 'fail x #f)))))
71 (define (eval-test-with-egg-file egg-name egg-test egg-file matcher)
72 (call-with-output-file egg-file
74 (write egg-test port)))
75 (matcher (egg->guix-package egg-name
78 (string-append egg-name "-egg")
81 (define-package-matcher match-chicken-foo
85 ('source (? file-like? source))
86 ('build-system 'chicken-build-system)
87 ('arguments ('quasiquote ('#:egg-name "foo")))
90 (("chicken-test" ('unquote chicken-test))
91 ("chicken-srfi-1" ('unquote chicken-srfi-1))
92 ("chicken-begin-syntax" ('unquote chicken-begin-syntax)))))
95 (("libgit2" ('unquote libgit2)))))
98 (("chicken-datatype" ('unquote chicken-datatype)))))
99 ('home-page "https://wiki.call-cc.org/egg/foo")
100 ('synopsis "Example egg")
102 ('license '(list license:gpl3 license:expat))))
104 (define-package-matcher match-chicken-bar
106 ('name "chicken-bar")
108 ('source (? file-like? source))
109 ('build-system 'chicken-build-system)
110 ('arguments ('quasiquote ('#:egg-name "bar")))
113 (("chicken-test" ('unquote chicken-test))
114 ("chicken-begin-syntax" ('unquote chicken-begin-syntax)))))
117 (("libgit2" ('unquote libgit2)))))
120 (("chicken-datatype" ('unquote chicken-datatype)))))
121 ('home-page "https://wiki.call-cc.org/egg/bar")
122 ('synopsis "Example egg")
124 ('license 'license:gpl3+)))
126 (test-assert "egg->guix-package local file, multiple licenses"
127 (eval-test-with-egg-file "foo" test-egg-1 test-egg-1-file match-chicken-foo))
129 (test-assert "egg->guix-package local file, single license"
130 (eval-test-with-egg-file "bar" test-egg-2 test-egg-2-file match-chicken-bar))