gnu-maintenance.scm 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151
  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. (every (lambda (project+file)
  42. (not (apply release-file? project+file)))
  43. '(("guile" "guile-www-1.1.1.tar.gz")
  44. ("guile" "guile-2.0.11.tar.gz.sig")
  45. ("mit-scheme" "mit-scheme-9.2-i386.tar.gz")
  46. ("mit-scheme" "mit-scheme-9.2-doc-pdf.tar.gz")
  47. ("gnutls" "gnutls-3.2.18-w32.zip")
  48. ("valgrind" "valgrind-3.20.0.RC1.tar.bz2")))))
  49. (test-assert "tarball->version"
  50. (let ((tarball->version (@@ (guix gnu-maintenance) tarball->version)))
  51. (every (match-lambda
  52. ((file version)
  53. (equal? (tarball->version file) version)))
  54. '(("coreutils-8.32.tar.gz" "8.32")
  55. ("mediainfo_20.09.tar.xz" "20.09")
  56. ("exiv2-0.27.3-Source.tar.gz" "0.27.3")
  57. ("mpg321_0.3.2.orig.tar.gz" "0.3.2")
  58. ("bvi-1.4.1.src.tar.gz" "1.4.1")))))
  59. (test-assert "latest-html-release, scheme-less URIs"
  60. (with-http-server
  61. `((200 "<html xmlns=\"http://www.w3.org/1999/xhtml\">
  62. <head>
  63. <title>Releases (on another domain)!</title>
  64. </head>
  65. <body
  66. <a href=\"//another-site/foo-2.tar.gz\">version 1</a>
  67. </body>
  68. </html>"))
  69. (let ()
  70. (define package
  71. (dummy-package "foo"
  72. (source
  73. (dummy-origin
  74. (uri (string-append (%local-url) "/foo-1.tar.gz"))))
  75. (properties
  76. `((release-monitoring-url . ,(%local-url))))))
  77. (define update ((upstream-updater-import %generic-html-updater) package))
  78. (define expected-new-url "http://another-site/foo-2.tar.gz")
  79. (and (pk 'u update)
  80. (equal? (upstream-source-version update) "2")
  81. (equal? (list expected-new-url) (upstream-source-urls update))))))
  82. (test-assert "latest-html-release, no signature"
  83. (with-http-server
  84. `((200 "<html xmlns=\"http://www.w3.org/1999/xhtml\">
  85. <head>
  86. <title>Releases!</title>
  87. </head>
  88. <body>
  89. <a href=\"bar/foo-1.tar.gz\">version 1</a>
  90. <a href=\"bar/foo-2.tar.gz\">version 2</a>
  91. </body>
  92. </html>"))
  93. (let ()
  94. (define package
  95. (dummy-package "foo"
  96. (source
  97. (dummy-origin
  98. (uri (string-append (%local-url) "/foo-1.tar.gz"))))
  99. (properties
  100. `((release-monitoring-url . ,(%local-url))))))
  101. (define update ((upstream-updater-import %generic-html-updater) package))
  102. (define expected-new-url
  103. (string-append (%local-url) "/foo-2.tar.gz"))
  104. (and (pk 'u update)
  105. (equal? (upstream-source-version update) "2")
  106. (equal? (list expected-new-url)
  107. (upstream-source-urls update))
  108. (null? ;; both #false and the empty list are acceptable
  109. (or (upstream-source-signature-urls update) '()))))))
  110. (test-assert "latest-html-release, signature"
  111. (with-http-server
  112. `((200 "<html xmlns=\"http://www.w3.org/1999/xhtml\">
  113. <head>
  114. <title>Signed releases!</title>
  115. </head>
  116. <body>
  117. <a href=\"bar/foo-1.tar.gz\">version 1</a>
  118. <a href=\"bar/foo-2.tar.gz\">version 2</a>
  119. <a href=\"bar/foo-1.tar.gz.sig\">version 1 signature</a>
  120. <a href=\"bar/foo-2.tar.gz.sig\">version 2 signature</a>
  121. </body>
  122. </html>"))
  123. (let ()
  124. (define package
  125. (dummy-package "foo"
  126. (source
  127. (dummy-origin
  128. (uri (string-append (%local-url) "/foo-1.tar.gz"))))
  129. (properties
  130. `((release-monitoring-url . ,(%local-url))))))
  131. (define update ((upstream-updater-import %generic-html-updater) package))
  132. (define expected-new-url
  133. (string-append (%local-url) "/foo-2.tar.gz"))
  134. (define expected-signature-url
  135. (string-append (%local-url) "/foo-2.tar.gz.sig"))
  136. (and (pk 'u update)
  137. (equal? (upstream-source-version update) "2")
  138. (equal? (list expected-new-url)
  139. (upstream-source-urls update))
  140. (equal? (list expected-signature-url)
  141. (upstream-source-signature-urls update))))))
  142. (test-end)