elpa.scm 3.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. ;;; GNU Guix --- Functional package management for GNU
  2. ;;; Copyright © 2015 Federico Beffa <beffa@fbengineering.ch>
  3. ;;; Copyright © 2020 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 tests)
  24. #:use-module (guix tests http)
  25. #:use-module (srfi srfi-1)
  26. #:use-module (srfi srfi-64)
  27. #:use-module (ice-9 match)
  28. #:use-module (web client))
  29. (define elpa-mock-archive
  30. '(1
  31. (ace-window .
  32. [(0 9 0)
  33. ((avy
  34. (0 2 0)))
  35. "Quickly switch windows." single
  36. ((:url . "https://github.com/abo-abo/ace-window")
  37. (:keywords "window" "location"))])
  38. (auctex .
  39. [(11 88 6)
  40. nil "Integrated environment for *TeX*" tar
  41. ((:url . "http://www.gnu.org/software/auctex/"))])))
  42. (test-begin "elpa")
  43. (define (eval-test-with-elpa pkg)
  44. ;; Set up an HTTP server and use it as a pseudo-proxy so that
  45. ;; 'elpa->guix-package' talks to it.
  46. (with-http-server `((200 ,(object->string elpa-mock-archive))
  47. (200 "This is the description.")
  48. (200 "fake tarball contents"))
  49. (parameterize ((current-http-proxy (%local-url)))
  50. (match (elpa->guix-package pkg #:repo 'gnu/http)
  51. (('package
  52. ('name "emacs-auctex")
  53. ('version "11.88.6")
  54. ('source
  55. ('origin
  56. ('method 'url-fetch)
  57. ('uri ('string-append
  58. "http://elpa.gnu.org/packages/auctex-" 'version ".tar"))
  59. ('sha256 ('base32 (? string? hash)))))
  60. ('build-system 'emacs-build-system)
  61. ('home-page "http://www.gnu.org/software/auctex/")
  62. ('synopsis "Integrated environment for *TeX*")
  63. ('description "This is the description.")
  64. ('license 'license:gpl3+))
  65. #t)
  66. (x
  67. (pk 'fail x #f))))))
  68. (test-assert "elpa->guix-package test 1"
  69. (eval-test-with-elpa "auctex"))
  70. (test-equal "guix-package->elpa-name: without 'upstream-name' property"
  71. "auctex"
  72. (guix-package->elpa-name (dummy-package "emacs-auctex")))
  73. (test-equal "guix-package->elpa-name: with 'upstream-name' property"
  74. "project"
  75. (guix-package->elpa-name
  76. (dummy-package "emacs-fake-name"
  77. (properties '((upstream-name . "project"))))))
  78. (test-end "elpa")
  79. ;; Local Variables:
  80. ;; eval: (put 'with-http-server 'scheme-indent-function 1)
  81. ;; End: