aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/automated/package-x-test.el110
1 files changed, 110 insertions, 0 deletions
diff --git a/test/automated/package-x-test.el b/test/automated/package-x-test.el
new file mode 100644
index 00000000000..70c9d96fde8
--- /dev/null
+++ b/test/automated/package-x-test.el
@@ -0,0 +1,110 @@
1;;; package-test.el --- Tests for the Emacs package system
2
3;; Copyright (C) 2013-2015 Free Software Foundation, Inc.
4
5;; Author: Daniel Hackney <dan@haxney.org>
6;; Version: 1.0
7
8;; This file is part of GNU Emacs.
9
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.
14
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.
19
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/>.
22
23;;; Commentary:
24
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.
28
29;; Run this in a clean Emacs session using:
30;;
31;; $ emacs -Q --batch -L . -l package-x-test.el -f ert-run-tests-batch-and-exit
32
33;;; Code:
34
35(require 'package-x)
36(require 'ert)
37(require 'cl-lib)
38(eval-when-compile (require 'package-test))
39
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))
46
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 '((:url . "http://doodles.au"))))
53 "Expected contents of the archive entry from the \"simple-single\" package.")
54
55(defvar package-x-test--single-archive-entry-1-4
56 (cons 'simple-single
57 (package-make-ac-desc '(1 4) nil
58 "A single-file package with no dependencies"
59 'single
60 nil))
61 "Expected contents of the archive entry from the updated \"simple-single\" package.")
62
63(ert-deftest package-x-test-upload-buffer ()
64 "Test creating an \"archive-contents\" file"
65 (with-package-test (:basedir "data/package"
66 :file "simple-single-1.3.el"
67 :upload-base t)
68 (package-upload-buffer)
69 (should (file-exists-p (expand-file-name "archive-contents"
70 package-archive-upload-base)))
71 (should (file-exists-p (expand-file-name "simple-single-1.3.el"
72 package-archive-upload-base)))
73 (should (file-exists-p (expand-file-name "simple-single-readme.txt"
74 package-archive-upload-base)))
75
76 (let (archive-contents)
77 (with-temp-buffer
78 (insert-file-contents
79 (expand-file-name "archive-contents"
80 package-archive-upload-base))
81 (setq archive-contents
82 (package-read-from-string
83 (buffer-substring (point-min) (point-max)))))
84 (should (equal archive-contents
85 (list 1 package-x-test--single-archive-entry-1-3))))))
86
87(ert-deftest package-x-test-upload-new-version ()
88 "Test uploading a new version of a package"
89 (with-package-test (:basedir "data/package"
90 :file "simple-single-1.3.el"
91 :upload-base t)
92 (package-upload-buffer)
93 (with-temp-buffer
94 (insert-file-contents "newer-versions/simple-single-1.4.el")
95 (package-upload-buffer))
96
97 (let (archive-contents)
98 (with-temp-buffer
99 (insert-file-contents
100 (expand-file-name "archive-contents"
101 package-archive-upload-base))
102 (setq archive-contents
103 (package-read-from-string
104 (buffer-substring (point-min) (point-max)))))
105 (should (equal archive-contents
106 (list 1 package-x-test--single-archive-entry-1-4))))))
107
108(provide 'package-x-test)
109
110;;; package-x-test.el ends here