upstream.scm 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214
  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>
  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. (define-module (test-upstream)
  20. #:use-module (gnu packages base)
  21. #:use-module (guix download)
  22. #:use-module (guix packages)
  23. #:use-module (guix build-system gnu)
  24. #:use-module (guix import print)
  25. #:use-module ((guix licenses) #:prefix license:)
  26. #:use-module (guix upstream)
  27. #:use-module (guix tests)
  28. #:use-module (srfi srfi-64)
  29. #:use-module (ice-9 match))
  30. (test-begin "upstream")
  31. ;; FIXME: Temporarily skipping this test; see <https://bugs.gnu.org/34229>.
  32. (test-skip 1)
  33. (test-equal "coalesce-sources same version"
  34. (list (upstream-source
  35. (package "foo") (version "1")
  36. (urls '("ftp://example.org/foo-1.tar.xz"
  37. "ftp://example.org/foo-1.tar.gz"))
  38. (signature-urls '("ftp://example.org/foo-1.tar.xz.sig"
  39. "ftp://example.org/foo-1.tar.gz.sig"))))
  40. (coalesce-sources (list (upstream-source
  41. (package "foo") (version "1")
  42. (urls '("ftp://example.org/foo-1.tar.gz"))
  43. (signature-urls
  44. '("ftp://example.org/foo-1.tar.gz.sig")))
  45. (upstream-source
  46. (package "foo") (version "1")
  47. (urls '("ftp://example.org/foo-1.tar.xz"))
  48. (signature-urls
  49. '("ftp://example.org/foo-1.tar.xz.sig"))))))
  50. (define test-package
  51. (package
  52. (name "test")
  53. (version "2.10")
  54. (source (origin
  55. (method url-fetch)
  56. (uri (string-append "mirror://gnu/hello/hello-" version
  57. ".tar.gz"))
  58. (sha256
  59. (base32
  60. "0ssi1wpaf7plaswqqjwigppsg5fyh99vdlb9kzl7c9lng89ndq1i"))))
  61. (build-system gnu-build-system)
  62. (inputs
  63. `(("hello" ,hello)))
  64. (native-inputs
  65. `(("sed" ,sed)
  66. ("tar" ,tar)))
  67. (propagated-inputs
  68. `(("grep" ,grep)))
  69. (home-page "http://localhost")
  70. (synopsis "test")
  71. (description "test")
  72. (license license:gpl3+)))
  73. (define test-package-sexp
  74. '(package
  75. (name "test")
  76. (version "2.10")
  77. (source (origin
  78. (method url-fetch)
  79. (uri (string-append "mirror://gnu/hello/hello-" version
  80. ".tar.gz"))
  81. (sha256
  82. (base32
  83. "0ssi1wpaf7plaswqqjwigppsg5fyh99vdlb9kzl7c9lng89ndq1i"))))
  84. (build-system gnu-build-system)
  85. (inputs
  86. `(("hello" ,hello)))
  87. (native-inputs
  88. `(("sed" ,sed)
  89. ("tar" ,tar)))
  90. (propagated-inputs
  91. `(("grep" ,grep)))
  92. (home-page "http://localhost")
  93. (synopsis "test")
  94. (description "test")
  95. (license license:gpl3+)))
  96. (test-equal "changed-inputs returns no changes"
  97. '()
  98. (changed-inputs test-package test-package-sexp))
  99. (test-assert "changed-inputs returns changes to labelled input list"
  100. (let ((changes (changed-inputs
  101. (package
  102. (inherit test-package)
  103. (inputs `(("hello" ,hello)
  104. ("sed" ,sed))))
  105. test-package-sexp)))
  106. (match changes
  107. ;; Exactly one change
  108. (((? upstream-input-change? item))
  109. (and (equal? (upstream-input-change-type item)
  110. 'regular)
  111. (equal? (upstream-input-change-action item)
  112. 'remove)
  113. (string=? (upstream-input-change-name item)
  114. "sed")))
  115. (else (pk else #false)))))
  116. (test-assert "changed-inputs returns changes to all labelled input lists"
  117. (let ((changes (changed-inputs
  118. (package
  119. (inherit test-package)
  120. (inputs '())
  121. (native-inputs '())
  122. (propagated-inputs '()))
  123. test-package-sexp)))
  124. (match changes
  125. (((? upstream-input-change? items) ...)
  126. (and (equal? (map upstream-input-change-type items)
  127. '(regular native native propagated))
  128. (equal? (map upstream-input-change-action items)
  129. '(add add add add))
  130. (equal? (map upstream-input-change-name items)
  131. '("hello" "sed" "tar" "grep"))))
  132. (else (pk else #false)))))
  133. (define test-new-package
  134. (package
  135. (inherit test-package)
  136. (inputs
  137. (list hello))
  138. (native-inputs
  139. (list sed tar))
  140. (propagated-inputs
  141. (list grep))))
  142. (define test-new-package-sexp
  143. '(package
  144. (name "test")
  145. (version "2.10")
  146. (source (origin
  147. (method url-fetch)
  148. (uri (string-append "mirror://gnu/hello/hello-" version
  149. ".tar.gz"))
  150. (sha256
  151. (base32
  152. "0ssi1wpaf7plaswqqjwigppsg5fyh99vdlb9kzl7c9lng89ndq1i"))))
  153. (build-system gnu-build-system)
  154. (inputs
  155. (list hello))
  156. (native-inputs
  157. (list sed tar))
  158. (propagated-inputs
  159. (list grep))
  160. (home-page "http://localhost")
  161. (synopsis "test")
  162. (description "test")
  163. (license license:gpl3+)))
  164. (test-assert "changed-inputs returns changes to plain input list"
  165. (let ((changes (changed-inputs
  166. (package
  167. (inherit test-new-package)
  168. (inputs (list hello sed)))
  169. test-new-package-sexp)))
  170. (match changes
  171. ;; Exactly one change
  172. (((? upstream-input-change? item))
  173. (and (equal? (upstream-input-change-type item)
  174. 'regular)
  175. (equal? (upstream-input-change-action item)
  176. 'remove)
  177. (string=? (upstream-input-change-name item)
  178. "sed")))
  179. (else (pk else #false)))))
  180. (test-assert "changed-inputs returns changes to all plain input lists"
  181. (let ((changes (changed-inputs
  182. (package
  183. (inherit test-new-package)
  184. (inputs '())
  185. (native-inputs '())
  186. (propagated-inputs '()))
  187. test-new-package-sexp)))
  188. (match changes
  189. (((? upstream-input-change? items) ...)
  190. (and (equal? (map upstream-input-change-type items)
  191. '(regular native native propagated))
  192. (equal? (map upstream-input-change-action items)
  193. '(add add add add))
  194. (equal? (map upstream-input-change-name items)
  195. '("hello" "sed" "tar" "grep"))))
  196. (else (pk else #false)))))
  197. (test-end)