Mercurial > emacs
annotate test/automated/ert-x-tests.el @ 112399:51005885fe39
aclocal.m4: tweaks to regenerate more conveniently
This attempts to act better when the source is in a weird state. See
<http://lists.gnu.org/archive/html/emacs-devel/2011-01/msg00734.html>.
* Makefile.in (am--refresh): Add aclocal.m4, configure, config.in.
* .bzrignore: Add aclocal.m4.
author | Paul Eggert <eggert@cs.ucla.edu> |
---|---|
date | Fri, 21 Jan 2011 12:23:24 -0800 |
parents | c5917804ecad |
children |
rev | line source |
---|---|
112201
c5917804ecad
Add ERT, a tool for automated testing in Emacs Lisp.
Christian Ohler <ohler@gnu.org>
parents:
diff
changeset
|
1 ;;; ert-x-tests.el --- Tests for ert-x.el |
c5917804ecad
Add ERT, a tool for automated testing in Emacs Lisp.
Christian Ohler <ohler@gnu.org>
parents:
diff
changeset
|
2 |
c5917804ecad
Add ERT, a tool for automated testing in Emacs Lisp.
Christian Ohler <ohler@gnu.org>
parents:
diff
changeset
|
3 ;; Copyright (C) 2008, 2010, 2011 Free Software Foundation, Inc. |
c5917804ecad
Add ERT, a tool for automated testing in Emacs Lisp.
Christian Ohler <ohler@gnu.org>
parents:
diff
changeset
|
4 |
c5917804ecad
Add ERT, a tool for automated testing in Emacs Lisp.
Christian Ohler <ohler@gnu.org>
parents:
diff
changeset
|
5 ;; Author: Phil Hagelberg |
c5917804ecad
Add ERT, a tool for automated testing in Emacs Lisp.
Christian Ohler <ohler@gnu.org>
parents:
diff
changeset
|
6 ;; Author: Christian Ohler <ohler@gnu.org> |
c5917804ecad
Add ERT, a tool for automated testing in Emacs Lisp.
Christian Ohler <ohler@gnu.org>
parents:
diff
changeset
|
7 |
c5917804ecad
Add ERT, a tool for automated testing in Emacs Lisp.
Christian Ohler <ohler@gnu.org>
parents:
diff
changeset
|
8 ;; This file is part of GNU Emacs. |
c5917804ecad
Add ERT, a tool for automated testing in Emacs Lisp.
Christian Ohler <ohler@gnu.org>
parents:
diff
changeset
|
9 |
c5917804ecad
Add ERT, a tool for automated testing in Emacs Lisp.
Christian Ohler <ohler@gnu.org>
parents:
diff
changeset
|
10 ;; This program is free software: you can redistribute it and/or |
c5917804ecad
Add ERT, a tool for automated testing in Emacs Lisp.
Christian Ohler <ohler@gnu.org>
parents:
diff
changeset
|
11 ;; modify it under the terms of the GNU General Public License as |
c5917804ecad
Add ERT, a tool for automated testing in Emacs Lisp.
Christian Ohler <ohler@gnu.org>
parents:
diff
changeset
|
12 ;; published by the Free Software Foundation, either version 3 of the |
c5917804ecad
Add ERT, a tool for automated testing in Emacs Lisp.
Christian Ohler <ohler@gnu.org>
parents:
diff
changeset
|
13 ;; License, or (at your option) any later version. |
c5917804ecad
Add ERT, a tool for automated testing in Emacs Lisp.
Christian Ohler <ohler@gnu.org>
parents:
diff
changeset
|
14 ;; |
c5917804ecad
Add ERT, a tool for automated testing in Emacs Lisp.
Christian Ohler <ohler@gnu.org>
parents:
diff
changeset
|
15 ;; This program is distributed in the hope that it will be useful, but |
c5917804ecad
Add ERT, a tool for automated testing in Emacs Lisp.
Christian Ohler <ohler@gnu.org>
parents:
diff
changeset
|
16 ;; WITHOUT ANY WARRANTY; without even the implied warranty of |
c5917804ecad
Add ERT, a tool for automated testing in Emacs Lisp.
Christian Ohler <ohler@gnu.org>
parents:
diff
changeset
|
17 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
c5917804ecad
Add ERT, a tool for automated testing in Emacs Lisp.
Christian Ohler <ohler@gnu.org>
parents:
diff
changeset
|
18 ;; General Public License for more details. |
c5917804ecad
Add ERT, a tool for automated testing in Emacs Lisp.
Christian Ohler <ohler@gnu.org>
parents:
diff
changeset
|
19 ;; |
c5917804ecad
Add ERT, a tool for automated testing in Emacs Lisp.
Christian Ohler <ohler@gnu.org>
parents:
diff
changeset
|
20 ;; You should have received a copy of the GNU General Public License |
c5917804ecad
Add ERT, a tool for automated testing in Emacs Lisp.
Christian Ohler <ohler@gnu.org>
parents:
diff
changeset
|
21 ;; along with this program. If not, see `http://www.gnu.org/licenses/'. |
c5917804ecad
Add ERT, a tool for automated testing in Emacs Lisp.
Christian Ohler <ohler@gnu.org>
parents:
diff
changeset
|
22 |
c5917804ecad
Add ERT, a tool for automated testing in Emacs Lisp.
Christian Ohler <ohler@gnu.org>
parents:
diff
changeset
|
23 ;;; Commentary: |
c5917804ecad
Add ERT, a tool for automated testing in Emacs Lisp.
Christian Ohler <ohler@gnu.org>
parents:
diff
changeset
|
24 |
c5917804ecad
Add ERT, a tool for automated testing in Emacs Lisp.
Christian Ohler <ohler@gnu.org>
parents:
diff
changeset
|
25 ;; This file is part of ERT, the Emacs Lisp Regression Testing tool. |
c5917804ecad
Add ERT, a tool for automated testing in Emacs Lisp.
Christian Ohler <ohler@gnu.org>
parents:
diff
changeset
|
26 ;; See ert.el or the texinfo manual for more details. |
c5917804ecad
Add ERT, a tool for automated testing in Emacs Lisp.
Christian Ohler <ohler@gnu.org>
parents:
diff
changeset
|
27 |
c5917804ecad
Add ERT, a tool for automated testing in Emacs Lisp.
Christian Ohler <ohler@gnu.org>
parents:
diff
changeset
|
28 ;;; Code: |
c5917804ecad
Add ERT, a tool for automated testing in Emacs Lisp.
Christian Ohler <ohler@gnu.org>
parents:
diff
changeset
|
29 |
c5917804ecad
Add ERT, a tool for automated testing in Emacs Lisp.
Christian Ohler <ohler@gnu.org>
parents:
diff
changeset
|
30 (eval-when-compile |
c5917804ecad
Add ERT, a tool for automated testing in Emacs Lisp.
Christian Ohler <ohler@gnu.org>
parents:
diff
changeset
|
31 (require 'cl)) |
c5917804ecad
Add ERT, a tool for automated testing in Emacs Lisp.
Christian Ohler <ohler@gnu.org>
parents:
diff
changeset
|
32 (require 'ert) |
c5917804ecad
Add ERT, a tool for automated testing in Emacs Lisp.
Christian Ohler <ohler@gnu.org>
parents:
diff
changeset
|
33 (require 'ert-x) |
c5917804ecad
Add ERT, a tool for automated testing in Emacs Lisp.
Christian Ohler <ohler@gnu.org>
parents:
diff
changeset
|
34 |
c5917804ecad
Add ERT, a tool for automated testing in Emacs Lisp.
Christian Ohler <ohler@gnu.org>
parents:
diff
changeset
|
35 ;;; Utilities |
c5917804ecad
Add ERT, a tool for automated testing in Emacs Lisp.
Christian Ohler <ohler@gnu.org>
parents:
diff
changeset
|
36 |
c5917804ecad
Add ERT, a tool for automated testing in Emacs Lisp.
Christian Ohler <ohler@gnu.org>
parents:
diff
changeset
|
37 (ert-deftest ert-test-buffer-string-reindented () |
c5917804ecad
Add ERT, a tool for automated testing in Emacs Lisp.
Christian Ohler <ohler@gnu.org>
parents:
diff
changeset
|
38 (ert-with-test-buffer (:name "well-indented") |
c5917804ecad
Add ERT, a tool for automated testing in Emacs Lisp.
Christian Ohler <ohler@gnu.org>
parents:
diff
changeset
|
39 (insert (concat "(hello (world\n" |
c5917804ecad
Add ERT, a tool for automated testing in Emacs Lisp.
Christian Ohler <ohler@gnu.org>
parents:
diff
changeset
|
40 " 'elisp)\n")) |
c5917804ecad
Add ERT, a tool for automated testing in Emacs Lisp.
Christian Ohler <ohler@gnu.org>
parents:
diff
changeset
|
41 (emacs-lisp-mode) |
c5917804ecad
Add ERT, a tool for automated testing in Emacs Lisp.
Christian Ohler <ohler@gnu.org>
parents:
diff
changeset
|
42 (should (equal (ert-buffer-string-reindented) (buffer-string)))) |
c5917804ecad
Add ERT, a tool for automated testing in Emacs Lisp.
Christian Ohler <ohler@gnu.org>
parents:
diff
changeset
|
43 (ert-with-test-buffer (:name "badly-indented") |
c5917804ecad
Add ERT, a tool for automated testing in Emacs Lisp.
Christian Ohler <ohler@gnu.org>
parents:
diff
changeset
|
44 (insert (concat "(hello\n" |
c5917804ecad
Add ERT, a tool for automated testing in Emacs Lisp.
Christian Ohler <ohler@gnu.org>
parents:
diff
changeset
|
45 " world)")) |
c5917804ecad
Add ERT, a tool for automated testing in Emacs Lisp.
Christian Ohler <ohler@gnu.org>
parents:
diff
changeset
|
46 (emacs-lisp-mode) |
c5917804ecad
Add ERT, a tool for automated testing in Emacs Lisp.
Christian Ohler <ohler@gnu.org>
parents:
diff
changeset
|
47 (should-not (equal (ert-buffer-string-reindented) (buffer-string))))) |
c5917804ecad
Add ERT, a tool for automated testing in Emacs Lisp.
Christian Ohler <ohler@gnu.org>
parents:
diff
changeset
|
48 |
c5917804ecad
Add ERT, a tool for automated testing in Emacs Lisp.
Christian Ohler <ohler@gnu.org>
parents:
diff
changeset
|
49 (defun ert--hash-table-to-alist (table) |
c5917804ecad
Add ERT, a tool for automated testing in Emacs Lisp.
Christian Ohler <ohler@gnu.org>
parents:
diff
changeset
|
50 (let ((accu nil)) |
c5917804ecad
Add ERT, a tool for automated testing in Emacs Lisp.
Christian Ohler <ohler@gnu.org>
parents:
diff
changeset
|
51 (maphash (lambda (key value) |
c5917804ecad
Add ERT, a tool for automated testing in Emacs Lisp.
Christian Ohler <ohler@gnu.org>
parents:
diff
changeset
|
52 (push (cons key value) accu)) |
c5917804ecad
Add ERT, a tool for automated testing in Emacs Lisp.
Christian Ohler <ohler@gnu.org>
parents:
diff
changeset
|
53 table) |
c5917804ecad
Add ERT, a tool for automated testing in Emacs Lisp.
Christian Ohler <ohler@gnu.org>
parents:
diff
changeset
|
54 (nreverse accu))) |
c5917804ecad
Add ERT, a tool for automated testing in Emacs Lisp.
Christian Ohler <ohler@gnu.org>
parents:
diff
changeset
|
55 |
c5917804ecad
Add ERT, a tool for automated testing in Emacs Lisp.
Christian Ohler <ohler@gnu.org>
parents:
diff
changeset
|
56 (ert-deftest ert-test-test-buffers () |
c5917804ecad
Add ERT, a tool for automated testing in Emacs Lisp.
Christian Ohler <ohler@gnu.org>
parents:
diff
changeset
|
57 (let (buffer-1 |
c5917804ecad
Add ERT, a tool for automated testing in Emacs Lisp.
Christian Ohler <ohler@gnu.org>
parents:
diff
changeset
|
58 buffer-2) |
c5917804ecad
Add ERT, a tool for automated testing in Emacs Lisp.
Christian Ohler <ohler@gnu.org>
parents:
diff
changeset
|
59 (let ((test-1 |
c5917804ecad
Add ERT, a tool for automated testing in Emacs Lisp.
Christian Ohler <ohler@gnu.org>
parents:
diff
changeset
|
60 (make-ert-test |
c5917804ecad
Add ERT, a tool for automated testing in Emacs Lisp.
Christian Ohler <ohler@gnu.org>
parents:
diff
changeset
|
61 :name 'test-1 |
c5917804ecad
Add ERT, a tool for automated testing in Emacs Lisp.
Christian Ohler <ohler@gnu.org>
parents:
diff
changeset
|
62 :body (lambda () |
c5917804ecad
Add ERT, a tool for automated testing in Emacs Lisp.
Christian Ohler <ohler@gnu.org>
parents:
diff
changeset
|
63 (ert-with-test-buffer (:name "foo") |
c5917804ecad
Add ERT, a tool for automated testing in Emacs Lisp.
Christian Ohler <ohler@gnu.org>
parents:
diff
changeset
|
64 (should (string-match |
c5917804ecad
Add ERT, a tool for automated testing in Emacs Lisp.
Christian Ohler <ohler@gnu.org>
parents:
diff
changeset
|
65 "[*]Test buffer (ert-test-test-buffers): foo[*]" |
c5917804ecad
Add ERT, a tool for automated testing in Emacs Lisp.
Christian Ohler <ohler@gnu.org>
parents:
diff
changeset
|
66 (buffer-name))) |
c5917804ecad
Add ERT, a tool for automated testing in Emacs Lisp.
Christian Ohler <ohler@gnu.org>
parents:
diff
changeset
|
67 (setq buffer-1 (current-buffer)))))) |
c5917804ecad
Add ERT, a tool for automated testing in Emacs Lisp.
Christian Ohler <ohler@gnu.org>
parents:
diff
changeset
|
68 (test-2 |
c5917804ecad
Add ERT, a tool for automated testing in Emacs Lisp.
Christian Ohler <ohler@gnu.org>
parents:
diff
changeset
|
69 (make-ert-test |
c5917804ecad
Add ERT, a tool for automated testing in Emacs Lisp.
Christian Ohler <ohler@gnu.org>
parents:
diff
changeset
|
70 :name 'test-2 |
c5917804ecad
Add ERT, a tool for automated testing in Emacs Lisp.
Christian Ohler <ohler@gnu.org>
parents:
diff
changeset
|
71 :body (lambda () |
c5917804ecad
Add ERT, a tool for automated testing in Emacs Lisp.
Christian Ohler <ohler@gnu.org>
parents:
diff
changeset
|
72 (ert-with-test-buffer (:name "bar") |
c5917804ecad
Add ERT, a tool for automated testing in Emacs Lisp.
Christian Ohler <ohler@gnu.org>
parents:
diff
changeset
|
73 (should (string-match |
c5917804ecad
Add ERT, a tool for automated testing in Emacs Lisp.
Christian Ohler <ohler@gnu.org>
parents:
diff
changeset
|
74 "[*]Test buffer (ert-test-test-buffers): bar[*]" |
c5917804ecad
Add ERT, a tool for automated testing in Emacs Lisp.
Christian Ohler <ohler@gnu.org>
parents:
diff
changeset
|
75 (buffer-name))) |
c5917804ecad
Add ERT, a tool for automated testing in Emacs Lisp.
Christian Ohler <ohler@gnu.org>
parents:
diff
changeset
|
76 (setq buffer-2 (current-buffer)) |
c5917804ecad
Add ERT, a tool for automated testing in Emacs Lisp.
Christian Ohler <ohler@gnu.org>
parents:
diff
changeset
|
77 (ert-fail "fail for test")))))) |
c5917804ecad
Add ERT, a tool for automated testing in Emacs Lisp.
Christian Ohler <ohler@gnu.org>
parents:
diff
changeset
|
78 (let ((ert--test-buffers (make-hash-table :weakness t))) |
c5917804ecad
Add ERT, a tool for automated testing in Emacs Lisp.
Christian Ohler <ohler@gnu.org>
parents:
diff
changeset
|
79 (ert-run-tests `(member ,test-1 ,test-2) #'ignore) |
c5917804ecad
Add ERT, a tool for automated testing in Emacs Lisp.
Christian Ohler <ohler@gnu.org>
parents:
diff
changeset
|
80 (should (equal (ert--hash-table-to-alist ert--test-buffers) |
c5917804ecad
Add ERT, a tool for automated testing in Emacs Lisp.
Christian Ohler <ohler@gnu.org>
parents:
diff
changeset
|
81 `((,buffer-2 . t)))) |
c5917804ecad
Add ERT, a tool for automated testing in Emacs Lisp.
Christian Ohler <ohler@gnu.org>
parents:
diff
changeset
|
82 (should-not (buffer-live-p buffer-1)) |
c5917804ecad
Add ERT, a tool for automated testing in Emacs Lisp.
Christian Ohler <ohler@gnu.org>
parents:
diff
changeset
|
83 (should (buffer-live-p buffer-2)))))) |
c5917804ecad
Add ERT, a tool for automated testing in Emacs Lisp.
Christian Ohler <ohler@gnu.org>
parents:
diff
changeset
|
84 |
c5917804ecad
Add ERT, a tool for automated testing in Emacs Lisp.
Christian Ohler <ohler@gnu.org>
parents:
diff
changeset
|
85 |
c5917804ecad
Add ERT, a tool for automated testing in Emacs Lisp.
Christian Ohler <ohler@gnu.org>
parents:
diff
changeset
|
86 (ert-deftest ert-filter-string () |
c5917804ecad
Add ERT, a tool for automated testing in Emacs Lisp.
Christian Ohler <ohler@gnu.org>
parents:
diff
changeset
|
87 (should (equal (ert-filter-string "foo bar baz" "quux") |
c5917804ecad
Add ERT, a tool for automated testing in Emacs Lisp.
Christian Ohler <ohler@gnu.org>
parents:
diff
changeset
|
88 "foo bar baz")) |
c5917804ecad
Add ERT, a tool for automated testing in Emacs Lisp.
Christian Ohler <ohler@gnu.org>
parents:
diff
changeset
|
89 (should (equal (ert-filter-string "foo bar baz" "bar") |
c5917804ecad
Add ERT, a tool for automated testing in Emacs Lisp.
Christian Ohler <ohler@gnu.org>
parents:
diff
changeset
|
90 "foo baz"))) |
c5917804ecad
Add ERT, a tool for automated testing in Emacs Lisp.
Christian Ohler <ohler@gnu.org>
parents:
diff
changeset
|
91 |
c5917804ecad
Add ERT, a tool for automated testing in Emacs Lisp.
Christian Ohler <ohler@gnu.org>
parents:
diff
changeset
|
92 (ert-deftest ert-propertized-string () |
c5917804ecad
Add ERT, a tool for automated testing in Emacs Lisp.
Christian Ohler <ohler@gnu.org>
parents:
diff
changeset
|
93 (should (ert-equal-including-properties |
c5917804ecad
Add ERT, a tool for automated testing in Emacs Lisp.
Christian Ohler <ohler@gnu.org>
parents:
diff
changeset
|
94 (ert-propertized-string "a" '(a b) "b" '(c t) "cd") |
c5917804ecad
Add ERT, a tool for automated testing in Emacs Lisp.
Christian Ohler <ohler@gnu.org>
parents:
diff
changeset
|
95 #("abcd" 1 2 (a b) 2 4 (c t)))) |
c5917804ecad
Add ERT, a tool for automated testing in Emacs Lisp.
Christian Ohler <ohler@gnu.org>
parents:
diff
changeset
|
96 (should (ert-equal-including-properties |
c5917804ecad
Add ERT, a tool for automated testing in Emacs Lisp.
Christian Ohler <ohler@gnu.org>
parents:
diff
changeset
|
97 (ert-propertized-string "foo " '(face italic) "bar" " baz" nil |
c5917804ecad
Add ERT, a tool for automated testing in Emacs Lisp.
Christian Ohler <ohler@gnu.org>
parents:
diff
changeset
|
98 " quux") |
c5917804ecad
Add ERT, a tool for automated testing in Emacs Lisp.
Christian Ohler <ohler@gnu.org>
parents:
diff
changeset
|
99 #("foo bar baz quux" 4 11 (face italic))))) |
c5917804ecad
Add ERT, a tool for automated testing in Emacs Lisp.
Christian Ohler <ohler@gnu.org>
parents:
diff
changeset
|
100 |
c5917804ecad
Add ERT, a tool for automated testing in Emacs Lisp.
Christian Ohler <ohler@gnu.org>
parents:
diff
changeset
|
101 |
c5917804ecad
Add ERT, a tool for automated testing in Emacs Lisp.
Christian Ohler <ohler@gnu.org>
parents:
diff
changeset
|
102 ;;; Tests for ERT itself that require test features from ert-x.el. |
c5917804ecad
Add ERT, a tool for automated testing in Emacs Lisp.
Christian Ohler <ohler@gnu.org>
parents:
diff
changeset
|
103 |
c5917804ecad
Add ERT, a tool for automated testing in Emacs Lisp.
Christian Ohler <ohler@gnu.org>
parents:
diff
changeset
|
104 (ert-deftest ert-test-run-tests-interactively-2 () |
c5917804ecad
Add ERT, a tool for automated testing in Emacs Lisp.
Christian Ohler <ohler@gnu.org>
parents:
diff
changeset
|
105 :tags '(:causes-redisplay) |
c5917804ecad
Add ERT, a tool for automated testing in Emacs Lisp.
Christian Ohler <ohler@gnu.org>
parents:
diff
changeset
|
106 (let ((passing-test (make-ert-test :name 'passing-test |
c5917804ecad
Add ERT, a tool for automated testing in Emacs Lisp.
Christian Ohler <ohler@gnu.org>
parents:
diff
changeset
|
107 :body (lambda () (ert-pass)))) |
c5917804ecad
Add ERT, a tool for automated testing in Emacs Lisp.
Christian Ohler <ohler@gnu.org>
parents:
diff
changeset
|
108 (failing-test (make-ert-test :name 'failing-test |
c5917804ecad
Add ERT, a tool for automated testing in Emacs Lisp.
Christian Ohler <ohler@gnu.org>
parents:
diff
changeset
|
109 :body (lambda () |
c5917804ecad
Add ERT, a tool for automated testing in Emacs Lisp.
Christian Ohler <ohler@gnu.org>
parents:
diff
changeset
|
110 (ert-info ((propertize "foo\nbar" |
c5917804ecad
Add ERT, a tool for automated testing in Emacs Lisp.
Christian Ohler <ohler@gnu.org>
parents:
diff
changeset
|
111 'a 'b)) |
c5917804ecad
Add ERT, a tool for automated testing in Emacs Lisp.
Christian Ohler <ohler@gnu.org>
parents:
diff
changeset
|
112 (ert-fail |
c5917804ecad
Add ERT, a tool for automated testing in Emacs Lisp.
Christian Ohler <ohler@gnu.org>
parents:
diff
changeset
|
113 "failure message")))))) |
c5917804ecad
Add ERT, a tool for automated testing in Emacs Lisp.
Christian Ohler <ohler@gnu.org>
parents:
diff
changeset
|
114 (let ((ert-debug-on-error nil)) |
c5917804ecad
Add ERT, a tool for automated testing in Emacs Lisp.
Christian Ohler <ohler@gnu.org>
parents:
diff
changeset
|
115 (let* ((buffer-name (generate-new-buffer-name "*ert-test-run-tests*")) |
c5917804ecad
Add ERT, a tool for automated testing in Emacs Lisp.
Christian Ohler <ohler@gnu.org>
parents:
diff
changeset
|
116 (messages nil) |
c5917804ecad
Add ERT, a tool for automated testing in Emacs Lisp.
Christian Ohler <ohler@gnu.org>
parents:
diff
changeset
|
117 (mock-message-fn |
c5917804ecad
Add ERT, a tool for automated testing in Emacs Lisp.
Christian Ohler <ohler@gnu.org>
parents:
diff
changeset
|
118 (lambda (format-string &rest args) |
c5917804ecad
Add ERT, a tool for automated testing in Emacs Lisp.
Christian Ohler <ohler@gnu.org>
parents:
diff
changeset
|
119 (push (apply #'format format-string args) messages)))) |
c5917804ecad
Add ERT, a tool for automated testing in Emacs Lisp.
Christian Ohler <ohler@gnu.org>
parents:
diff
changeset
|
120 (flet ((expected-string (with-font-lock-p) |
c5917804ecad
Add ERT, a tool for automated testing in Emacs Lisp.
Christian Ohler <ohler@gnu.org>
parents:
diff
changeset
|
121 (ert-propertized-string |
c5917804ecad
Add ERT, a tool for automated testing in Emacs Lisp.
Christian Ohler <ohler@gnu.org>
parents:
diff
changeset
|
122 "Selector: (member <passing-test> <failing-test>)\n" |
c5917804ecad
Add ERT, a tool for automated testing in Emacs Lisp.
Christian Ohler <ohler@gnu.org>
parents:
diff
changeset
|
123 "Passed: 1\n" |
c5917804ecad
Add ERT, a tool for automated testing in Emacs Lisp.
Christian Ohler <ohler@gnu.org>
parents:
diff
changeset
|
124 "Failed: 1 (1 unexpected)\n" |
c5917804ecad
Add ERT, a tool for automated testing in Emacs Lisp.
Christian Ohler <ohler@gnu.org>
parents:
diff
changeset
|
125 "Total: 2/2\n\n" |
c5917804ecad
Add ERT, a tool for automated testing in Emacs Lisp.
Christian Ohler <ohler@gnu.org>
parents:
diff
changeset
|
126 "Started at:\n" |
c5917804ecad
Add ERT, a tool for automated testing in Emacs Lisp.
Christian Ohler <ohler@gnu.org>
parents:
diff
changeset
|
127 "Finished.\n" |
c5917804ecad
Add ERT, a tool for automated testing in Emacs Lisp.
Christian Ohler <ohler@gnu.org>
parents:
diff
changeset
|
128 "Finished at:\n\n" |
c5917804ecad
Add ERT, a tool for automated testing in Emacs Lisp.
Christian Ohler <ohler@gnu.org>
parents:
diff
changeset
|
129 `(category ,(button-category-symbol |
c5917804ecad
Add ERT, a tool for automated testing in Emacs Lisp.
Christian Ohler <ohler@gnu.org>
parents:
diff
changeset
|
130 'ert--results-progress-bar-button) |
c5917804ecad
Add ERT, a tool for automated testing in Emacs Lisp.
Christian Ohler <ohler@gnu.org>
parents:
diff
changeset
|
131 button (t) |
c5917804ecad
Add ERT, a tool for automated testing in Emacs Lisp.
Christian Ohler <ohler@gnu.org>
parents:
diff
changeset
|
132 face ,(if with-font-lock-p |
c5917804ecad
Add ERT, a tool for automated testing in Emacs Lisp.
Christian Ohler <ohler@gnu.org>
parents:
diff
changeset
|
133 'ert-test-result-unexpected |
c5917804ecad
Add ERT, a tool for automated testing in Emacs Lisp.
Christian Ohler <ohler@gnu.org>
parents:
diff
changeset
|
134 'button)) |
c5917804ecad
Add ERT, a tool for automated testing in Emacs Lisp.
Christian Ohler <ohler@gnu.org>
parents:
diff
changeset
|
135 ".F" nil "\n\n" |
c5917804ecad
Add ERT, a tool for automated testing in Emacs Lisp.
Christian Ohler <ohler@gnu.org>
parents:
diff
changeset
|
136 `(category ,(button-category-symbol |
c5917804ecad
Add ERT, a tool for automated testing in Emacs Lisp.
Christian Ohler <ohler@gnu.org>
parents:
diff
changeset
|
137 'ert--results-expand-collapse-button) |
c5917804ecad
Add ERT, a tool for automated testing in Emacs Lisp.
Christian Ohler <ohler@gnu.org>
parents:
diff
changeset
|
138 button (t) |
c5917804ecad
Add ERT, a tool for automated testing in Emacs Lisp.
Christian Ohler <ohler@gnu.org>
parents:
diff
changeset
|
139 face ,(if with-font-lock-p |
c5917804ecad
Add ERT, a tool for automated testing in Emacs Lisp.
Christian Ohler <ohler@gnu.org>
parents:
diff
changeset
|
140 'ert-test-result-unexpected |
c5917804ecad
Add ERT, a tool for automated testing in Emacs Lisp.
Christian Ohler <ohler@gnu.org>
parents:
diff
changeset
|
141 'button)) |
c5917804ecad
Add ERT, a tool for automated testing in Emacs Lisp.
Christian Ohler <ohler@gnu.org>
parents:
diff
changeset
|
142 "F" nil " " |
c5917804ecad
Add ERT, a tool for automated testing in Emacs Lisp.
Christian Ohler <ohler@gnu.org>
parents:
diff
changeset
|
143 `(category ,(button-category-symbol |
c5917804ecad
Add ERT, a tool for automated testing in Emacs Lisp.
Christian Ohler <ohler@gnu.org>
parents:
diff
changeset
|
144 'ert--test-name-button) |
c5917804ecad
Add ERT, a tool for automated testing in Emacs Lisp.
Christian Ohler <ohler@gnu.org>
parents:
diff
changeset
|
145 button (t) |
c5917804ecad
Add ERT, a tool for automated testing in Emacs Lisp.
Christian Ohler <ohler@gnu.org>
parents:
diff
changeset
|
146 ert-test-name failing-test) |
c5917804ecad
Add ERT, a tool for automated testing in Emacs Lisp.
Christian Ohler <ohler@gnu.org>
parents:
diff
changeset
|
147 "failing-test" |
c5917804ecad
Add ERT, a tool for automated testing in Emacs Lisp.
Christian Ohler <ohler@gnu.org>
parents:
diff
changeset
|
148 nil "\n Info: " '(a b) "foo\n" |
c5917804ecad
Add ERT, a tool for automated testing in Emacs Lisp.
Christian Ohler <ohler@gnu.org>
parents:
diff
changeset
|
149 nil " " '(a b) "bar" |
c5917804ecad
Add ERT, a tool for automated testing in Emacs Lisp.
Christian Ohler <ohler@gnu.org>
parents:
diff
changeset
|
150 nil "\n (ert-test-failed \"failure message\")\n\n\n" |
c5917804ecad
Add ERT, a tool for automated testing in Emacs Lisp.
Christian Ohler <ohler@gnu.org>
parents:
diff
changeset
|
151 ))) |
c5917804ecad
Add ERT, a tool for automated testing in Emacs Lisp.
Christian Ohler <ohler@gnu.org>
parents:
diff
changeset
|
152 (save-window-excursion |
c5917804ecad
Add ERT, a tool for automated testing in Emacs Lisp.
Christian Ohler <ohler@gnu.org>
parents:
diff
changeset
|
153 (unwind-protect |
c5917804ecad
Add ERT, a tool for automated testing in Emacs Lisp.
Christian Ohler <ohler@gnu.org>
parents:
diff
changeset
|
154 (let ((case-fold-search nil)) |
c5917804ecad
Add ERT, a tool for automated testing in Emacs Lisp.
Christian Ohler <ohler@gnu.org>
parents:
diff
changeset
|
155 (ert-run-tests-interactively |
c5917804ecad
Add ERT, a tool for automated testing in Emacs Lisp.
Christian Ohler <ohler@gnu.org>
parents:
diff
changeset
|
156 `(member ,passing-test ,failing-test) buffer-name |
c5917804ecad
Add ERT, a tool for automated testing in Emacs Lisp.
Christian Ohler <ohler@gnu.org>
parents:
diff
changeset
|
157 mock-message-fn) |
c5917804ecad
Add ERT, a tool for automated testing in Emacs Lisp.
Christian Ohler <ohler@gnu.org>
parents:
diff
changeset
|
158 (should (equal messages `(,(concat |
c5917804ecad
Add ERT, a tool for automated testing in Emacs Lisp.
Christian Ohler <ohler@gnu.org>
parents:
diff
changeset
|
159 "Ran 2 tests, 1 results were " |
c5917804ecad
Add ERT, a tool for automated testing in Emacs Lisp.
Christian Ohler <ohler@gnu.org>
parents:
diff
changeset
|
160 "as expected, 1 unexpected")))) |
c5917804ecad
Add ERT, a tool for automated testing in Emacs Lisp.
Christian Ohler <ohler@gnu.org>
parents:
diff
changeset
|
161 (with-current-buffer buffer-name |
c5917804ecad
Add ERT, a tool for automated testing in Emacs Lisp.
Christian Ohler <ohler@gnu.org>
parents:
diff
changeset
|
162 (font-lock-mode 0) |
c5917804ecad
Add ERT, a tool for automated testing in Emacs Lisp.
Christian Ohler <ohler@gnu.org>
parents:
diff
changeset
|
163 (should (ert-equal-including-properties |
c5917804ecad
Add ERT, a tool for automated testing in Emacs Lisp.
Christian Ohler <ohler@gnu.org>
parents:
diff
changeset
|
164 (ert-filter-string (buffer-string) |
c5917804ecad
Add ERT, a tool for automated testing in Emacs Lisp.
Christian Ohler <ohler@gnu.org>
parents:
diff
changeset
|
165 '("Started at:\\(.*\\)$" 1) |
c5917804ecad
Add ERT, a tool for automated testing in Emacs Lisp.
Christian Ohler <ohler@gnu.org>
parents:
diff
changeset
|
166 '("Finished at:\\(.*\\)$" 1)) |
c5917804ecad
Add ERT, a tool for automated testing in Emacs Lisp.
Christian Ohler <ohler@gnu.org>
parents:
diff
changeset
|
167 (expected-string nil))) |
c5917804ecad
Add ERT, a tool for automated testing in Emacs Lisp.
Christian Ohler <ohler@gnu.org>
parents:
diff
changeset
|
168 ;; `font-lock-mode' only works if interactive, so |
c5917804ecad
Add ERT, a tool for automated testing in Emacs Lisp.
Christian Ohler <ohler@gnu.org>
parents:
diff
changeset
|
169 ;; pretend we are. |
c5917804ecad
Add ERT, a tool for automated testing in Emacs Lisp.
Christian Ohler <ohler@gnu.org>
parents:
diff
changeset
|
170 (let ((noninteractive nil)) |
c5917804ecad
Add ERT, a tool for automated testing in Emacs Lisp.
Christian Ohler <ohler@gnu.org>
parents:
diff
changeset
|
171 (font-lock-mode 1)) |
c5917804ecad
Add ERT, a tool for automated testing in Emacs Lisp.
Christian Ohler <ohler@gnu.org>
parents:
diff
changeset
|
172 (should (ert-equal-including-properties |
c5917804ecad
Add ERT, a tool for automated testing in Emacs Lisp.
Christian Ohler <ohler@gnu.org>
parents:
diff
changeset
|
173 (ert-filter-string (buffer-string) |
c5917804ecad
Add ERT, a tool for automated testing in Emacs Lisp.
Christian Ohler <ohler@gnu.org>
parents:
diff
changeset
|
174 '("Started at:\\(.*\\)$" 1) |
c5917804ecad
Add ERT, a tool for automated testing in Emacs Lisp.
Christian Ohler <ohler@gnu.org>
parents:
diff
changeset
|
175 '("Finished at:\\(.*\\)$" 1)) |
c5917804ecad
Add ERT, a tool for automated testing in Emacs Lisp.
Christian Ohler <ohler@gnu.org>
parents:
diff
changeset
|
176 (expected-string t))))) |
c5917804ecad
Add ERT, a tool for automated testing in Emacs Lisp.
Christian Ohler <ohler@gnu.org>
parents:
diff
changeset
|
177 (when (get-buffer buffer-name) |
c5917804ecad
Add ERT, a tool for automated testing in Emacs Lisp.
Christian Ohler <ohler@gnu.org>
parents:
diff
changeset
|
178 (kill-buffer buffer-name))))))))) |
c5917804ecad
Add ERT, a tool for automated testing in Emacs Lisp.
Christian Ohler <ohler@gnu.org>
parents:
diff
changeset
|
179 |
c5917804ecad
Add ERT, a tool for automated testing in Emacs Lisp.
Christian Ohler <ohler@gnu.org>
parents:
diff
changeset
|
180 (ert-deftest ert-test-describe-test () |
c5917804ecad
Add ERT, a tool for automated testing in Emacs Lisp.
Christian Ohler <ohler@gnu.org>
parents:
diff
changeset
|
181 "Tests `ert-describe-test'." |
c5917804ecad
Add ERT, a tool for automated testing in Emacs Lisp.
Christian Ohler <ohler@gnu.org>
parents:
diff
changeset
|
182 (save-window-excursion |
c5917804ecad
Add ERT, a tool for automated testing in Emacs Lisp.
Christian Ohler <ohler@gnu.org>
parents:
diff
changeset
|
183 (ert-with-buffer-renamed ("*Help*") |
c5917804ecad
Add ERT, a tool for automated testing in Emacs Lisp.
Christian Ohler <ohler@gnu.org>
parents:
diff
changeset
|
184 (if (< emacs-major-version 24) |
c5917804ecad
Add ERT, a tool for automated testing in Emacs Lisp.
Christian Ohler <ohler@gnu.org>
parents:
diff
changeset
|
185 (should (equal (should-error (ert-describe-test 'ert-describe-test)) |
c5917804ecad
Add ERT, a tool for automated testing in Emacs Lisp.
Christian Ohler <ohler@gnu.org>
parents:
diff
changeset
|
186 '(error "Requires Emacs 24"))) |
c5917804ecad
Add ERT, a tool for automated testing in Emacs Lisp.
Christian Ohler <ohler@gnu.org>
parents:
diff
changeset
|
187 (ert-describe-test 'ert-test-describe-test) |
c5917804ecad
Add ERT, a tool for automated testing in Emacs Lisp.
Christian Ohler <ohler@gnu.org>
parents:
diff
changeset
|
188 (with-current-buffer "*Help*" |
c5917804ecad
Add ERT, a tool for automated testing in Emacs Lisp.
Christian Ohler <ohler@gnu.org>
parents:
diff
changeset
|
189 (let ((case-fold-search nil)) |
c5917804ecad
Add ERT, a tool for automated testing in Emacs Lisp.
Christian Ohler <ohler@gnu.org>
parents:
diff
changeset
|
190 (should (string-match (concat |
c5917804ecad
Add ERT, a tool for automated testing in Emacs Lisp.
Christian Ohler <ohler@gnu.org>
parents:
diff
changeset
|
191 "\\`ert-test-describe-test is a test" |
c5917804ecad
Add ERT, a tool for automated testing in Emacs Lisp.
Christian Ohler <ohler@gnu.org>
parents:
diff
changeset
|
192 " defined in `ert-x-tests.elc?'\\.\n\n" |
c5917804ecad
Add ERT, a tool for automated testing in Emacs Lisp.
Christian Ohler <ohler@gnu.org>
parents:
diff
changeset
|
193 "Tests `ert-describe-test'\\.\n\\'") |
c5917804ecad
Add ERT, a tool for automated testing in Emacs Lisp.
Christian Ohler <ohler@gnu.org>
parents:
diff
changeset
|
194 (buffer-string))))))))) |
c5917804ecad
Add ERT, a tool for automated testing in Emacs Lisp.
Christian Ohler <ohler@gnu.org>
parents:
diff
changeset
|
195 |
c5917804ecad
Add ERT, a tool for automated testing in Emacs Lisp.
Christian Ohler <ohler@gnu.org>
parents:
diff
changeset
|
196 (ert-deftest ert-test-message-log-truncation () |
c5917804ecad
Add ERT, a tool for automated testing in Emacs Lisp.
Christian Ohler <ohler@gnu.org>
parents:
diff
changeset
|
197 :tags '(:causes-redisplay) |
c5917804ecad
Add ERT, a tool for automated testing in Emacs Lisp.
Christian Ohler <ohler@gnu.org>
parents:
diff
changeset
|
198 (let ((test (make-ert-test |
c5917804ecad
Add ERT, a tool for automated testing in Emacs Lisp.
Christian Ohler <ohler@gnu.org>
parents:
diff
changeset
|
199 :body (lambda () |
c5917804ecad
Add ERT, a tool for automated testing in Emacs Lisp.
Christian Ohler <ohler@gnu.org>
parents:
diff
changeset
|
200 ;; Emacs would combine messages if we |
c5917804ecad
Add ERT, a tool for automated testing in Emacs Lisp.
Christian Ohler <ohler@gnu.org>
parents:
diff
changeset
|
201 ;; generate the same message multiple |
c5917804ecad
Add ERT, a tool for automated testing in Emacs Lisp.
Christian Ohler <ohler@gnu.org>
parents:
diff
changeset
|
202 ;; times. |
c5917804ecad
Add ERT, a tool for automated testing in Emacs Lisp.
Christian Ohler <ohler@gnu.org>
parents:
diff
changeset
|
203 (message "a") |
c5917804ecad
Add ERT, a tool for automated testing in Emacs Lisp.
Christian Ohler <ohler@gnu.org>
parents:
diff
changeset
|
204 (message "b") |
c5917804ecad
Add ERT, a tool for automated testing in Emacs Lisp.
Christian Ohler <ohler@gnu.org>
parents:
diff
changeset
|
205 (message "c") |
c5917804ecad
Add ERT, a tool for automated testing in Emacs Lisp.
Christian Ohler <ohler@gnu.org>
parents:
diff
changeset
|
206 (message "d"))))) |
c5917804ecad
Add ERT, a tool for automated testing in Emacs Lisp.
Christian Ohler <ohler@gnu.org>
parents:
diff
changeset
|
207 (let (result) |
c5917804ecad
Add ERT, a tool for automated testing in Emacs Lisp.
Christian Ohler <ohler@gnu.org>
parents:
diff
changeset
|
208 (ert-with-buffer-renamed ("*Messages*") |
c5917804ecad
Add ERT, a tool for automated testing in Emacs Lisp.
Christian Ohler <ohler@gnu.org>
parents:
diff
changeset
|
209 (let ((message-log-max 2)) |
c5917804ecad
Add ERT, a tool for automated testing in Emacs Lisp.
Christian Ohler <ohler@gnu.org>
parents:
diff
changeset
|
210 (setq result (ert-run-test test))) |
c5917804ecad
Add ERT, a tool for automated testing in Emacs Lisp.
Christian Ohler <ohler@gnu.org>
parents:
diff
changeset
|
211 (should (equal (with-current-buffer "*Messages*" |
c5917804ecad
Add ERT, a tool for automated testing in Emacs Lisp.
Christian Ohler <ohler@gnu.org>
parents:
diff
changeset
|
212 (buffer-string)) |
c5917804ecad
Add ERT, a tool for automated testing in Emacs Lisp.
Christian Ohler <ohler@gnu.org>
parents:
diff
changeset
|
213 "c\nd\n"))) |
c5917804ecad
Add ERT, a tool for automated testing in Emacs Lisp.
Christian Ohler <ohler@gnu.org>
parents:
diff
changeset
|
214 (should (equal (ert-test-result-messages result) "a\nb\nc\nd\n"))))) |
c5917804ecad
Add ERT, a tool for automated testing in Emacs Lisp.
Christian Ohler <ohler@gnu.org>
parents:
diff
changeset
|
215 |
c5917804ecad
Add ERT, a tool for automated testing in Emacs Lisp.
Christian Ohler <ohler@gnu.org>
parents:
diff
changeset
|
216 (ert-deftest ert-test-builtin-message-log-flushing () |
c5917804ecad
Add ERT, a tool for automated testing in Emacs Lisp.
Christian Ohler <ohler@gnu.org>
parents:
diff
changeset
|
217 "This test attempts to demonstrate that there is no way to |
c5917804ecad
Add ERT, a tool for automated testing in Emacs Lisp.
Christian Ohler <ohler@gnu.org>
parents:
diff
changeset
|
218 force immediate truncation of the *Messages* buffer from Lisp |
c5917804ecad
Add ERT, a tool for automated testing in Emacs Lisp.
Christian Ohler <ohler@gnu.org>
parents:
diff
changeset
|
219 \(and hence justifies the existence of |
c5917804ecad
Add ERT, a tool for automated testing in Emacs Lisp.
Christian Ohler <ohler@gnu.org>
parents:
diff
changeset
|
220 `ert--force-message-log-buffer-truncation'\): The only way that |
c5917804ecad
Add ERT, a tool for automated testing in Emacs Lisp.
Christian Ohler <ohler@gnu.org>
parents:
diff
changeset
|
221 came to my mind was \(message \"\"\), which doesn't have the |
c5917804ecad
Add ERT, a tool for automated testing in Emacs Lisp.
Christian Ohler <ohler@gnu.org>
parents:
diff
changeset
|
222 desired effect." |
c5917804ecad
Add ERT, a tool for automated testing in Emacs Lisp.
Christian Ohler <ohler@gnu.org>
parents:
diff
changeset
|
223 :tags '(:causes-redisplay) |
c5917804ecad
Add ERT, a tool for automated testing in Emacs Lisp.
Christian Ohler <ohler@gnu.org>
parents:
diff
changeset
|
224 (ert-with-buffer-renamed ("*Messages*") |
c5917804ecad
Add ERT, a tool for automated testing in Emacs Lisp.
Christian Ohler <ohler@gnu.org>
parents:
diff
changeset
|
225 (with-current-buffer "*Messages*" |
c5917804ecad
Add ERT, a tool for automated testing in Emacs Lisp.
Christian Ohler <ohler@gnu.org>
parents:
diff
changeset
|
226 (should (equal (buffer-string) "")) |
c5917804ecad
Add ERT, a tool for automated testing in Emacs Lisp.
Christian Ohler <ohler@gnu.org>
parents:
diff
changeset
|
227 ;; We used to get sporadic failures in this test that involved |
c5917804ecad
Add ERT, a tool for automated testing in Emacs Lisp.
Christian Ohler <ohler@gnu.org>
parents:
diff
changeset
|
228 ;; a spurious newline at the beginning of the buffer, before |
c5917804ecad
Add ERT, a tool for automated testing in Emacs Lisp.
Christian Ohler <ohler@gnu.org>
parents:
diff
changeset
|
229 ;; the first message. Below, we print a message and erase the |
c5917804ecad
Add ERT, a tool for automated testing in Emacs Lisp.
Christian Ohler <ohler@gnu.org>
parents:
diff
changeset
|
230 ;; buffer since this seems to eliminate the sporadic failures. |
c5917804ecad
Add ERT, a tool for automated testing in Emacs Lisp.
Christian Ohler <ohler@gnu.org>
parents:
diff
changeset
|
231 (message "foo") |
c5917804ecad
Add ERT, a tool for automated testing in Emacs Lisp.
Christian Ohler <ohler@gnu.org>
parents:
diff
changeset
|
232 (erase-buffer) |
c5917804ecad
Add ERT, a tool for automated testing in Emacs Lisp.
Christian Ohler <ohler@gnu.org>
parents:
diff
changeset
|
233 (should (equal (buffer-string) "")) |
c5917804ecad
Add ERT, a tool for automated testing in Emacs Lisp.
Christian Ohler <ohler@gnu.org>
parents:
diff
changeset
|
234 (let ((message-log-max 2)) |
c5917804ecad
Add ERT, a tool for automated testing in Emacs Lisp.
Christian Ohler <ohler@gnu.org>
parents:
diff
changeset
|
235 (let ((message-log-max t)) |
c5917804ecad
Add ERT, a tool for automated testing in Emacs Lisp.
Christian Ohler <ohler@gnu.org>
parents:
diff
changeset
|
236 (loop for i below 4 do |
c5917804ecad
Add ERT, a tool for automated testing in Emacs Lisp.
Christian Ohler <ohler@gnu.org>
parents:
diff
changeset
|
237 (message "%s" i)) |
c5917804ecad
Add ERT, a tool for automated testing in Emacs Lisp.
Christian Ohler <ohler@gnu.org>
parents:
diff
changeset
|
238 (should (equal (buffer-string) "0\n1\n2\n3\n"))) |
c5917804ecad
Add ERT, a tool for automated testing in Emacs Lisp.
Christian Ohler <ohler@gnu.org>
parents:
diff
changeset
|
239 (should (equal (buffer-string) "0\n1\n2\n3\n")) |
c5917804ecad
Add ERT, a tool for automated testing in Emacs Lisp.
Christian Ohler <ohler@gnu.org>
parents:
diff
changeset
|
240 (message "") |
c5917804ecad
Add ERT, a tool for automated testing in Emacs Lisp.
Christian Ohler <ohler@gnu.org>
parents:
diff
changeset
|
241 (should (equal (buffer-string) "0\n1\n2\n3\n")) |
c5917804ecad
Add ERT, a tool for automated testing in Emacs Lisp.
Christian Ohler <ohler@gnu.org>
parents:
diff
changeset
|
242 (message "Test message") |
c5917804ecad
Add ERT, a tool for automated testing in Emacs Lisp.
Christian Ohler <ohler@gnu.org>
parents:
diff
changeset
|
243 (should (equal (buffer-string) "3\nTest message\n")))))) |
c5917804ecad
Add ERT, a tool for automated testing in Emacs Lisp.
Christian Ohler <ohler@gnu.org>
parents:
diff
changeset
|
244 |
c5917804ecad
Add ERT, a tool for automated testing in Emacs Lisp.
Christian Ohler <ohler@gnu.org>
parents:
diff
changeset
|
245 (ert-deftest ert-test-force-message-log-buffer-truncation () |
c5917804ecad
Add ERT, a tool for automated testing in Emacs Lisp.
Christian Ohler <ohler@gnu.org>
parents:
diff
changeset
|
246 :tags '(:causes-redisplay) |
c5917804ecad
Add ERT, a tool for automated testing in Emacs Lisp.
Christian Ohler <ohler@gnu.org>
parents:
diff
changeset
|
247 (labels ((body () |
c5917804ecad
Add ERT, a tool for automated testing in Emacs Lisp.
Christian Ohler <ohler@gnu.org>
parents:
diff
changeset
|
248 (loop for i below 3 do |
c5917804ecad
Add ERT, a tool for automated testing in Emacs Lisp.
Christian Ohler <ohler@gnu.org>
parents:
diff
changeset
|
249 (message "%s" i))) |
c5917804ecad
Add ERT, a tool for automated testing in Emacs Lisp.
Christian Ohler <ohler@gnu.org>
parents:
diff
changeset
|
250 ;; Uses the implicit messages buffer truncation implemented |
c5917804ecad
Add ERT, a tool for automated testing in Emacs Lisp.
Christian Ohler <ohler@gnu.org>
parents:
diff
changeset
|
251 ;; in Emacs' C core. |
c5917804ecad
Add ERT, a tool for automated testing in Emacs Lisp.
Christian Ohler <ohler@gnu.org>
parents:
diff
changeset
|
252 (c (x) |
c5917804ecad
Add ERT, a tool for automated testing in Emacs Lisp.
Christian Ohler <ohler@gnu.org>
parents:
diff
changeset
|
253 (ert-with-buffer-renamed ("*Messages*") |
c5917804ecad
Add ERT, a tool for automated testing in Emacs Lisp.
Christian Ohler <ohler@gnu.org>
parents:
diff
changeset
|
254 (let ((message-log-max x)) |
c5917804ecad
Add ERT, a tool for automated testing in Emacs Lisp.
Christian Ohler <ohler@gnu.org>
parents:
diff
changeset
|
255 (body)) |
c5917804ecad
Add ERT, a tool for automated testing in Emacs Lisp.
Christian Ohler <ohler@gnu.org>
parents:
diff
changeset
|
256 (with-current-buffer "*Messages*" |
c5917804ecad
Add ERT, a tool for automated testing in Emacs Lisp.
Christian Ohler <ohler@gnu.org>
parents:
diff
changeset
|
257 (buffer-string)))) |
c5917804ecad
Add ERT, a tool for automated testing in Emacs Lisp.
Christian Ohler <ohler@gnu.org>
parents:
diff
changeset
|
258 ;; Uses our lisp reimplementation. |
c5917804ecad
Add ERT, a tool for automated testing in Emacs Lisp.
Christian Ohler <ohler@gnu.org>
parents:
diff
changeset
|
259 (lisp (x) |
c5917804ecad
Add ERT, a tool for automated testing in Emacs Lisp.
Christian Ohler <ohler@gnu.org>
parents:
diff
changeset
|
260 (ert-with-buffer-renamed ("*Messages*") |
c5917804ecad
Add ERT, a tool for automated testing in Emacs Lisp.
Christian Ohler <ohler@gnu.org>
parents:
diff
changeset
|
261 (let ((message-log-max t)) |
c5917804ecad
Add ERT, a tool for automated testing in Emacs Lisp.
Christian Ohler <ohler@gnu.org>
parents:
diff
changeset
|
262 (body)) |
c5917804ecad
Add ERT, a tool for automated testing in Emacs Lisp.
Christian Ohler <ohler@gnu.org>
parents:
diff
changeset
|
263 (let ((message-log-max x)) |
c5917804ecad
Add ERT, a tool for automated testing in Emacs Lisp.
Christian Ohler <ohler@gnu.org>
parents:
diff
changeset
|
264 (ert--force-message-log-buffer-truncation)) |
c5917804ecad
Add ERT, a tool for automated testing in Emacs Lisp.
Christian Ohler <ohler@gnu.org>
parents:
diff
changeset
|
265 (with-current-buffer "*Messages*" |
c5917804ecad
Add ERT, a tool for automated testing in Emacs Lisp.
Christian Ohler <ohler@gnu.org>
parents:
diff
changeset
|
266 (buffer-string))))) |
c5917804ecad
Add ERT, a tool for automated testing in Emacs Lisp.
Christian Ohler <ohler@gnu.org>
parents:
diff
changeset
|
267 (loop for x in '(0 1 2 3 4 t) do |
c5917804ecad
Add ERT, a tool for automated testing in Emacs Lisp.
Christian Ohler <ohler@gnu.org>
parents:
diff
changeset
|
268 (should (equal (c x) (lisp x)))))) |
c5917804ecad
Add ERT, a tool for automated testing in Emacs Lisp.
Christian Ohler <ohler@gnu.org>
parents:
diff
changeset
|
269 |
c5917804ecad
Add ERT, a tool for automated testing in Emacs Lisp.
Christian Ohler <ohler@gnu.org>
parents:
diff
changeset
|
270 |
c5917804ecad
Add ERT, a tool for automated testing in Emacs Lisp.
Christian Ohler <ohler@gnu.org>
parents:
diff
changeset
|
271 (provide 'ert-x-tests) |
c5917804ecad
Add ERT, a tool for automated testing in Emacs Lisp.
Christian Ohler <ohler@gnu.org>
parents:
diff
changeset
|
272 |
c5917804ecad
Add ERT, a tool for automated testing in Emacs Lisp.
Christian Ohler <ohler@gnu.org>
parents:
diff
changeset
|
273 ;;; ert-x-tests.el ends here |