diff options
| author | Nicolas Graves <ngraves@ngraves.fr> | 2025-09-17 00:48:51 +0200 |
|---|---|---|
| committer | Ludovic Courtès <ludo@gnu.org> | 2025-10-01 11:00:36 +0200 |
| commit | bf468f4b700a32b2c2c58fd0d2113c0f05c5cdff (patch) | |
| tree | eb1a343cb08e89cc8809c8d10f083529e3dbad2e /tests/import | |
| parent | d4fda72d8f991fa2102fe2ef121dbade2d322382 (diff) | |
import: egg: Move tests to tests/import/egg.scm.
* tests/egg.scm: Move to tests/import/egg.scm.
* Makefile.am: Refresh it.
Signed-off-by: Ludovic Courtès <ludo@gnu.org>
Diffstat (limited to 'tests/import')
| -rw-r--r-- | tests/import/egg.scm | 120 |
1 files changed, 120 insertions, 0 deletions
diff --git a/tests/import/egg.scm b/tests/import/egg.scm new file mode 100644 index 00000000000..c74f9546836 --- /dev/null +++ b/tests/import/egg.scm | |||
| @@ -0,0 +1,120 @@ | |||
| 1 | ;;; GNU Guix --- Functional package management for GNU | ||
| 2 | ;;; Copyright © 2021 Xinglu Chen <public@yoctocell.xyz> | ||
| 3 | ;;; Copyright © 2021 Sarah Morgensen <iskarian@mgsn.dev> | ||
| 4 | ;;; | ||
| 5 | ;;; This file is part of GNU Guix. | ||
| 6 | ;;; | ||
| 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. | ||
| 11 | ;;; | ||
| 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. | ||
| 16 | ;;; | ||
| 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/>. | ||
| 19 | |||
| 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) | ||
| 28 | #:select (delete-file-recursively mkdir-p which | ||
| 29 | call-with-temporary-output-file)) | ||
| 30 | #:use-module (srfi srfi-1) | ||
| 31 | #:use-module (srfi srfi-64) | ||
| 32 | #:use-module (web uri) | ||
| 33 | #:use-module (ice-9 match)) | ||
| 34 | |||
| 35 | (define test-egg-1 | ||
| 36 | '((synopsis "Example egg") | ||
| 37 | (license "GPL-3/MIT") | ||
| 38 | (version "1.0.0") | ||
| 39 | (test-dependencies test srfi-1) | ||
| 40 | (foreign-dependencies libgit2) | ||
| 41 | (build-dependencies begin-syntax) | ||
| 42 | (dependencies datatype) | ||
| 43 | (author "John Doe"))) | ||
| 44 | |||
| 45 | (define test-egg-2 | ||
| 46 | '((synopsis "Example egg") | ||
| 47 | (license "GPL-3+") | ||
| 48 | (version "0.3") | ||
| 49 | (test-dependencies test) | ||
| 50 | (foreign-dependencies libgit2) | ||
| 51 | (build-dependencies begin-syntax) | ||
| 52 | (dependencies datatype) | ||
| 53 | (author "Alice Bobson"))) | ||
| 54 | |||
| 55 | (define test-egg-1-file "/tmp/guix-egg-1") | ||
| 56 | (define test-egg-2-file "/tmp/guix-egg-2") | ||
| 57 | |||
| 58 | (test-begin "egg") | ||
| 59 | |||
| 60 | (test-equal "guix-package->egg-name" | ||
| 61 | "bar" | ||
| 62 | (guix-package->egg-name | ||
| 63 | (dummy-package "dummy" | ||
| 64 | (name "chicken-bar")))) | ||
| 65 | |||
| 66 | ;; Copied from tests/hackage.scm | ||
| 67 | (define-syntax-rule (define-package-matcher name pattern) | ||
| 68 | (define* (name obj) | ||
| 69 | (match obj | ||
| 70 | (pattern #t) | ||
| 71 | (x (pk 'fail x #f))))) | ||
| 72 | |||
| 73 | (define (eval-test-with-egg-file egg-name egg-test egg-file matcher) | ||
| 74 | (call-with-output-file egg-file | ||
| 75 | (lambda (port) | ||
| 76 | (write egg-test port))) | ||
| 77 | (matcher (egg->guix-package egg-name #f | ||
| 78 | #:file egg-file | ||
| 79 | #:source (plain-file | ||
| 80 | (string-append egg-name "-egg") | ||
| 81 | "content")))) | ||
| 82 | |||
| 83 | (define-package-matcher match-chicken-foo | ||
| 84 | ('package | ||
| 85 | ('name "chicken-foo") | ||
| 86 | ('version "1.0.0") | ||
| 87 | ('source (? file-like? source)) | ||
| 88 | ('build-system 'chicken-build-system) | ||
| 89 | ('arguments ('quasiquote ('#:egg-name "foo"))) | ||
| 90 | ('native-inputs | ||
| 91 | ('list 'chicken-test 'chicken-srfi-1 'chicken-begin-syntax)) | ||
| 92 | ('inputs ('list 'libgit2)) | ||
| 93 | ('propagated-inputs ('list 'chicken-datatype)) | ||
| 94 | ('home-page "https://wiki.call-cc.org/egg/foo") | ||
| 95 | ('synopsis "Example egg") | ||
| 96 | ('description #f) | ||
| 97 | ('license '(list license:gpl3 license:expat)))) | ||
| 98 | |||
| 99 | (define-package-matcher match-chicken-bar | ||
| 100 | ('package | ||
| 101 | ('name "chicken-bar") | ||
| 102 | ('version "0.3") | ||
| 103 | ('source (? file-like? source)) | ||
| 104 | ('build-system 'chicken-build-system) | ||
| 105 | ('arguments ('quasiquote ('#:egg-name "bar"))) | ||
| 106 | ('native-inputs ('list 'chicken-test 'chicken-begin-syntax)) | ||
| 107 | ('inputs ('list 'libgit2)) | ||
| 108 | ('propagated-inputs ('list 'chicken-datatype)) | ||
| 109 | ('home-page "https://wiki.call-cc.org/egg/bar") | ||
| 110 | ('synopsis "Example egg") | ||
| 111 | ('description #f) | ||
| 112 | ('license 'license:gpl3+))) | ||
| 113 | |||
| 114 | (test-assert "egg->guix-package local file, multiple licenses" | ||
| 115 | (eval-test-with-egg-file "foo" test-egg-1 test-egg-1-file match-chicken-foo)) | ||
| 116 | |||
| 117 | (test-assert "egg->guix-package local file, single license" | ||
| 118 | (eval-test-with-egg-file "bar" test-egg-2 test-egg-2-file match-chicken-bar)) | ||
| 119 | |||
| 120 | (test-end "egg") | ||
