elpa.scm 3.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  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. ;;; Copyright © 2022 Maxime Devos <maximedevos@telenet.be>
  7. ;;;
  8. ;;; This file is part of GNU Guix.
  9. ;;;
  10. ;;; GNU Guix is free software; you can redistribute it and/or modify it
  11. ;;; under the terms of the GNU General Public License as published by
  12. ;;; the Free Software Foundation; either version 3 of the License, or (at
  13. ;;; your option) any later version.
  14. ;;;
  15. ;;; GNU Guix is distributed in the hope that it will be useful, but
  16. ;;; WITHOUT ANY WARRANTY; without even the implied warranty of
  17. ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  18. ;;; GNU General Public License for more details.
  19. ;;;
  20. ;;; You should have received a copy of the GNU General Public License
  21. ;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
  22. (define-module (test-elpa)
  23. #:use-module (guix import elpa)
  24. #:use-module (guix tests)
  25. #:use-module (guix tests http)
  26. #:use-module (srfi srfi-1)
  27. #:use-module (srfi srfi-64)
  28. #:use-module (ice-9 match)
  29. #:use-module (web client))
  30. (define elpa-mock-archive
  31. '(1
  32. (ace-window .
  33. [(0 9 0)
  34. ((avy
  35. (0 2 0)))
  36. "Quickly switch windows." single
  37. ((:url . "https://github.com/abo-abo/ace-window")
  38. (:keywords "window" "location"))])
  39. (auctex .
  40. [(11 88 6)
  41. nil "Integrated environment for *TeX*" tar
  42. ((:url . "http://www.gnu.org/software/auctex/"))])))
  43. (test-begin "elpa")
  44. (define (eval-test-with-elpa pkg)
  45. ;; Set up an HTTP server and use it as a pseudo-proxy so that
  46. ;; 'elpa->guix-package' talks to it.
  47. (with-http-server `(("http://elpa.gnu.org/packages/archive-contents" 200
  48. ,(object->string elpa-mock-archive))
  49. ("http://elpa.gnu.org/packages/auctex-readme.txt" 200
  50. "This is the description.")
  51. ("http://elpa.gnu.org/packages/auctex-11.88.6.tar" 200
  52. "fake tarball contents"))
  53. (parameterize ((current-http-proxy (%local-url)))
  54. (match (elpa->guix-package pkg #:repo 'gnu/http)
  55. (('package
  56. ('name "emacs-auctex")
  57. ('version "11.88.6")
  58. ('source
  59. ('origin
  60. ('method 'url-fetch)
  61. ('uri ('string-append
  62. "http://elpa.gnu.org/packages/auctex-" 'version ".tar"))
  63. ('sha256 ('base32 (? string? hash)))))
  64. ('build-system 'emacs-build-system)
  65. ('home-page "http://www.gnu.org/software/auctex/")
  66. ('synopsis "Integrated environment for *TeX*")
  67. ('description "This is the description.")
  68. ('license 'license:gpl3+))
  69. #t)
  70. (x
  71. (pk 'fail x #f))))))
  72. (test-assert "elpa->guix-package test 1"
  73. (eval-test-with-elpa "auctex"))
  74. (test-equal "guix-package->elpa-name: without 'upstream-name' property"
  75. "auctex"
  76. (guix-package->elpa-name (dummy-package "emacs-auctex")))
  77. (test-equal "guix-package->elpa-name: with 'upstream-name' property"
  78. "project"
  79. (guix-package->elpa-name
  80. (dummy-package "emacs-fake-name"
  81. (properties '((upstream-name . "project"))))))
  82. (test-end "elpa")
  83. ;; Local Variables:
  84. ;; eval: (put 'with-http-server 'scheme-indent-function 1)
  85. ;; End: