aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorJoakim Verona2013-07-02 22:46:17 +0200
committerJoakim Verona2013-07-02 22:46:17 +0200
commit3718127221fbbc31f8ebd027ab7c95403dbe9118 (patch)
treeef422898f3344c8f94f6ecf63eb583122bbf2bd8 /test
parent1ce45b902c67b8a0dda8d71bd2812de29a9988a6 (diff)
parenta3b49114c186d84404226af75ae7905bd1cd018f (diff)
downloademacs-3718127221fbbc31f8ebd027ab7c95403dbe9118.tar.gz
emacs-3718127221fbbc31f8ebd027ab7c95403dbe9118.zip
Merge branch 'trunk' into xwidget
Conflicts: src/window.c
Diffstat (limited to 'test')
-rw-r--r--test/ChangeLog61
-rw-r--r--test/automated/Makefile.in2
-rw-r--r--test/automated/data/package/archive-contents10
-rw-r--r--test/automated/data/package/multi-file-0.2.3.tarbin0 -> 20480 bytes
-rw-r--r--test/automated/data/package/multi-file-readme.txt1
-rw-r--r--test/automated/data/package/newer-versions/archive-contents13
-rw-r--r--test/automated/data/package/newer-versions/new-pkg-1.0.el18
-rw-r--r--test/automated/data/package/newer-versions/simple-single-1.4.el36
-rw-r--r--test/automated/data/package/simple-depend-1.0.el17
-rw-r--r--test/automated/data/package/simple-single-1.3.el32
-rw-r--r--test/automated/data/package/simple-single-readme.txt3
-rw-r--r--test/automated/decoder-tests.el117
-rw-r--r--test/automated/flymake-tests.el82
-rw-r--r--test/automated/flymake/warnpred/Makefile8
-rw-r--r--test/automated/flymake/warnpred/test.c5
-rw-r--r--test/automated/flymake/warnpred/test.pl2
-rw-r--r--test/automated/info-xref.el148
-rw-r--r--test/automated/occur-tests.el20
-rwxr-xr-xtest/automated/package-test.el398
-rwxr-xr-xtest/automated/package-x-test.el107
-rw-r--r--test/automated/python-tests.el6
-rw-r--r--test/automated/ruby-mode-tests.el9
-rw-r--r--test/automated/undo-tests.el22
23 files changed, 1061 insertions, 56 deletions
diff --git a/test/ChangeLog b/test/ChangeLog
index 2e8364e1d2a..9ccb1f4bc89 100644
--- a/test/ChangeLog
+++ b/test/ChangeLog
@@ -1,7 +1,64 @@
12013-06-28 Kenichi Handa <handa@gnu.org>
2
3 * automated/decoder-tests.el (decoder-tests-gen-file): New arg FILE.
4 (decoder-tests-ao-gen-file): Renamed from decoder-tests-filename.
5 Callers changed.
6 (decoder-tests-filename): New function.
7 (decoder-tests-prefer-utf-8-read)
8 (decoder-tests-prefer-utf-8-write): New function.
9 (ert-test-decoder-prefer-utf-8): New test.
10
112013-06-27 Dmitry Gutov <dgutov@yandex.ru>
12
13 * automated/package-x-test.el: Change the commentary.
14 (package-x-test--single-archive-entry-1-3)
15 (package-x-test--single-archive-entry-1-4): Fix the tests, by
16 using the appropriate data structure.
17
182013-06-27 Daniel Hackney <dan@haxney.org>
19
20 * automated/Makefile.in (setwins): Include the 'data' subdirectory.
21
22 * automated/package-x-test.el: New file.
23
24 * automated/package-test.el: New file.
25
26 * automated/data/package: New directory, with test examples.
27
282013-06-27 Glenn Morris <rgm@gnu.org>
29
30 * automated/python-tests.el (python-tests-with-temp-file):
31 Clean up after ourself.
32
33 * automated/undo-tests.el (undo-test3): Remove test that seems to
34 do nothing that the previous one doesn't, except leave a tempfile.
35
362013-06-26 Glenn Morris <rgm@gnu.org>
37
38 * automated/info-xref.el: New file.
39
402013-06-25 Glenn Morris <rgm@gnu.org>
41
42 * automated/occur-tests.el (occur-test-create): New function.
43 Use it to create separate tests for each element, so we run them
44 all rather than stopping at the first error.
45
462013-06-24 Glenn Morris <rgm@fencepost.gnu.org>
47
48 * automated/occur-tests.el (occur-tests):
49 Update for 2013-05-29 change to occur header line.
50
512013-06-21 Eduard Wiebe <usenet@pusto.de>
52
53 Test suite for flymake.
54 * automated/flymake-tests.el:
55 * automated/flymake/warnpred/Makefile
56 * automated/flymake/warnpred/test.c
57 * automated/flymake/warnpred/test.pl: New files.
58
12013-06-12 RĂ¼diger Sonderfeld <ruediger@c-plusplus.de> 592013-06-12 RĂ¼diger Sonderfeld <ruediger@c-plusplus.de>
2 60
3 * automated/reftex-tests.el (reftex-parse-from-file-test): Fix 61 * automated/reftex-tests.el (reftex-parse-from-file-test): Fix test.
4 test.
5 62
62013-06-12 RĂ¼diger Sonderfeld <ruediger@c-plusplus.de> 632013-06-12 RĂ¼diger Sonderfeld <ruediger@c-plusplus.de>
7 64
diff --git a/test/automated/Makefile.in b/test/automated/Makefile.in
index 1a4e3c9b1ea..6e7111e589c 100644
--- a/test/automated/Makefile.in
+++ b/test/automated/Makefile.in
@@ -50,7 +50,7 @@ emacs = EMACSLOADPATH=$(lispsrc):$(test) LC_ALL=C $(EMACS) $(EMACSOPT)
50# Common command to find subdirectories 50# Common command to find subdirectories
51setwins=subdirs=`find . -type d -print`; \ 51setwins=subdirs=`find . -type d -print`; \
52 for file in $$subdirs; do \ 52 for file in $$subdirs; do \
53 case $$file in */.* | */.*/* | */=* ) ;; \ 53 case $$file in */.* | */.*/* | */=* | ./data* ) ;; \
54 *) wins="$$wins $$file" ;; \ 54 *) wins="$$wins $$file" ;; \
55 esac; \ 55 esac; \
56 done 56 done
diff --git a/test/automated/data/package/archive-contents b/test/automated/data/package/archive-contents
new file mode 100644
index 00000000000..7e4a410030f
--- /dev/null
+++ b/test/automated/data/package/archive-contents
@@ -0,0 +1,10 @@
1(1
2 (simple-single .
3 [(1 3)
4 nil "A single-file package with no dependencies" single])
5 (simple-depend .
6 [(1 0)
7 ((simple-single (1 3))) "A single-file package with a dependency." single])
8 (multi-file .
9 [(0 2 3)
10 nil "Example of a multi-file tar package" tar]))
diff --git a/test/automated/data/package/multi-file-0.2.3.tar b/test/automated/data/package/multi-file-0.2.3.tar
new file mode 100644
index 00000000000..bdbbab0e6f4
--- /dev/null
+++ b/test/automated/data/package/multi-file-0.2.3.tar
Binary files differ
diff --git a/test/automated/data/package/multi-file-readme.txt b/test/automated/data/package/multi-file-readme.txt
new file mode 100644
index 00000000000..affd2e96fb0
--- /dev/null
+++ b/test/automated/data/package/multi-file-readme.txt
@@ -0,0 +1 @@
This is a bare-bones readme file for the multi-file package.
diff --git a/test/automated/data/package/newer-versions/archive-contents b/test/automated/data/package/newer-versions/archive-contents
new file mode 100644
index 00000000000..add5f2909d0
--- /dev/null
+++ b/test/automated/data/package/newer-versions/archive-contents
@@ -0,0 +1,13 @@
1(1
2 (simple-single .
3 [(1 4)
4 nil "A single-file package with no dependencies" single])
5 (simple-depend .
6 [(1 0)
7 ((simple-single (1 3))) "A single-file package with a dependency." single])
8 (new-pkg .
9 [(1 0)
10 nil "A package only seen after "updating" archive-contents" single])
11 (multi-file .
12 [(0 2 3)
13 nil "Example of a multi-file tar package" tar]))
diff --git a/test/automated/data/package/newer-versions/new-pkg-1.0.el b/test/automated/data/package/newer-versions/new-pkg-1.0.el
new file mode 100644
index 00000000000..7251622fa59
--- /dev/null
+++ b/test/automated/data/package/newer-versions/new-pkg-1.0.el
@@ -0,0 +1,18 @@
1;;; new-pkg.el --- A package only seen after "updating" archive-contents
2
3;; Author: J. R. Hacker <jrh@example.com>
4;; Version: 1.0
5
6;;; Commentary:
7
8;; This will only show up after updating "archive-contents".
9
10;;; Code:
11
12(defun new-pkg-frob ()
13 "Ignore me."
14 (ignore))
15
16(provide 'new-pkg)
17
18;;; new-pkg.el ends here
diff --git a/test/automated/data/package/newer-versions/simple-single-1.4.el b/test/automated/data/package/newer-versions/simple-single-1.4.el
new file mode 100644
index 00000000000..7d8178c05a5
--- /dev/null
+++ b/test/automated/data/package/newer-versions/simple-single-1.4.el
@@ -0,0 +1,36 @@
1;;; simple-single.el --- A single-file package with no dependencies
2
3;; Author: J. R. Hacker <jrh@example.com>
4;; Version: 1.4
5;; Keywords: frobnicate
6
7;;; Commentary:
8
9;; This package provides a minor mode to frobnicate and/or bifurcate
10;; any flanges you desire. To activate it, type "C-M-r M-3 butterfly"
11;; and all your dreams will come true.
12;;
13;; This is a new, updated version.
14
15;;; Code:
16
17(defgroup simple-single nil "Simply a file"
18 :group 'lisp)
19
20(defcustom simple-single-super-sunday nil
21 "How great is this?
22Default changed to `nil'."
23 :type 'boolean
24 :group 'simple-single
25 :package-version "1.4")
26
27(defvar simple-single-sudo-sandwich nil
28 "Make a sandwich?")
29
30;;;###autoload
31(define-minor-mode simple-single-mode
32 "It does good things to stuff")
33
34(provide 'simple-single)
35
36;;; simple-single.el ends here
diff --git a/test/automated/data/package/simple-depend-1.0.el b/test/automated/data/package/simple-depend-1.0.el
new file mode 100644
index 00000000000..b58b658d024
--- /dev/null
+++ b/test/automated/data/package/simple-depend-1.0.el
@@ -0,0 +1,17 @@
1;;; simple-depend.el --- A single-file package with a dependency.
2
3;; Author: J. R. Hacker <jrh@example.com>
4;; Version: 1.0
5;; Keywords: frobnicate
6;; Package-Requires: ((simple-single "1.3"))
7
8;;; Commentary:
9
10;; Depends on another package.
11
12;;; Code:
13
14(defvar simple-depend "Value"
15 "Some trivial code")
16
17;;; simple-depend.el ends here
diff --git a/test/automated/data/package/simple-single-1.3.el b/test/automated/data/package/simple-single-1.3.el
new file mode 100644
index 00000000000..a61784164f8
--- /dev/null
+++ b/test/automated/data/package/simple-single-1.3.el
@@ -0,0 +1,32 @@
1;;; simple-single.el --- A single-file package with no dependencies
2
3;; Author: J. R. Hacker <jrh@example.com>
4;; Version: 1.3
5;; Keywords: frobnicate
6
7;;; Commentary:
8
9;; This package provides a minor mode to frobnicate and/or bifurcate
10;; any flanges you desire. To activate it, type "C-M-r M-3 butterfly"
11;; and all your dreams will come true.
12
13;;; Code:
14
15(defgroup simple-single nil "Simply a file"
16 :group 'lisp)
17
18(defcustom simple-single-super-sunday t
19 "How great is this?"
20 :type 'boolean
21 :group 'simple-single)
22
23(defvar simple-single-sudo-sandwich nil
24 "Make a sandwich?")
25
26;;;###autoload
27(define-minor-mode simple-single-mode
28 "It does good things to stuff")
29
30(provide 'simple-single)
31
32;;; simple-single.el ends here
diff --git a/test/automated/data/package/simple-single-readme.txt b/test/automated/data/package/simple-single-readme.txt
new file mode 100644
index 00000000000..25d3034032b
--- /dev/null
+++ b/test/automated/data/package/simple-single-readme.txt
@@ -0,0 +1,3 @@
1This package provides a minor mode to frobnicate and/or bifurcate
2any flanges you desire. To activate it, type "C-M-r M-3 butterfly"
3and all your dreams will come true.
diff --git a/test/automated/decoder-tests.el b/test/automated/decoder-tests.el
index 055626491c0..e1b05faf3c0 100644
--- a/test/automated/decoder-tests.el
+++ b/test/automated/decoder-tests.el
@@ -23,12 +23,14 @@
23 23
24(require 'ert) 24(require 'ert)
25 25
26;;; Check ASCII optimizing decoder
27
28;; Directory to hold test data files. 26;; Directory to hold test data files.
29(defvar decoder-tests-workdir 27(defvar decoder-tests-workdir
30 (expand-file-name "decoder-tests" temporary-file-directory)) 28 (expand-file-name "decoder-tests" temporary-file-directory))
31 29
30;; Remove all generated test files.
31(defun decoder-tests-remove-files ()
32 (delete-directory decoder-tests-workdir t))
33
32;; Return the contents (specified by CONTENT-TYPE; ascii, latin, or 34;; Return the contents (specified by CONTENT-TYPE; ascii, latin, or
33;; binary) of a test file. 35;; binary) of a test file.
34(defun decoder-tests-file-contents (content-type) 36(defun decoder-tests-file-contents (content-type)
@@ -43,25 +45,16 @@
43 (t 45 (t
44 (error "Invalid file content type: %s" content-type))))) 46 (error "Invalid file content type: %s" content-type)))))
45 47
46;; Return the name of test file whose contents specified by 48;; Generate FILE with CONTENTS encoded by CODING-SYSTEM.
47;; CONTENT-TYPE and whose encoding specified by CODING-SYSTEM.
48(defun decoder-tests-filename (content-type coding-system)
49 (expand-file-name (format "%s-%s" content-type coding-system)
50 decoder-tests-workdir))
51
52;; Generate a test file whose contents specified by CONTENT-TYPE and
53;; whose encoding specified by CODING-SYSTEM. 49;; whose encoding specified by CODING-SYSTEM.
54(defun decoder-tests-gen-file (content-type coding-system) 50(defun decoder-tests-gen-file (file contents coding-system)
55 (or (file-directory-p decoder-tests-workdir) 51 (or (file-directory-p decoder-tests-workdir)
56 (mkdir decoder-tests-workdir t)) 52 (mkdir decoder-tests-workdir t))
57 (let ((file (decoder-tests-filename content-type coding-system))) 53 (setq file (expand-file-name file decoder-tests-workdir))
58 (with-temp-file file 54 (with-temp-file file
59 (set-buffer-file-coding-system coding-system) 55 (set-buffer-file-coding-system coding-system)
60 (insert (decoder-tests-file-contents content-type))))) 56 (insert contents))
61 57 file)
62;; Remove all generated test files.
63(defun decoder-tests-remove-files ()
64 (delete-directory decoder-tests-workdir t))
65 58
66;;; The following three functions are filters for contents of a test 59;;; The following three functions are filters for contents of a test
67;;; file. 60;;; file.
@@ -96,6 +89,26 @@
96(defun decoder-tests-add-bom (str) 89(defun decoder-tests-add-bom (str)
97 (concat "\xfeff" str)) 90 (concat "\xfeff" str))
98 91
92;; Return the name of test file whose contents specified by
93;; CONTENT-TYPE and whose encoding specified by CODING-SYSTEM.
94(defun decoder-tests-filename (content-type coding-system &optional ext)
95 (if ext
96 (expand-file-name (format "%s-%s.%s" content-type coding-system ext)
97 decoder-tests-workdir)
98 (expand-file-name (format "%s-%s" content-type coding-system)
99 decoder-tests-workdir)))
100
101
102;;; Check ASCII optimizing decoder
103
104;; Generate a test file whose contents specified by CONTENT-TYPE and
105;; whose encoding specified by CODING-SYSTEM.
106(defun decoder-tests-ao-gen-file (content-type coding-system)
107 (let ((file (decoder-tests-filename content-type coding-system)))
108 (decoder-tests-gen-file file
109 (decoder-tests-file-contents content-type)
110 coding-system)))
111
99;; Test the decoding of a file whose contents and encoding are 112;; Test the decoding of a file whose contents and encoding are
100;; specified by CONTENT-TYPE and WRITE-CODING. The test passes if the 113;; specified by CONTENT-TYPE and WRITE-CODING. The test passes if the
101;; file is read by READ-CODING and detected as DETECTED-CODING and the 114;; file is read by READ-CODING and detected as DETECTED-CODING and the
@@ -127,7 +140,7 @@
127 (unwind-protect 140 (unwind-protect
128 (progn 141 (progn
129 (dolist (eol-type '(unix dos mac)) 142 (dolist (eol-type '(unix dos mac))
130 (decoder-tests-gen-file 'ascii eol-type)) 143 (decoder-tests-ao-gen-file 'ascii eol-type))
131 (should-not (decoder-tests 'ascii 'unix 'undecided 'unix)) 144 (should-not (decoder-tests 'ascii 'unix 'undecided 'unix))
132 (should-not (decoder-tests 'ascii 'dos 'undecided 'dos)) 145 (should-not (decoder-tests 'ascii 'dos 'undecided 'dos))
133 (should-not (decoder-tests 'ascii 'dos 'dos 'dos)) 146 (should-not (decoder-tests 'ascii 'dos 'dos 'dos))
@@ -147,8 +160,8 @@
147 (progn 160 (progn
148 (dolist (coding '("utf-8" "utf-8-with-signature")) 161 (dolist (coding '("utf-8" "utf-8-with-signature"))
149 (dolist (eol-type '("unix" "dos" "mac")) 162 (dolist (eol-type '("unix" "dos" "mac"))
150 (decoder-tests-gen-file 'latin 163 (decoder-tests-ao-gen-file 'latin
151 (intern (concat coding "-" eol-type))))) 164 (intern (concat coding "-" eol-type)))))
152 (should-not (decoder-tests 'latin 'utf-8-unix 'undecided 'utf-8-unix)) 165 (should-not (decoder-tests 'latin 'utf-8-unix 'undecided 'utf-8-unix))
153 (should-not (decoder-tests 'latin 'utf-8-unix 'utf-8-unix 'utf-8-unix)) 166 (should-not (decoder-tests 'latin 'utf-8-unix 'utf-8-unix 'utf-8-unix))
154 (should-not (decoder-tests 'latin 'utf-8-dos 'undecided 'utf-8-dos)) 167 (should-not (decoder-tests 'latin 'utf-8-dos 'undecided 'utf-8-dos))
@@ -177,8 +190,8 @@
177 (unwind-protect 190 (unwind-protect
178 (progn 191 (progn
179 (dolist (eol-type '("unix" "dos" "mac")) 192 (dolist (eol-type '("unix" "dos" "mac"))
180 (decoder-tests-gen-file 'binary 193 (decoder-tests-ao-gen-file 'binary
181 (intern (concat "raw-text" "-" eol-type)))) 194 (intern (concat "raw-text" "-" eol-type))))
182 (should-not (decoder-tests 'binary 'raw-text-unix 'undecided 195 (should-not (decoder-tests 'binary 'raw-text-unix 'undecided
183 'raw-text-unix)) 196 'raw-text-unix))
184 (should-not (decoder-tests 'binary 'raw-text-dos 'undecided 197 (should-not (decoder-tests 'binary 'raw-text-dos 'undecided
@@ -193,6 +206,64 @@
193 'raw-text-mac 'decoder-tests-lf-to-lflf))) 206 'raw-text-mac 'decoder-tests-lf-to-lflf)))
194 (decoder-tests-remove-files))) 207 (decoder-tests-remove-files)))
195 208
209
210;;; Check the coding system `prefer-utf-8'.
211
212;; Read FILE. Check if the encoding was detected as DETECT. If
213;; PREFER is non-nil, prefer that coding system before reading.
214
215(defun decoder-tests-prefer-utf-8-read (file detect prefer)
216 (if prefer
217 (prefer-coding-system prefer))
218 (with-temp-buffer
219 (insert-file-contents file)
220 (if (eq buffer-file-coding-system detect)
221 nil
222 (format "Invalid detection: %s" buffer-file-coding-system))))
223
224;; Read FILE, modify it, and write it. Check if the coding system
225;; used for writing was CODING. If CODING-TAG is non-nil, insert
226;; coding tag with it before writing. If STR is non-nil, insert it
227;; before writing.
228
229(defun decoder-tests-prefer-utf-8-write (file coding-tag coding
230 &optional str)
231 (with-temp-buffer
232 (insert-file-contents file)
233 (goto-char (point-min))
234 (if coding-tag
235 (insert (format ";; -*- coding: %s; -*-\n" coding-tag))
236 (insert ";;\n"))
237 (if str
238 (insert str))
239 (write-file (decoder-tests-filename 'test 'test "el"))
240 (if (coding-system-equal buffer-file-coding-system coding)
241 nil
242 (format "Incorrect encoding: %s" last-coding-system-used))))
243
244(ert-deftest ert-test-decoder-prefer-utf-8 ()
245 (unwind-protect
246 (let ((ascii (decoder-tests-gen-file "ascii.el"
247 (decoder-tests-file-contents 'ascii)
248 'unix))
249 (latin (decoder-tests-gen-file "utf-8.el"
250 (decoder-tests-file-contents 'latin)
251 'utf-8)))
252 (should-not (decoder-tests-prefer-utf-8-read
253 ascii 'prefer-utf-8-unix nil))
254 (should-not (decoder-tests-prefer-utf-8-read
255 latin 'utf-8-unix nil))
256 (should-not (decoder-tests-prefer-utf-8-read
257 latin 'utf-8-unix 'iso-8859-1))
258 (should-not (decoder-tests-prefer-utf-8-read
259 latin 'utf-8-unix 'sjis))
260 (should-not (decoder-tests-prefer-utf-8-write
261 ascii nil 'prefer-utf-8-unix))
262 (should-not (decoder-tests-prefer-utf-8-write
263 ascii 'iso-8859-1 'iso-8859-1-unix))
264 (should-not (decoder-tests-prefer-utf-8-write
265 ascii nil 'utf-8-unix "Ă€")))
266 (decoder-tests-remove-files)))
196 267
197 268
198;;; The following is for benchmark testing of the new optimized 269;;; The following is for benchmark testing of the new optimized
diff --git a/test/automated/flymake-tests.el b/test/automated/flymake-tests.el
new file mode 100644
index 00000000000..9cc87b608ad
--- /dev/null
+++ b/test/automated/flymake-tests.el
@@ -0,0 +1,82 @@
1;;; flymake-tests.el --- Test suite for flymake
2
3;; Copyright (C) 2011-2013 Free Software Foundation, Inc.
4
5;; Author: Eduard Wiebe <usenet@pusto.de>
6
7;; This file is part of GNU Emacs.
8
9;; GNU Emacs is free software: you can redistribute it and/or modify
10;; it under the terms of the GNU General Public License as published by
11;; the Free Software Foundation, either version 3 of the License, or
12;; (at your option) any later version.
13
14;; GNU Emacs is distributed in the hope that it will be useful,
15;; but WITHOUT ANY WARRANTY; without even the implied warranty of
16;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17;; GNU General Public License for more details.
18
19;; You should have received a copy of the GNU General Public License
20;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
21
22;;; Commentary:
23
24;;; Code:
25(require 'ert)
26(require 'flymake)
27
28(defgroup flymake-tests nil
29 "Test suite for flymake.")
30
31
32;; Warning predicate
33(defun flymake-tests--current-face (file predicate)
34 (let ((buffer (find-file-noselect file)))
35 (unwind-protect
36 (with-current-buffer (find-file-noselect file)
37 (setq-local flymake-warning-predicate predicate)
38 (goto-char (point-min))
39 (flymake-mode 1)
40 ;; XXX: is this reliable enough?
41 (sleep-for (+ 0.5 flymake-no-changes-timeout))
42 (flymake-goto-next-error)
43 (face-at-point))
44 (and buffer (kill-buffer buffer)))))
45
46(ert-deftest warning-predicate-rx-gcc ()
47 "Test GCC warning via regexp predicate."
48 :expected-result (if (executable-find "gcc") :passed :failed)
49 (should (eq 'flymake-warnline
50 (flymake-tests--current-face
51 "flymake/warnpred/test.c"
52 "^[Ww]arning"))))
53
54(ert-deftest warning-predicate-function-gcc ()
55 "Test GCC warning via function predicate."
56 :expected-result (if (and (executable-find "gcc") (executable-find "make"))
57 :passed
58 :failed)
59 (should (eq 'flymake-warnline
60 (flymake-tests--current-face
61 "flymake/warnpred/test.c"
62 (lambda (msg) (string-match "^[Ww]arning" msg))))))
63
64(ert-deftest warning-predicate-rx-perl ()
65 "Test perl warning via regular expression predicate."
66 :expected-result (if (executable-find "perl") :passed :failed)
67 (should (eq 'flymake-warnline
68 (flymake-tests--current-face
69 "flymake/warnpred/test.pl"
70 "^Scalar value"))))
71
72(ert-deftest warning-predicate-function-perl ()
73 "Test perl warning via function predicate."
74 :expected-result (if (executable-find "perl") :passed :failed)
75 (should (eq 'flymake-warnline
76 (flymake-tests--current-face
77 "flymake/warnpred/test.pl"
78 (lambda (msg) (string-match "^Scalar value" msg))))))
79
80(provide 'flymake-tests)
81
82;;; flymake.el ends here
diff --git a/test/automated/flymake/warnpred/Makefile b/test/automated/flymake/warnpred/Makefile
new file mode 100644
index 00000000000..33af51c3337
--- /dev/null
+++ b/test/automated/flymake/warnpred/Makefile
@@ -0,0 +1,8 @@
1# Makefile for flymake tests
2
3CC_OPTS = -Wall
4
5check-syntax:
6 $(CC) $(CC_OPTS) ${CHK_SOURCES}
7
8# eof
diff --git a/test/automated/flymake/warnpred/test.c b/test/automated/flymake/warnpred/test.c
new file mode 100644
index 00000000000..3a3926131f5
--- /dev/null
+++ b/test/automated/flymake/warnpred/test.c
@@ -0,0 +1,5 @@
1int main()
2{
3 char c = 1000;
4 return c;
5}
diff --git a/test/automated/flymake/warnpred/test.pl b/test/automated/flymake/warnpred/test.pl
new file mode 100644
index 00000000000..2013b2e4434
--- /dev/null
+++ b/test/automated/flymake/warnpred/test.pl
@@ -0,0 +1,2 @@
1@arr = [1,2,3,4];
2@arr[1] = -1;
diff --git a/test/automated/info-xref.el b/test/automated/info-xref.el
new file mode 100644
index 00000000000..973af0d46c7
--- /dev/null
+++ b/test/automated/info-xref.el
@@ -0,0 +1,148 @@
1;;; info-xref.el --- tests for info-xref.el
2
3;; Copyright (C) 2013 Free Software Foundation, Inc.
4
5;; This file is part of GNU Emacs.
6
7;; GNU Emacs is free software: you can redistribute it and/or modify
8;; it under the terms of the GNU General Public License as published by
9;; the Free Software Foundation, either version 3 of the License, or
10;; (at your option) any later version.
11
12;; GNU Emacs is distributed in the hope that it will be useful,
13;; but 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 Emacs. If not, see <http://www.gnu.org/licenses/>.
19
20;;; Commentary:
21
22;;; Code:
23
24(require 'ert)
25(require 'info-xref)
26
27(defun info-xref-test-internal (body result)
28 "Body of a basic info-xref ert test.
29BODY is a string from an info buffer.
30RESULT is a list (NBAD NGOOD NUNAVAIL)."
31 (get-buffer-create info-xref-output-buffer)
32 (setq info-xref-xfile-alist nil)
33 (require 'info)
34 (let ((Info-directory-list '("."))
35 Info-additional-directory-list)
36 (info-xref-with-output
37 (with-temp-buffer
38 (insert body)
39 (info-xref-check-buffer))))
40 (should (equal result (list info-xref-bad info-xref-good info-xref-unavail)))
41 ;; If there was an error, we can leave this around.
42 (kill-buffer info-xref-output-buffer))
43
44(ert-deftest info-xref-test-node-crossref ()
45 "Test parsing of @xref{node,crossref,,manual} with Texinfo 4/5."
46 (info-xref-test-internal "
47*Note crossref: (manual-foo)node. Texinfo 4/5 format with crossref.
48" '(0 0 1)))
49
50(ert-deftest info-xref-test-node-4 ()
51 "Test parsing of @xref{node,,,manual} with Texinfo 4."
52 (info-xref-test-internal "
53*Note node: (manual-foo)node. Texinfo 4 format with no crossref.
54" '(0 0 1)))
55
56(ert-deftest info-xref-test-node-5 ()
57 "Test parsing of @xref{node,,,manual} with Texinfo 5."
58 (info-xref-test-internal "
59*Note (manual-foo)node::. Texinfo 5 format with no crossref.
60" '(0 0 1)))
61
62;; TODO Easier to have static data files in the repo?
63(defun info-xref-test-write-file (file body)
64 "Write BODY to texi FILE."
65 (with-temp-buffer
66 (insert "\
67\input texinfo
68@setfilename "
69 (format "%s.info\n" (file-name-sans-extension file))
70 "\
71@settitle test
72
73@ifnottex
74@node Top
75@top test
76@end ifnottex
77
78@menu
79* Chapter One::
80@end menu
81
82@node Chapter One
83@chapter Chapter One
84
85text.
86
87"
88 body
89 "\
90@bye
91"
92 )
93 (write-region nil nil file nil 'silent))
94 (should (equal 0 (call-process "makeinfo" file))))
95
96(ert-deftest info-xref-test-makeinfo ()
97 "Test that info-xref can parse basic makeinfo output."
98 :expected-result (if (executable-find "makeinfo") :passed :failed)
99 (should (executable-find "makeinfo"))
100 (let ((tempfile (make-temp-file "info-xref-test" nil ".texi"))
101 (tempfile2 (make-temp-file "info-xref-test2" nil ".texi"))
102 (errflag t))
103 (unwind-protect
104 (progn
105 ;; tempfile contains xrefs to various things, including tempfile2.
106 (info-xref-test-write-file
107 tempfile
108 (concat "\
109@xref{nodename,,,missing,Missing Manual}.
110
111@xref{nodename,crossref,title,missing,Missing Manual}.
112
113@xref{Chapter One}.
114
115@xref{Chapter One,Something}.
116
117"
118 (format "@xref{Chapter One,,,%s,Present Manual}.\n"
119 (file-name-sans-extension (file-name-nondirectory
120 tempfile2)))))
121 ;; Something for tempfile to xref to.
122 (info-xref-test-write-file tempfile2 "")
123 (require 'info)
124 (save-window-excursion
125 (let ((Info-directory-list
126 (list
127 (or (file-name-directory tempfile) ".")))
128 Info-additional-directory-list)
129 (info-xref-check (format "%s.info" (file-name-sans-extension
130 tempfile))))
131 (should (equal (list info-xref-bad info-xref-good
132 info-xref-unavail)
133 '(0 1 2)))
134 (setq errflag nil)
135 ;; If there was an error, we can leave this around.
136 (kill-buffer info-xref-output-buffer)))
137 ;; Useful diagnostic in case of problems.
138 (if errflag
139 (with-temp-buffer
140 (call-process "makeinfo" nil t nil "--version")
141 (message "%s" (buffer-string))))
142 (mapc 'delete-file (list tempfile tempfile2
143 (format "%s.info" (file-name-sans-extension
144 tempfile))
145 (format "%s.info" (file-name-sans-extension
146 tempfile2)))))))
147
148;;; info-xref.el ends here
diff --git a/test/automated/occur-tests.el b/test/automated/occur-tests.el
index 7cc4df6bffa..306803b7567 100644
--- a/test/automated/occur-tests.el
+++ b/test/automated/occur-tests.el
@@ -35,7 +35,7 @@ xd
35xex 35xex
36fx 36fx
37" "\ 37" "\
385 matches for \"x\" in buffer: *test-occur* 386 matches in 5 lines for \"x\" in buffer: *test-occur*
39 1:xa 39 1:xa
40 3:cx 40 3:cx
41 4:xd 41 4:xd
@@ -335,12 +335,18 @@ Each element has the format:
335 (and (buffer-name temp-buffer) 335 (and (buffer-name temp-buffer)
336 (kill-buffer temp-buffer))))) 336 (kill-buffer temp-buffer)))))
337 337
338(ert-deftest occur-tests () 338(defun occur-test-create (n)
339 "Test the functionality of `occur'. 339 "Create a test for element N of the `occur-tests' constant."
340The test data is in the `occur-tests' constant." 340 (let ((testname (intern (format "occur-test-%.2d" n)))
341 (let ((occur-hook nil)) 341 (testdoc (format "Test element %d of `occur-tests'." n)))
342 (dolist (test occur-tests) 342 (eval
343 (should (occur-test-case test))))) 343 `(ert-deftest ,testname ()
344 ,testdoc
345 (let (occur-hook)
346 (should (occur-test-case (nth ,n occur-tests))))))))
347
348(dotimes (i (length occur-tests))
349 (occur-test-create i))
344 350
345(provide 'occur-tests) 351(provide 'occur-tests)
346 352
diff --git a/test/automated/package-test.el b/test/automated/package-test.el
new file mode 100755
index 00000000000..706ba953d98
--- /dev/null
+++ b/test/automated/package-test.el
@@ -0,0 +1,398 @@
1;;; package-test.el --- Tests for the Emacs package system
2
3;; Copyright (C) 2013 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-test.el -l ert -f ert-run-tests-batch-and-exit
32
33;;; Code:
34
35(require 'package)
36(require 'ert)
37(require 'cl-lib)
38
39(defvar package-test-user-dir nil
40 "Directory to use for installing packages during testing.")
41
42(defvar package-test-file-dir (file-name-directory (or load-file-name
43 buffer-file-name))
44 "Directory of the actual \"package-test.el\" file.")
45
46(defvar simple-single-desc
47 (package-desc-create :name 'simple-single
48 :version '(1 3)
49 :summary "A single-file package with no dependencies"
50 :kind 'single)
51 "Expected `package-desc' parsed from simple-single-1.3.el.")
52
53(defvar simple-single-desc-1-4
54 (package-desc-create :name 'simple-single
55 :version '(1 4)
56 :summary "A single-file package with no dependencies"
57 :kind 'single)
58 "Expected `package-desc' parsed from simple-single-1.4.el.")
59
60(defvar simple-depend-desc
61 (package-desc-create :name 'simple-depend
62 :version '(1 0)
63 :summary "A single-file package with a dependency."
64 :kind 'single
65 :reqs '((simple-single (1 3))))
66 "Expected `package-desc' parsed from simple-depend-1.0.el.")
67
68(defvar multi-file-desc
69 (package-desc-create :name 'multi-file
70 :version '(0 2 3)
71 :summary "Example of a multi-file tar package"
72 :kind 'tar)
73 "Expected `package-desc' from \"multi-file-0.2.3.tar\".")
74
75(defvar new-pkg-desc
76 (package-desc-create :name 'new-pkg
77 :version '(1 0)
78 :kind 'single)
79 "Expected `package-desc' parsed from new-pkg-1.0.el.")
80
81(defvar package-test-data-dir (expand-file-name "data/package" package-test-file-dir)
82 "Base directory of package test files.")
83
84(defvar package-test-fake-contents-file
85 (expand-file-name "archive-contents" package-test-data-dir)
86 "Path to a static copy of \"archive-contents\".")
87
88(defvar package-test-built-file-suffixes '(".tar" "/dir" "/*.info")
89 "Remove these files when cleaning up a built package.")
90
91(cl-defmacro with-package-test ((&optional &key file
92 basedir
93 install
94 update-news
95 upload-base)
96 &rest body)
97 "Set up temporary locations and variables for testing."
98 (declare (indent 1))
99 `(let* ((package-test-user-dir (make-temp-file "pkg-test-user-dir-" t))
100 (package-user-dir package-test-user-dir)
101 (package-archives `(("gnu" . ,package-test-data-dir)))
102 (old-yes-no-defn (symbol-function 'yes-or-no-p))
103 (old-pwd default-directory)
104 package--initialized
105 package-alist
106 ,@(if update-news
107 '(package-update-news-on-upload t)
108 (list (cl-gensym)))
109 ,@(if upload-base
110 '((package-test-archive-upload-base (make-temp-file "pkg-archive-base-" t))
111 (package-archive-upload-base package-test-archive-upload-base))
112 (list (cl-gensym)))) ;; Dummy value so `let' doesn't try to bind `nil'
113 (unwind-protect
114 (progn
115 ,(if basedir `(cd ,basedir))
116 (setf (symbol-function 'yes-or-no-p) #'(lambda (&rest r) t))
117 (unless (file-directory-p package-user-dir)
118 (mkdir package-user-dir))
119 ,@(when install
120 `((package-initialize)
121 (package-refresh-contents)
122 (mapc 'package-install ,install)))
123 (with-temp-buffer
124 ,(if file
125 `(insert-file-contents ,file))
126 ,@body))
127
128 (when (file-directory-p package-test-user-dir)
129 (delete-directory package-test-user-dir t))
130
131 (when (and (boundp 'package-test-archive-upload-base)
132 (file-directory-p package-test-archive-upload-base))
133 (delete-directory package-test-archive-upload-base t))
134 (setf (symbol-function 'yes-or-no-p) old-yes-no-defn)
135 (cd old-pwd))))
136
137(defmacro with-fake-help-buffer (&rest body)
138 "Execute BODY in a temp buffer which is treated as the \"*Help*\" buffer."
139 `(with-temp-buffer
140 (help-mode)
141 ;; Trick `help-buffer' into using the temp buffer.
142 (let ((help-xref-following t))
143 ,@body)))
144
145(defun package-test-install-texinfo (file)
146 "Install from texinfo FILE.
147
148FILE should be a .texinfo file relative to the current
149`default-directory'"
150 (require 'info)
151 (let* ((full-file (expand-file-name file))
152 (info-file (replace-regexp-in-string "\\.texi\\'" ".info" full-file))
153 (old-info-defn (symbol-function 'Info-revert-find-node)))
154 (require 'info)
155 (setf (symbol-function 'Info-revert-find-node) #'ignore)
156 (with-current-buffer (find-file-literally full-file)
157 (unwind-protect
158 (progn
159 (require 'makeinfo)
160 (makeinfo-buffer)
161 ;; Give `makeinfo-buffer' a chance to finish
162 (while compilation-in-progress
163 (sit-for 0.1))
164 (call-process "ginstall-info" nil nil nil
165 (format "--info-dir=%s" default-directory)
166 (format "%s" info-file)))
167 (kill-buffer)
168 (setf (symbol-function 'Info-revert-find-node) old-info-defn)))))
169
170(defun package-test-strip-version (dir)
171 (replace-regexp-in-string "-pkg\\.el\\'" "" (package--description-file dir)))
172
173(defun package-test-suffix-matches (base suffix-list)
174 "Return file names matching BASE concatenated with each item in SUFFIX-LIST"
175 (cl-mapcan
176 '(lambda (item) (file-expand-wildcards (concat base item)))
177 suffix-list))
178
179(defun package-test-cleanup-built-files (dir)
180 "Remove files which were the result of creating a tar archive.
181
182DIR is the base name of the package directory, without the trailing slash"
183 (let* ((pkg-dirname (file-name-nondirectory dir)))
184 (dolist (file (package-test-suffix-matches dir package-test-built-file-suffixes))
185 (delete-file file))))
186
187(defun package-test-search-tar-file (filename)
188 "Search the current buffer's `tar-parse-info' variable for FILENAME.
189
190Must called from within a `tar-mode' buffer."
191 (cl-dolist (header tar-parse-info)
192 (let ((tar-name (tar-header-name header)))
193 (when (string= tar-name filename)
194 (cl-return t)))))
195
196(defun package-test-desc-version-string (desc)
197 "Return the package version as a string."
198 (package-version-join (package-desc-version desc)))
199
200(ert-deftest package-test-desc-from-buffer ()
201 "Parse an elisp buffer to get a `package-desc' object."
202 (with-package-test (:basedir "data/package" :file "simple-single-1.3.el")
203 (should (equal (package-buffer-info) simple-single-desc)))
204 (with-package-test (:basedir "data/package" :file "simple-depend-1.0.el")
205 (should (equal (package-buffer-info) simple-depend-desc)))
206 (with-package-test (:basedir "data/package"
207 :file "multi-file-0.2.3.tar")
208 (tar-mode)
209 (should (equal (package-tar-file-info) multi-file-desc))))
210
211(ert-deftest package-test-install-single ()
212 "Install a single file without using an archive."
213 (with-package-test (:basedir "data/package" :file "simple-single-1.3.el")
214 (should (package-install-from-buffer))
215 (package-initialize)
216 (should (package-installed-p 'simple-single))
217 (let* ((simple-pkg-dir (file-name-as-directory
218 (expand-file-name
219 "simple-single-1.3"
220 package-test-user-dir)))
221 (autoloads-file (expand-file-name "simple-single-autoloads.el"
222 simple-pkg-dir)))
223 (should (file-directory-p simple-pkg-dir))
224 (with-temp-buffer
225 (insert-file-contents (expand-file-name "simple-single-pkg.el"
226 simple-pkg-dir))
227 (should (string= (buffer-string)
228 (concat "(define-package \"simple-single\" \"1.3\" "
229 "\"A single-file package "
230 "with no dependencies\" 'nil)\n"))))
231 (should (file-exists-p autoloads-file))
232 (should-not (get-file-buffer autoloads-file)))))
233
234(ert-deftest package-test-install-dependency ()
235 "Install a package which includes a dependency."
236 (with-package-test ()
237 (package-initialize)
238 (package-refresh-contents)
239 (package-install 'simple-depend)
240 (should (package-installed-p 'simple-single))
241 (should (package-installed-p 'simple-depend))))
242
243(ert-deftest package-test-refresh-contents ()
244 "Parse an \"archive-contents\" file."
245 (with-package-test ()
246 (package-initialize)
247 (package-refresh-contents)
248 (should (eq 3 (length package-archive-contents)))))
249
250(ert-deftest package-test-install-single-from-archive ()
251 "Install a single package from a package archive."
252 (with-package-test ()
253 (package-initialize)
254 (package-refresh-contents)
255 (package-install 'simple-single)))
256
257(ert-deftest package-test-install-multifile ()
258 "Check properties of the installed multi-file package."
259 (with-package-test (:basedir "data/package" :install '(multi-file))
260 (let ((autoload-file
261 (expand-file-name "multi-file-autoloads.el"
262 (expand-file-name
263 "multi-file-0.2.3"
264 package-test-user-dir)))
265 (installed-files '("dir" "multi-file.info" "multi-file-sub.elc"
266 "multi-file-autoloads.el" "multi-file.elc"))
267 (autoload-forms '("^(defvar multi-file-custom-var"
268 "^(custom-autoload 'multi-file-custom-var"
269 "^(autoload 'multi-file-mode"))
270 (pkg-dir (file-name-as-directory
271 (expand-file-name
272 "multi-file-0.2.3"
273 package-test-user-dir))))
274 (package-refresh-contents)
275 (should (package-installed-p 'multi-file))
276 (with-temp-buffer
277 (insert-file-contents-literally autoload-file)
278 (dolist (fn installed-files)
279 (should (file-exists-p (expand-file-name fn pkg-dir))))
280 (dolist (re autoload-forms)
281 (goto-char (point-min))
282 (should (re-search-forward re nil t)))))))
283
284(ert-deftest package-test-update-listing ()
285 "Ensure installed package status is updated."
286 (with-package-test ()
287 (let ((buf (package-list-packages)))
288 (search-forward-regexp "^ +simple-single")
289 (package-menu-mark-install)
290 (package-menu-execute)
291 (should (package-installed-p 'simple-single))
292 (switch-to-buffer "*Packages*")
293 (goto-char (point-min))
294 (should (re-search-forward "^\\s-+simple-single\\s-+1.3\\s-+installed" nil t))
295 (goto-char (point-min))
296 (should-not (re-search-forward "^\\s-+simple-single\\s-+1.3\\s-+\\(available\\|new\\)" nil t))
297 (kill-buffer buf))))
298
299(ert-deftest package-test-update-archives ()
300 "Test updating package archives."
301 (with-package-test ()
302 (let ((buf (package-list-packages)))
303 (package-menu-refresh)
304 (search-forward-regexp "^ +simple-single")
305 (package-menu-mark-install)
306 (package-menu-execute)
307 (should (package-installed-p 'simple-single))
308 (let ((package-test-data-dir
309 (expand-file-name "data/package/newer-versions" package-test-file-dir)))
310 (setq package-archives `(("gnu" . ,package-test-data-dir)))
311 (package-menu-refresh)
312
313 ;; New version should be available and old version should be installed
314 (goto-char (point-min))
315 (should (re-search-forward "^\\s-+simple-single\\s-+1.4\\s-+new" nil t))
316 (should (re-search-forward "^\\s-+simple-single\\s-+1.3\\s-+installed" nil t))
317
318 (goto-char (point-min))
319 (should (re-search-forward "^\\s-+new-pkg\\s-+1.0\\s-+\\(available\\|new\\)" nil t))
320
321 (package-menu-mark-upgrades)
322 (package-menu-execute)
323 (package-menu-refresh)
324 (should (package-installed-p 'simple-single '(1 4)))))))
325
326(ert-deftest package-test-describe-package ()
327 "Test displaying help for a package."
328
329 (require 'finder-inf)
330 ;; Built-in
331 (with-fake-help-buffer
332 (describe-package '5x5)
333 (goto-char (point-min))
334 (should (search-forward "5x5 is a built-in package." nil t))
335 (should (search-forward "Status: Built-in." nil t))
336 (should (search-forward "Summary: simple little puzzle game" nil t))
337 (should (search-forward "The aim of 5x5" nil t)))
338
339 ;; Installed
340 (with-package-test ()
341 (package-initialize)
342 (package-refresh-contents)
343 (package-install 'simple-single)
344 (with-fake-help-buffer
345 (describe-package 'simple-single)
346 (goto-char (point-min))
347 (should (search-forward "simple-single is an installed package." nil t))
348 (should (search-forward
349 (format "Status: Installed in `%s/'."
350 (expand-file-name "simple-single-1.3" package-user-dir))
351 nil t))
352 (should (search-forward "Version: 1.3" nil t))
353 (should (search-forward "Summary: A single-file package with no dependencies"
354 nil t))
355 ;; No description, though. Because at this point we don't know
356 ;; what archive the package originated from, and we don't have
357 ;; its readme file saved.
358 )))
359
360(ert-deftest package-test-describe-not-installed-package ()
361 "Test displaying of the readme for not-installed package."
362
363 (with-package-test ()
364 (package-initialize)
365 (package-refresh-contents)
366 (with-fake-help-buffer
367 (describe-package 'simple-single)
368 (goto-char (point-min))
369 (should (search-forward "This package provides a minor mode to frobnicate"
370 nil t)))))
371
372(ert-deftest package-test-describe-non-installed-package ()
373 "Test displaying of the readme for non-installed package."
374
375 (with-package-test ()
376 (package-initialize)
377 (package-refresh-contents)
378 (with-fake-help-buffer
379 (describe-package 'simple-single)
380 (goto-char (point-min))
381 (should (search-forward "This package provides a minor mode to frobnicate"
382 nil t)))))
383
384(ert-deftest package-test-describe-non-installed-multi-file-package ()
385 "Test displaying of the readme for non-installed multi-file package."
386
387 (with-package-test ()
388 (package-initialize)
389 (package-refresh-contents)
390 (with-fake-help-buffer
391 (describe-package 'multi-file)
392 (goto-char (point-min))
393 (should (search-forward "This is a bare-bones readme file for the multi-file"
394 nil t)))))
395
396(provide 'package-test)
397
398;;; package-test.el ends here
diff --git a/test/automated/package-x-test.el b/test/automated/package-x-test.el
new file mode 100755
index 00000000000..b8f2a23f6d5
--- /dev/null
+++ b/test/automated/package-x-test.el
@@ -0,0 +1,107 @@
1;;; package-test.el --- Tests for the Emacs package system
2
3;; Copyright (C) 2013 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
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
42 buffer-file-name)))
43 load-path)))
44 (require 'package-test))
45
46(defvar package-x-test--single-archive-entry-1-3
47 (cons 'simple-single
48 (package-make-ac-desc '(1 3) nil
49 "A single-file package with no dependencies"
50 'single))
51 "Expected contents of the archive entry from the \"simple-single\" package.")
52
53(defvar package-x-test--single-archive-entry-1-4
54 (cons 'simple-single
55 (package-make-ac-desc '(1 4) nil
56 "A single-file package with no dependencies"
57 'single))
58 "Expected contents of the archive entry from the updated \"simple-single\" package.")
59
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"
64 :upload-base t)
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)))
72
73 (let (archive-contents)
74 (with-temp-buffer
75 (insert-file-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))))))
83
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"
88 :upload-base t)
89 (package-upload-buffer)
90 (with-temp-buffer
91 (insert-file-contents "newer-versions/simple-single-1.4.el")
92 (package-upload-buffer))
93
94 (let (archive-contents)
95 (with-temp-buffer
96 (insert-file-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))))))
104
105(provide 'package-x-test)
106
107;;; package-x-test.el ends here
diff --git a/test/automated/python-tests.el b/test/automated/python-tests.el
index 8462a863b84..40505cc7953 100644
--- a/test/automated/python-tests.el
+++ b/test/automated/python-tests.el
@@ -39,7 +39,8 @@ always located at the beginning of buffer."
39BODY is code to be executed within the temp buffer. Point is 39BODY is code to be executed within the temp buffer. Point is
40always located at the beginning of buffer." 40always located at the beginning of buffer."
41 (declare (indent 1) (debug t)) 41 (declare (indent 1) (debug t))
42 `(let* ((temp-file (concat (make-temp-file "python-tests") ".py")) 42 ;; temp-file never actually used for anything?
43 `(let* ((temp-file (make-temp-file "python-tests" nil ".py"))
43 (buffer (find-file-noselect temp-file))) 44 (buffer (find-file-noselect temp-file)))
44 (unwind-protect 45 (unwind-protect
45 (with-current-buffer buffer 46 (with-current-buffer buffer
@@ -47,7 +48,8 @@ always located at the beginning of buffer."
47 (insert ,contents) 48 (insert ,contents)
48 (goto-char (point-min)) 49 (goto-char (point-min))
49 ,@body) 50 ,@body)
50 (and buffer (kill-buffer buffer))))) 51 (and buffer (kill-buffer buffer))
52 (delete-file temp-file))))
51 53
52(defun python-tests-look-at (string &optional num restore-point) 54(defun python-tests-look-at (string &optional num restore-point)
53 "Move point at beginning of STRING in the current buffer. 55 "Move point at beginning of STRING in the current buffer.
diff --git a/test/automated/ruby-mode-tests.el b/test/automated/ruby-mode-tests.el
index 77dd62821f7..a18899df02f 100644
--- a/test/automated/ruby-mode-tests.el
+++ b/test/automated/ruby-mode-tests.el
@@ -87,6 +87,9 @@ VALUES-PLIST is a list with alternating index and value elements."
87(ert-deftest ruby-heredoc-highlights-interpolations () 87(ert-deftest ruby-heredoc-highlights-interpolations ()
88 (ruby-assert-face "s = <<EOS\n #{foo}\nEOS" 15 font-lock-variable-name-face)) 88 (ruby-assert-face "s = <<EOS\n #{foo}\nEOS" 15 font-lock-variable-name-face))
89 89
90(ert-deftest ruby-no-heredoc-inside-quotes ()
91 (ruby-assert-state "\"<<\", \"\",\nfoo" 3 nil))
92
90(ert-deftest ruby-deep-indent () 93(ert-deftest ruby-deep-indent ()
91 (let ((ruby-deep-arglist nil) 94 (let ((ruby-deep-arglist nil)
92 (ruby-deep-indent-paren '(?\( ?\{ ?\[ ?\] t))) 95 (ruby-deep-indent-paren '(?\( ?\{ ?\[ ?\] t)))
@@ -124,6 +127,12 @@ VALUES-PLIST is a list with alternating index and value elements."
124(ert-deftest ruby-regexp-can-be-multiline () 127(ert-deftest ruby-regexp-can-be-multiline ()
125 (ruby-assert-state "/bars\ntees # toots \nfoos/" 3 nil)) 128 (ruby-assert-state "/bars\ntees # toots \nfoos/" 3 nil))
126 129
130(ert-deftest ruby-slash-symbol-is-not-mistaken-for-regexp ()
131 (ruby-assert-state ":/" 3 nil))
132
133(ert-deftest ruby-slash-char-literal-is-not-mistaken-for-regexp ()
134 (ruby-assert-state "?/" 3 nil))
135
127(ert-deftest ruby-indent-simple () 136(ert-deftest ruby-indent-simple ()
128 (ruby-should-indent-buffer 137 (ruby-should-indent-buffer
129 "if foo 138 "if foo
diff --git a/test/automated/undo-tests.el b/test/automated/undo-tests.el
index 3037db03602..98b0c52728b 100644
--- a/test/automated/undo-tests.el
+++ b/test/automated/undo-tests.el
@@ -1,6 +1,6 @@
1;;; undo-tests.el --- Tests of primitive-undo 1;;; undo-tests.el --- Tests of primitive-undo
2 2
3;; Copyright (C) 2012 Aaron S. Hawley 3;; Copyright (C) 2012-2013 Free Software Foundation, Inc.
4 4
5;; Author: Aaron S. Hawley <aaron.s.hawley@gmail.com> 5;; Author: Aaron S. Hawley <aaron.s.hawley@gmail.com>
6 6
@@ -140,26 +140,6 @@
140 (undo) 140 (undo)
141 (buffer-string)))))) 141 (buffer-string))))))
142 142
143(ert-deftest undo-test3 ()
144 "Test modtime with \\[undo] command."
145 (let ((tmpfile (make-temp-file "undo-test3")))
146 (with-temp-file tmpfile
147 (let ((buffer-file-name tmpfile))
148 (buffer-enable-undo)
149 (set (make-local-variable 'make-backup-files) nil)
150 (undo-boundary)
151 (insert ?\s)
152 (undo-boundary)
153 (basic-save-buffer)
154 (insert ?\t)
155 (undo)
156 (should
157 (string-equal (buffer-string)
158 (progn
159 (undo)
160 (buffer-string)))))
161 (delete-file tmpfile))))
162
163(ert-deftest undo-test4 () 143(ert-deftest undo-test4 ()
164 "Test \\[undo] of \\[flush-lines]." 144 "Test \\[undo] of \\[flush-lines]."
165 (with-temp-buffer 145 (with-temp-buffer