1 ;;; package-test.el --- Tests for the Emacs package system
3 ;; Author: Daniel Hackney <dan@haxney.org>
6 ;; This file is part of GNU Emacs.
8 ;; GNU Emacs is free software; you can redistribute it and/or modify
9 ;; it under the terms of the GNU General Public License as published by
10 ;; the Free Software Foundation; either version 3, or (at your option)
13 ;; GNU Emacs is distributed in the hope that it will be useful,
14 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
15 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 ;; GNU General Public License for more details.
18 ;; You should have received a copy of the GNU General Public License
19 ;; along with GNU Emacs; see the file COPYING. If not, write to the
20 ;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
21 ;; Boston, MA 02110-1301, USA.
25 ;; You may want to run this from a separate Emacs instance from your
26 ;; main one, because a bug in the code below could mess with your
27 ;; installed packages.
29 ;; Run this in a clean Emacs session using:
31 ;; $ emacs -Q --batch -L . -l package-x-test.el -f ert-run-tests-batch-and-exit
39 ;; package-test is not normally in `load-path', so temporarily set
40 ;; `load-path' to contain the current directory.
41 (let ((load-path (append (list (file-name-directory (or load-file-name
44 (require 'package-test
))
46 (defvar package-x-test--single-archive-entry-1-3
47 (package-desc-create :name
'simple-single
49 :summary
"A single-file package with no dependencies"
51 "Expected contents of the archive entry from the \"simple-single\" package.")
53 (defvar package-x-test--single-archive-entry-1-4
54 (package-desc-create :name
'simple-single
56 :summary
"A single-file package with no dependencies"
58 "Expected contents of the archive entry from the updated \"simple-single\" package.")
60 (ert-deftest package-x-test-upload-buffer
()
61 "Test creating an \"archive-contents\" file"
62 (with-package-test (:basedir
"data/package"
63 :file
"simple-single-1.3.el"
65 (package-upload-buffer)
66 (should (file-exists-p (expand-file-name "archive-contents"
67 package-archive-upload-base
)))
68 (should (file-exists-p (expand-file-name "simple-single-1.3.el"
69 package-archive-upload-base
)))
70 (should (file-exists-p (expand-file-name "simple-single-readme.txt"
71 package-archive-upload-base
)))
73 (let (archive-contents)
76 (expand-file-name "archive-contents"
77 package-archive-upload-base
))
78 (setq archive-contents
79 (package-read-from-string
80 (buffer-substring (point-min) (point-max)))))
81 (should (equal archive-contents
82 (list 1 package-x-test--single-archive-entry-1-3
))))))
84 (ert-deftest package-x-test-upload-new-version
()
85 "Test uploading a new version of a package"
86 (with-package-test (:basedir
"data/package"
87 :file
"simple-single-1.3.el"
89 (package-upload-buffer)
91 (insert-file-contents "newer-versions/simple-single-1.4.el")
92 (package-upload-buffer))
94 (let (archive-contents)
97 (expand-file-name "archive-contents"
98 package-archive-upload-base
))
99 (setq archive-contents
100 (package-read-from-string
101 (buffer-substring (point-min) (point-max)))))
102 (should (equal archive-contents
103 (list 1 package-x-test--single-archive-entry-1-4
))))))
105 (provide 'package-x-test
)
107 ;;; package-x-test.el ends here