blob: cce51b63561331850ed2528a9baae9d4648eee0a (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
|
;;; package-test.el --- Tests for the Emacs package system
;; Copyright (C) 2013-2014 Free Software Foundation, Inc.
;; Author: Daniel Hackney <dan@haxney.org>
;; Version: 1.0
;; This file is part of GNU Emacs.
;; GNU Emacs is free software: you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation, either version 3 of the License, or
;; (at your option) any later version.
;; GNU Emacs is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
;; GNU General Public License for more details.
;; You should have received a copy of the GNU General Public License
;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
;;; Commentary:
;; You may want to run this from a separate Emacs instance from your
;; main one, because a bug in the code below could mess with your
;; installed packages.
;; Run this in a clean Emacs session using:
;;
;; $ emacs -Q --batch -L . -l package-x-test.el -f ert-run-tests-batch-and-exit
;;; Code:
(require 'package-x)
(require 'ert)
(require 'cl-lib)
(eval-when-compile (require 'package-test))
;; package-test is not normally in `load-path', so temporarily set
;; `load-path' to contain the current directory.
(let ((load-path (append (list (file-name-directory (or load-file-name
buffer-file-name)))
load-path)))
(require 'package-test))
(defvar package-x-test--single-archive-entry-1-3
(cons 'simple-single
(package-make-ac-desc '(1 3) nil
"A single-file package with no dependencies"
'single
'((:url . "http://doodles.au"))))
"Expected contents of the archive entry from the \"simple-single\" package.")
(defvar package-x-test--single-archive-entry-1-4
(cons 'simple-single
(package-make-ac-desc '(1 4) nil
"A single-file package with no dependencies"
'single
nil))
"Expected contents of the archive entry from the updated \"simple-single\" package.")
(ert-deftest package-x-test-upload-buffer ()
"Test creating an \"archive-contents\" file"
(with-package-test (:basedir "data/package"
:file "simple-single-1.3.el"
:upload-base t)
(package-upload-buffer)
(should (file-exists-p (expand-file-name "archive-contents"
package-archive-upload-base)))
(should (file-exists-p (expand-file-name "simple-single-1.3.el"
package-archive-upload-base)))
(should (file-exists-p (expand-file-name "simple-single-readme.txt"
package-archive-upload-base)))
(let (archive-contents)
(with-temp-buffer
(insert-file-contents
(expand-file-name "archive-contents"
package-archive-upload-base))
(setq archive-contents
(package-read-from-string
(buffer-substring (point-min) (point-max)))))
(should (equal archive-contents
(list 1 package-x-test--single-archive-entry-1-3))))))
(ert-deftest package-x-test-upload-new-version ()
"Test uploading a new version of a package"
(with-package-test (:basedir "data/package"
:file "simple-single-1.3.el"
:upload-base t)
(package-upload-buffer)
(with-temp-buffer
(insert-file-contents "newer-versions/simple-single-1.4.el")
(package-upload-buffer))
(let (archive-contents)
(with-temp-buffer
(insert-file-contents
(expand-file-name "archive-contents"
package-archive-upload-base))
(setq archive-contents
(package-read-from-string
(buffer-substring (point-min) (point-max)))))
(should (equal archive-contents
(list 1 package-x-test--single-archive-entry-1-4))))))
(provide 'package-x-test)
;;; package-x-test.el ends here
|