1 ;;; GNU Guix --- Functional package management for GNU
2 ;;; Copyright © 2016 Ludovic Courtès <ludo@gnu.org>
3 ;;; Copyright © 2022 Ricardo Wurmus <rekado@elephly.net>
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-upstream)
21 #:use-module (gnu packages base)
22 #:use-module (guix download)
23 #:use-module (guix packages)
24 #:use-module (guix build-system gnu)
25 #:use-module (guix import print)
26 #:use-module ((guix licenses) #:prefix license:)
27 #:use-module (guix upstream)
28 #:use-module (guix tests)
29 #:use-module (srfi srfi-64)
30 #:use-module (ice-9 match))
33 (test-begin "upstream")
35 ;; FIXME: Temporarily skipping this test; see <https://bugs.gnu.org/34229>.
38 (test-equal "coalesce-sources same version"
39 (list (upstream-source
40 (package "foo") (version "1")
41 (urls '("ftp://example.org/foo-1.tar.xz"
42 "ftp://example.org/foo-1.tar.gz"))
43 (signature-urls '("ftp://example.org/foo-1.tar.xz.sig"
44 "ftp://example.org/foo-1.tar.gz.sig"))))
46 (coalesce-sources (list (upstream-source
47 (package "foo") (version "1")
48 (urls '("ftp://example.org/foo-1.tar.gz"))
50 '("ftp://example.org/foo-1.tar.gz.sig")))
52 (package "foo") (version "1")
53 (urls '("ftp://example.org/foo-1.tar.xz"))
55 '("ftp://example.org/foo-1.tar.xz.sig"))))))
63 (uri (string-append "mirror://gnu/hello/hello-" version
67 "0ssi1wpaf7plaswqqjwigppsg5fyh99vdlb9kzl7c9lng89ndq1i"))))
68 (build-system gnu-build-system)
76 (home-page "http://localhost")
79 (license license:gpl3+)))
81 (define test-package-sexp
87 (uri (string-append "mirror://gnu/hello/hello-" version
91 "0ssi1wpaf7plaswqqjwigppsg5fyh99vdlb9kzl7c9lng89ndq1i"))))
92 (build-system gnu-build-system)
100 (home-page "http://localhost")
103 (license license:gpl3+)))
105 (test-equal "changed-inputs returns no changes"
107 (changed-inputs test-package test-package-sexp))
109 (test-assert "changed-inputs returns changes to labelled input list"
110 (let ((changes (changed-inputs
112 (inherit test-package)
113 (inputs `(("hello" ,hello)
117 ;; Exactly one change
118 (((? upstream-input-change? item))
119 (and (equal? (upstream-input-change-type item)
121 (equal? (upstream-input-change-action item)
123 (string=? (upstream-input-change-name item)
125 (else (pk else #false)))))
127 (test-assert "changed-inputs returns changes to all labelled input lists"
128 (let ((changes (changed-inputs
130 (inherit test-package)
133 (propagated-inputs '()))
136 (((? upstream-input-change? items) ...)
137 (and (equal? (map upstream-input-change-type items)
138 '(regular native native propagated))
139 (equal? (map upstream-input-change-action items)
141 (equal? (map upstream-input-change-name items)
142 '("hello" "sed" "tar" "grep"))))
143 (else (pk else #false)))))
145 (define test-new-package
147 (inherit test-package)
155 (define test-new-package-sexp
161 (uri (string-append "mirror://gnu/hello/hello-" version
165 "0ssi1wpaf7plaswqqjwigppsg5fyh99vdlb9kzl7c9lng89ndq1i"))))
166 (build-system gnu-build-system)
173 (home-page "http://localhost")
176 (license license:gpl3+)))
178 (test-assert "changed-inputs returns changes to plain input list"
179 (let ((changes (changed-inputs
181 (inherit test-new-package)
182 (inputs (list hello sed)))
183 test-new-package-sexp)))
185 ;; Exactly one change
186 (((? upstream-input-change? item))
187 (and (equal? (upstream-input-change-type item)
189 (equal? (upstream-input-change-action item)
191 (string=? (upstream-input-change-name item)
193 (else (pk else #false)))))
195 (test-assert "changed-inputs returns changes to all plain input lists"
196 (let ((changes (changed-inputs
198 (inherit test-new-package)
201 (propagated-inputs '()))
202 test-new-package-sexp)))
204 (((? upstream-input-change? items) ...)
205 (and (equal? (map upstream-input-change-type items)
206 '(regular native native propagated))
207 (equal? (map upstream-input-change-action items)
209 (equal? (map upstream-input-change-name items)
210 '("hello" "sed" "tar" "grep"))))
211 (else (pk else #false)))))