gnu-maintenance.scm 5.5 KB

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