elpa.scm 2.8 KB

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