lisp/simple.el (define-alternatives): Rename from alternatives-define.
[emacs.git] / test / automated / package-x-test.el
blobbeb1835808515e3e1226485d0e62814241f20f99
1 ;;; package-test.el --- Tests for the Emacs package system
3 ;; Copyright (C) 2013 Free Software Foundation, Inc.
5 ;; Author: Daniel Hackney <dan@haxney.org>
6 ;; Version: 1.0
8 ;; This file is part of GNU Emacs.
10 ;; GNU Emacs is free software: you can redistribute it and/or modify
11 ;; it under the terms of the GNU General Public License as published by
12 ;; the Free Software Foundation, either version 3 of the License, or
13 ;; (at your option) any later version.
15 ;; GNU Emacs is distributed in the hope that it will be useful,
16 ;; but 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.
20 ;; You should have received a copy of the GNU General Public License
21 ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
23 ;;; Commentary:
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
33 ;;; Code:
35 (require 'package-x)
36 (require 'ert)
37 (require 'cl-lib)
38 (eval-when-compile (require 'package-test))
40 ;; package-test is not normally in `load-path', so temporarily set
41 ;; `load-path' to contain the current directory.
42 (let ((load-path (append (list (file-name-directory (or load-file-name
43 buffer-file-name)))
44 load-path)))
45 (require 'package-test))
47 (defvar package-x-test--single-archive-entry-1-3
48 (cons 'simple-single
49 (package-make-ac-desc '(1 3) nil
50 "A single-file package with no dependencies"
51 'single))
52 "Expected contents of the archive entry from the \"simple-single\" package.")
54 (defvar package-x-test--single-archive-entry-1-4
55 (cons 'simple-single
56 (package-make-ac-desc '(1 4) nil
57 "A single-file package with no dependencies"
58 'single))
59 "Expected contents of the archive entry from the updated \"simple-single\" package.")
61 (ert-deftest package-x-test-upload-buffer ()
62 "Test creating an \"archive-contents\" file"
63 (with-package-test (:basedir "data/package"
64 :file "simple-single-1.3.el"
65 :upload-base t)
66 (package-upload-buffer)
67 (should (file-exists-p (expand-file-name "archive-contents"
68 package-archive-upload-base)))
69 (should (file-exists-p (expand-file-name "simple-single-1.3.el"
70 package-archive-upload-base)))
71 (should (file-exists-p (expand-file-name "simple-single-readme.txt"
72 package-archive-upload-base)))
74 (let (archive-contents)
75 (with-temp-buffer
76 (insert-file-contents
77 (expand-file-name "archive-contents"
78 package-archive-upload-base))
79 (setq archive-contents
80 (package-read-from-string
81 (buffer-substring (point-min) (point-max)))))
82 (should (equal archive-contents
83 (list 1 package-x-test--single-archive-entry-1-3))))))
85 (ert-deftest package-x-test-upload-new-version ()
86 "Test uploading a new version of a package"
87 (with-package-test (:basedir "data/package"
88 :file "simple-single-1.3.el"
89 :upload-base t)
90 (package-upload-buffer)
91 (with-temp-buffer
92 (insert-file-contents "newer-versions/simple-single-1.4.el")
93 (package-upload-buffer))
95 (let (archive-contents)
96 (with-temp-buffer
97 (insert-file-contents
98 (expand-file-name "archive-contents"
99 package-archive-upload-base))
100 (setq archive-contents
101 (package-read-from-string
102 (buffer-substring (point-min) (point-max)))))
103 (should (equal archive-contents
104 (list 1 package-x-test--single-archive-entry-1-4))))))
106 (provide 'package-x-test)
108 ;;; package-x-test.el ends here