elpa.scm 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136
  1. ;;; GNU Guix --- Functional package management for GNU
  2. ;;; Copyright © 2015 Federico Beffa <beffa@fbengineering.ch>
  3. ;;; Copyright © 2020, 2023 Ludovic Courtès <ludo@gnu.org>
  4. ;;; Copyright © 2020 Martin Becze <mjbecze@riseup.net>
  5. ;;; Copyright © 2021 Xinglu Chen <public@yoctocell.xyz>
  6. ;;;
  7. ;;; This file is part of GNU Guix.
  8. ;;;
  9. ;;; GNU Guix is free software; you can redistribute it and/or modify it
  10. ;;; under the terms of the GNU General Public License as published by
  11. ;;; the Free Software Foundation; either version 3 of the License, or (at
  12. ;;; your option) any later version.
  13. ;;;
  14. ;;; GNU Guix is distributed in the hope that it will be useful, but
  15. ;;; WITHOUT ANY WARRANTY; without even the implied warranty of
  16. ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  17. ;;; GNU General Public License for more details.
  18. ;;;
  19. ;;; You should have received a copy of the GNU General Public License
  20. ;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
  21. (define-module (test-elpa)
  22. #:use-module (guix import elpa)
  23. #:use-module (guix upstream)
  24. #:use-module ((guix download) #:select (url-fetch))
  25. #:use-module (guix tests)
  26. #:use-module (guix tests http)
  27. #:use-module (srfi srfi-1)
  28. #:use-module (srfi srfi-64)
  29. #:use-module (ice-9 match)
  30. #:use-module (web client))
  31. (define elpa-mock-archive
  32. '(1
  33. (ace-window .
  34. [(0 9 0)
  35. ((avy
  36. (0 2 0)))
  37. "Quickly switch windows." single
  38. ((:url . "https://github.com/abo-abo/ace-window")
  39. (:keywords "window" "location"))])
  40. (auctex .
  41. [(11 88 6)
  42. nil "Integrated environment for *TeX*" tar
  43. ((:url . "http://www.gnu.org/software/auctex/"))])
  44. (fake-taxy-magit-section .
  45. [(0 12 2)
  46. ((emacs
  47. (26 3))
  48. (magit-section
  49. (3 2 1))
  50. (taxy
  51. (0 10)))
  52. "View Taxy structs in a Magit Section buffer" tar
  53. ((:url . "https://github.com/alphapapa/taxy.el")
  54. (:keywords "lisp"))])))
  55. (test-begin "elpa")
  56. (define (eval-test-with-elpa pkg)
  57. ;; Set up an HTTP server and use it as a pseudo-proxy so that
  58. ;; 'elpa->guix-package' talks to it.
  59. (with-http-server `((200 ,(object->string elpa-mock-archive))
  60. (200 "This is the description.")
  61. (200 "fake tarball contents"))
  62. (parameterize ((current-http-proxy (%local-url)))
  63. (match (elpa->guix-package pkg #:repo 'gnu/http)
  64. (`(package
  65. (name "emacs-auctex")
  66. (version "11.88.6")
  67. (source
  68. (origin
  69. (method url-fetch)
  70. (uri (string-append
  71. "http://elpa.gnu.org/packages/auctex-" version ".tar"))
  72. (sha256 (base32 ,(? string? hash)))))
  73. (build-system emacs-build-system)
  74. (home-page "http://www.gnu.org/software/auctex/")
  75. (synopsis "Integrated environment for *TeX*")
  76. (description "This is the description.")
  77. (license license:gpl3+))
  78. #t)
  79. (x
  80. (pk 'fail x #f))))))
  81. (test-assert "elpa->guix-package test 1"
  82. (eval-test-with-elpa "auctex"))
  83. (test-equal "package-latest-release"
  84. (list '("http://elpa.gnu.org/packages/fake-taxy-magit-section-0.12.2.tar")
  85. '("http://elpa.gnu.org/packages/fake-taxy-magit-section-0.12.2.tar.sig")
  86. (list (upstream-input
  87. (name "magit-section")
  88. (downstream-name "emacs-magit-section")
  89. (type 'propagated)
  90. (min-version "3.2.1")
  91. (max-version min-version))
  92. (upstream-input
  93. (name "taxy")
  94. (downstream-name "emacs-taxy")
  95. (type 'propagated)
  96. (min-version "0.10")
  97. (max-version #f))))
  98. (with-http-server `((200 ,(object->string elpa-mock-archive)))
  99. (parameterize ((current-http-proxy (%local-url)))
  100. (define source
  101. ;; Note: Use 'http' URLs to the proxy is used.
  102. (package-latest-release
  103. (dummy-package "emacs-fake-taxy-magit-section"
  104. (version "0.0.0")
  105. (source (dummy-origin
  106. (method url-fetch)
  107. (uri "http://elpa.gnu.org/xyz"))))
  108. (list %elpa-updater)))
  109. (list (upstream-source-urls source)
  110. (upstream-source-signature-urls source)
  111. (upstream-source-inputs source)))))
  112. (test-equal "guix-package->elpa-name: without 'upstream-name' property"
  113. "auctex"
  114. (guix-package->elpa-name (dummy-package "emacs-auctex")))
  115. (test-equal "guix-package->elpa-name: with 'upstream-name' property"
  116. "project"
  117. (guix-package->elpa-name
  118. (dummy-package "emacs-fake-name"
  119. (properties '((upstream-name . "project"))))))
  120. (test-end "elpa")
  121. ;; Local Variables:
  122. ;; eval: (put 'with-http-server 'scheme-indent-function 1)
  123. ;; End: