gnu-maintenance.scm 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197
  1. ;;; GNU Guix --- Functional package management for GNU
  2. ;;; Copyright © 2015, 2021 Ludovic Courtès <ludo@gnu.org>
  3. ;;; Copyright © 2022 Maxime Devos <maximedevos@telenet.be>
  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-gnu-maintenance)
  20. #:use-module (guix gnu-maintenance)
  21. #:use-module (guix tests)
  22. #:use-module (guix tests http)
  23. #:use-module (guix upstream)
  24. #:use-module (guix utils)
  25. #:use-module (srfi srfi-1)
  26. #:use-module (srfi srfi-64)
  27. #:use-module (ice-9 match))
  28. (test-begin "gnu-maintenance")
  29. (test-assert "release-file?"
  30. (and (every (lambda (project+file)
  31. (apply release-file? project+file))
  32. '(("gcc" "gcc-5.3.0.tar.bz2")
  33. ("texmacs" "TeXmacs-1.0.7.9-src.tar.gz")
  34. ("icecat" "icecat-38.4.0-gnu1.tar.bz2")
  35. ("mit-scheme" "mit-scheme-9.2.tar.gz")
  36. ("mediainfo" "mediainfo_20.09.tar.xz")
  37. ("exiv2" "exiv2-0.27.3-Source.tar.gz")
  38. ("mpg321" "mpg321_0.3.2.orig.tar.gz")
  39. ("bvi" "bvi-1.4.1.src.tar.gz")
  40. ("hostscope" "hostscope-V2.1.tgz")
  41. ("qtbase" "qtbase-everywhere-src-6.5.2.tar.xz")
  42. ("qtbase" "qtbase-everywhere-opensource-src-5.15.10.tar.xz")
  43. ("qt-creator" "qt-creator-opensource-src-11.0.1.tar.xz")))
  44. (every (lambda (project+file)
  45. (not (apply release-file? project+file)))
  46. '(("guile" "guile-www-1.1.1.tar.gz")
  47. ("guile" "guile-2.0.11.tar.gz.sig")
  48. ("mit-scheme" "mit-scheme-9.2-i386.tar.gz")
  49. ("mit-scheme" "mit-scheme-9.2-doc-pdf.tar.gz")
  50. ("gnutls" "gnutls-3.2.18-w32.zip")
  51. ("valgrind" "valgrind-3.20.0.RC1.tar.bz2")))))
  52. (test-assert "tarball->version"
  53. (let ((tarball->version (@@ (guix gnu-maintenance) tarball->version)))
  54. (every (match-lambda
  55. ((file version)
  56. (equal? (tarball->version file) version)))
  57. '(("coreutils-8.32.tar.gz" "8.32")
  58. ("mediainfo_20.09.tar.xz" "20.09")
  59. ("exiv2-0.27.3-Source.tar.gz" "0.27.3")
  60. ("mpg321_0.3.2.orig.tar.gz" "0.3.2")
  61. ("bvi-1.4.1.src.tar.gz" "1.4.1")))))
  62. (test-assert "latest-html-release, scheme-less URIs"
  63. (with-http-server
  64. `((200 "<html xmlns=\"http://www.w3.org/1999/xhtml\">
  65. <head>
  66. <title>Releases (on another domain)!</title>
  67. </head>
  68. <body
  69. <a href=\"//another-site/foo-2.tar.gz\">version 1</a>
  70. </body>
  71. </html>"))
  72. (let ()
  73. (define package
  74. (dummy-package "foo"
  75. (source
  76. (dummy-origin
  77. (uri (string-append (%local-url) "/foo-1.tar.gz"))))
  78. (properties
  79. `((release-monitoring-url . ,(%local-url))))))
  80. (define update ((upstream-updater-import %generic-html-updater) package))
  81. (define expected-new-url "http://another-site/foo-2.tar.gz")
  82. (and (pk 'u update)
  83. (equal? (upstream-source-version update) "2")
  84. (equal? (list expected-new-url) (upstream-source-urls update))))))
  85. (test-assert "latest-html-release, no signature"
  86. (with-http-server
  87. `((200 "<html xmlns=\"http://www.w3.org/1999/xhtml\">
  88. <head>
  89. <title>Releases!</title>
  90. </head>
  91. <body>
  92. <a href=\"bar/foo-1.tar.gz\">version 1</a>
  93. <a href=\"bar/foo-2.tar.gz\">version 2</a>
  94. </body>
  95. </html>"))
  96. (let ()
  97. (define package
  98. (dummy-package "foo"
  99. (source
  100. (dummy-origin
  101. (uri (string-append (%local-url) "/foo-1.tar.gz"))))
  102. (properties
  103. `((release-monitoring-url . ,(%local-url))))))
  104. (define update ((upstream-updater-import %generic-html-updater) package))
  105. (define expected-new-url
  106. (string-append (%local-url) "/foo-2.tar.gz"))
  107. (and (pk 'u update)
  108. (equal? (upstream-source-version update) "2")
  109. (equal? (list expected-new-url)
  110. (upstream-source-urls update))
  111. (null? ;; both #false and the empty list are acceptable
  112. (or (upstream-source-signature-urls update) '()))))))
  113. (test-assert "latest-html-release, signature"
  114. (with-http-server
  115. `((200 "<html xmlns=\"http://www.w3.org/1999/xhtml\">
  116. <head>
  117. <title>Signed releases!</title>
  118. </head>
  119. <body>
  120. <a href=\"bar/foo-1.tar.gz\">version 1</a>
  121. <a href=\"bar/foo-2.tar.gz\">version 2</a>
  122. <a href=\"bar/foo-1.tar.gz.sig\">version 1 signature</a>
  123. <a href=\"bar/foo-2.tar.gz.sig\">version 2 signature</a>
  124. </body>
  125. </html>"))
  126. (let ()
  127. (define package
  128. (dummy-package "foo"
  129. (source
  130. (dummy-origin
  131. (uri (string-append (%local-url) "/foo-1.tar.gz"))))
  132. (properties
  133. `((release-monitoring-url . ,(%local-url))))))
  134. (define update ((upstream-updater-import %generic-html-updater) package))
  135. (define expected-new-url
  136. (string-append (%local-url) "/foo-2.tar.gz"))
  137. (define expected-signature-url
  138. (string-append (%local-url) "/foo-2.tar.gz.sig"))
  139. (and (pk 'u update)
  140. (equal? (upstream-source-version update) "2")
  141. (equal? (list expected-new-url)
  142. (upstream-source-urls update))
  143. (equal? (list expected-signature-url)
  144. (upstream-source-signature-urls update))))))
  145. (test-equal "rewrite-url, to-version specified"
  146. "https://download.qt.io/official_releases/qt/6.5/6.5.2/\
  147. submodules/qtbase-everywhere-src-6.5.2.tar.xz"
  148. (rewrite-url "https://download.qt.io/official_releases/qt/6.3/6.3.2/\
  149. submodules/qtbase-everywhere-src-6.3.2.tar.xz" "6.3.2" #:to-version "6.5.2"))
  150. (test-equal "rewrite-url, without to-version"
  151. "https://dist.libuv.org/dist/v1.46.0/libuv-v1.46.0.tar.gz"
  152. (with-http-server
  153. ;; First reply, crawling https://dist.libuv.org/dist/.
  154. `((200 "\
  155. <!DOCTYPE html>
  156. <html>
  157. <head><title>Index of dist</title></head>
  158. <body>
  159. <a href=\"../\">../</a>
  160. <a href=\"v1.44.0/\" title=\"v1.44.0/\">v1.44.0/</a>
  161. <a href=\"v1.44.1/\" title=\"v1.44.1/\">v1.44.1/</a>
  162. <a href=\"v1.44.2/\" title=\"v1.44.2/\">v1.44.2/</a>
  163. <a href=\"v1.45.0/\" title=\"v1.45.0/\">v1.45.0/</a>
  164. <a href=\"v1.46.0/\" title=\"v1.46.0/\">v1.46.0/</a>
  165. </body>
  166. </html>")
  167. ;; Second reply, crawling https://dist.libuv.org/dist/v1.46.0/.
  168. (200 "\
  169. <!DOCTYPE html>
  170. <html>
  171. <head><title>Index of dist/v1.46.0</title></head>
  172. <body>
  173. <a href=\"../\">../</a>
  174. <a href=\"libuv-v1.46.0-dist.tar.gz\" title=\"libuv-v1.46.0-dist.tar.gz\">
  175. libuv-v1.46.0-dist.tar.gz</a>
  176. <a href=\"libuv-v1.46.0-dist.tar.gz.sign\"
  177. title=\"libuv-v1.46.0-dist.tar.gz.sign\">libuv-v1.46.0-dist.tar.gz.sign</a>
  178. <a href=\"libuv-v1.46.0.tar.gz\" title=\"libuv-v1.46.0.tar.gz\">
  179. libuv-v1.46.0.tar.gz</a>
  180. <a href=\"libuv-v1.46.0.tar.gz.sign\" title=\"libuv-v1.46.0.tar.gz.sign\">
  181. libuv-v1.46.0.tar.gz.sign</a>
  182. </body>
  183. </html>"))
  184. (rewrite-url "https://dist.libuv.org/dist/v1.45.0/libuv-v1.45.0.tar.gz"
  185. "1.45.0")))
  186. (test-end)