aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorYAMAMOTO Mitsuharu2019-05-23 10:53:23 +0900
committerYAMAMOTO Mitsuharu2019-05-23 10:53:23 +0900
commitb40dde705af4d53853de6185a2468153b442dc9a (patch)
treee8dabba695163c2d07439fad6accff761f8f714c /test
parent5d7dafacf4afc888511649f6fc24c28210cd0dfc (diff)
parent03feb9376b54c489e24478954a11061e9b0d6db7 (diff)
downloademacs-b40dde705af4d53853de6185a2468153b442dc9a.tar.gz
emacs-b40dde705af4d53853de6185a2468153b442dc9a.zip
Merge branch 'master' into harfbuzz
Diffstat (limited to 'test')
-rw-r--r--test/Makefile.in13
-rw-r--r--test/data/emacs-module/mod-test.c29
-rw-r--r--test/lisp/autorevert-tests.el255
-rw-r--r--test/lisp/delim-col-tests.el181
-rw-r--r--test/lisp/emacs-lisp/cl-macs-tests.el17
-rw-r--r--test/lisp/emacs-lisp/eieio-tests/eieio-tests.el56
-rw-r--r--test/lisp/emacs-lisp/lisp-mode-tests.el28
-rw-r--r--test/lisp/emacs-lisp/map-tests.el1
-rw-r--r--test/lisp/emacs-lisp/rx-tests.el8
-rw-r--r--test/lisp/emacs-lisp/seq-tests.el1
-rw-r--r--test/lisp/emacs-lisp/thunk-tests.el1
-rw-r--r--test/lisp/filenotify-tests.el59
-rw-r--r--test/lisp/files-tests.el15
-rw-r--r--test/lisp/font-lock-tests.el41
-rw-r--r--test/lisp/help-fns-tests.el2
-rw-r--r--test/lisp/image-file-tests.el44
-rw-r--r--test/lisp/image-tests.el11
-rw-r--r--test/lisp/mail/footnote-tests.el47
-rw-r--r--test/lisp/md4-tests.el1
-rw-r--r--test/lisp/net/tramp-tests.el109
-rw-r--r--test/lisp/nxml/nxml-mode-tests.el82
-rw-r--r--test/lisp/org/org-tests.el2
-rw-r--r--test/lisp/progmodes/python-tests.el13
-rw-r--r--test/lisp/soundex-tests.el2
-rw-r--r--test/lisp/tempo-tests.el228
-rw-r--r--test/lisp/term-tests.el136
-rw-r--r--test/lisp/textmodes/sgml-mode-tests.el12
-rw-r--r--test/lisp/vc/diff-mode-tests.el1
-rw-r--r--test/lisp/vc/smerge-mode-tests.el2
-rw-r--r--test/lisp/vc/vc-bzr-tests.el1
-rw-r--r--test/lisp/vc/vc-hg-tests.el1
-rw-r--r--test/lisp/xdg-tests.el1
-rw-r--r--test/manual/biditest.el1
-rw-r--r--test/manual/etags/el-src/emacs/lisp/progmodes/etags.el1
-rw-r--r--test/src/emacs-module-tests.el15
-rw-r--r--test/src/lcms-tests.el2
-rw-r--r--test/src/timefns-tests.el6
37 files changed, 1305 insertions, 120 deletions
diff --git a/test/Makefile.in b/test/Makefile.in
index ec20a427ba5..c18099587c0 100644
--- a/test/Makefile.in
+++ b/test/Makefile.in
@@ -254,8 +254,6 @@ else
254FPIC_CFLAGS = -fPIC 254FPIC_CFLAGS = -fPIC
255endif 255endif
256 256
257HYBRID_MALLOC = @HYBRID_MALLOC@
258LIBEGNU_ARCHIVE = ../lib/lib$(if $(HYBRID_MALLOC),e)gnu.a
259GMP_LIB = @GMP_LIB@ 257GMP_LIB = @GMP_LIB@
260GMP_OBJ = $(if @GMP_OBJ@, ../src/@GMP_OBJ@) 258GMP_OBJ = $(if @GMP_OBJ@, ../src/@GMP_OBJ@)
261 259
@@ -266,11 +264,16 @@ MODULE_CFLAGS = -I../src -I$(srcdir)/../lib \
266 $(WARN_CFLAGS) $(WERROR_CFLAGS) $(CFLAGS) 264 $(WARN_CFLAGS) $(WERROR_CFLAGS) $(CFLAGS)
267 265
268test_module = $(test_module_dir)/mod-test${SO} 266test_module = $(test_module_dir)/mod-test${SO}
269src/emacs-module-tests.log: $(test_module) 267src/emacs-module-tests.log src/emacs-module-tests.elc: $(test_module)
270$(test_module): $(test_module:${SO}=.c) ../src/emacs-module.h $(LIBEGNU_ARCHIVE) 268
269# In the compilation command, we can't use any object or archive file
270# as source because those are not compiled with -fPIC. Therefore we
271# use only source files.
272$(test_module): $(test_module:${SO}=.c) ../src/emacs-module.h
271 $(AM_V_at)${MKDIR_P} $(dir $@) 273 $(AM_V_at)${MKDIR_P} $(dir $@)
272 $(AM_V_CCLD)$(CC) -shared $(CPPFLAGS) $(MODULE_CFLAGS) $(LDFLAGS) \ 274 $(AM_V_CCLD)$(CC) -shared $(CPPFLAGS) $(MODULE_CFLAGS) $(LDFLAGS) \
273 -o $@ $< $(LIBEGNU_ARCHIVE) $(GMP_LIB) $(GMP_OBJ) 275 -o $@ $< $(GMP_LIB) $(GMP_OBJ:.o=.c) \
276 $(srcdir)/../lib/timespec.c $(srcdir)/../lib/gettime.c
274endif 277endif
275 278
276## Check that there is no 'automated' subdirectory, which would 279## Check that there is no 'automated' subdirectory, which would
diff --git a/test/data/emacs-module/mod-test.c b/test/data/emacs-module/mod-test.c
index b7007bd80ff..2891b73c1a0 100644
--- a/test/data/emacs-module/mod-test.c
+++ b/test/data/emacs-module/mod-test.c
@@ -19,7 +19,9 @@ along with GNU Emacs. If not, see <https://www.gnu.org/licenses/>. */
19 19
20#include "config.h" 20#include "config.h"
21 21
22#undef NDEBUG
22#include <assert.h> 23#include <assert.h>
24
23#include <errno.h> 25#include <errno.h>
24#include <limits.h> 26#include <limits.h>
25#include <stdio.h> 27#include <stdio.h>
@@ -316,16 +318,6 @@ Fmod_test_invalid_finalizer (emacs_env *env, ptrdiff_t nargs, emacs_value *args,
316} 318}
317 319
318static void 320static void
319signal_wrong_type_argument (emacs_env *env, const char *predicate,
320 emacs_value arg)
321{
322 emacs_value symbol = env->intern (env, "wrong-type-argument");
323 emacs_value elements[2] = {env->intern (env, predicate), arg};
324 emacs_value data = env->funcall (env, env->intern (env, "list"), 2, elements);
325 env->non_local_exit_signal (env, symbol, data);
326}
327
328static void
329signal_errno (emacs_env *env, const char *function) 321signal_errno (emacs_env *env, const char *function)
330{ 322{
331 const char *message = strerror (errno); 323 const char *message = strerror (errno);
@@ -345,16 +337,10 @@ Fmod_test_sleep_until (emacs_env *env, ptrdiff_t nargs, emacs_value *args,
345 void *data) 337 void *data)
346{ 338{
347 assert (nargs == 2); 339 assert (nargs == 2);
348 const double until_seconds = env->extract_float (env, args[0]); 340 const struct timespec until = env->extract_time (env, args[0]);
349 if (env->non_local_exit_check (env)) 341 if (env->non_local_exit_check (env))
350 return NULL; 342 return NULL;
351 if (until_seconds <= 0)
352 {
353 signal_wrong_type_argument (env, "cl-plusp", args[0]);
354 return NULL;
355 }
356 const bool process_input = env->is_not_nil (env, args[1]); 343 const bool process_input = env->is_not_nil (env, args[1]);
357 const struct timespec until = dtotimespec (until_seconds);
358 const struct timespec amount = make_timespec(0, 10000000); 344 const struct timespec amount = make_timespec(0, 10000000);
359 while (true) 345 while (true)
360 { 346 {
@@ -393,7 +379,11 @@ Fmod_test_nanoseconds (emacs_env *env, ptrdiff_t nargs, emacs_value *args, void
393 struct emacs_mpz nanoseconds; 379 struct emacs_mpz nanoseconds;
394 assert (LONG_MIN <= time.tv_sec && time.tv_sec <= LONG_MAX); 380 assert (LONG_MIN <= time.tv_sec && time.tv_sec <= LONG_MAX);
395 mpz_init_set_si (nanoseconds.value, time.tv_sec); 381 mpz_init_set_si (nanoseconds.value, time.tv_sec);
382#ifdef __MINGW32__
383 _Static_assert (1000000000 <= ULONG_MAX, "unsupported architecture");
384#else
396 static_assert (1000000000 <= ULONG_MAX, "unsupported architecture"); 385 static_assert (1000000000 <= ULONG_MAX, "unsupported architecture");
386#endif
397 mpz_mul_ui (nanoseconds.value, nanoseconds.value, 1000000000); 387 mpz_mul_ui (nanoseconds.value, nanoseconds.value, 1000000000);
398 assert (0 <= time.tv_nsec && time.tv_nsec <= ULONG_MAX); 388 assert (0 <= time.tv_nsec && time.tv_nsec <= ULONG_MAX);
399 mpz_add_ui (nanoseconds.value, nanoseconds.value, time.tv_nsec); 389 mpz_add_ui (nanoseconds.value, nanoseconds.value, time.tv_nsec);
@@ -445,6 +435,11 @@ bind_function (emacs_env *env, const char *name, emacs_value Sfun)
445int 435int
446emacs_module_init (struct emacs_runtime *ert) 436emacs_module_init (struct emacs_runtime *ert)
447{ 437{
438 /* Check that EMACS_MAJOR_VERSION is defined and an integral
439 constant. */
440 char dummy[EMACS_MAJOR_VERSION];
441 assert (27 <= sizeof dummy);
442
448 if (ert->size < sizeof *ert) 443 if (ert->size < sizeof *ert)
449 { 444 {
450 fprintf (stderr, "Runtime size of runtime structure (%"pT" bytes) " 445 fprintf (stderr, "Runtime size of runtime structure (%"pT" bytes) "
diff --git a/test/lisp/autorevert-tests.el b/test/lisp/autorevert-tests.el
index 6e8219d238d..5024a2daf0a 100644
--- a/test/lisp/autorevert-tests.el
+++ b/test/lisp/autorevert-tests.el
@@ -1,4 +1,4 @@
1;;; auto-revert-tests.el --- Tests of auto-revert 1;;; auto-revert-tests.el --- Tests of auto-revert -*- lexical-binding: t -*-
2 2
3;; Copyright (C) 2015-2019 Free Software Foundation, Inc. 3;; Copyright (C) 2015-2019 Free Software Foundation, Inc.
4 4
@@ -19,6 +19,33 @@
19 19
20;;; Commentary: 20;;; Commentary:
21 21
22;; Some of the tests require access to a remote host files. Since
23;; this could be problematic, a mock-up connection method "mock" is
24;; used. Emulating a remote connection, it simply calls "sh -i".
25;; Tramp's file name handlers still run, so this test is sufficient
26;; except for connection establishing.
27
28;; If you want to test a real Tramp connection, set
29;; $REMOTE_TEMPORARY_FILE_DIRECTORY to a suitable value in order to
30;; overwrite the default value. If you want to skip tests accessing a
31;; remote host, set this environment variable to "/dev/null" or
32;; whatever is appropriate on your system.
33
34;; For the remote file-notify library, Tramp checks for the existence
35;; of a respective command. The first command found is used. In
36;; order to use a dedicated one, the environment variable
37;; $REMOTE_FILE_NOTIFY_LIBRARY shall be set, possible values are
38;; "inotifywait", "gio-monitor" and "gvfs-monitor-dir".
39
40;; Local file-notify libraries are auto-detected during Emacs
41;; configuration. This can be changed with a respective configuration
42;; argument, like
43;;
44;; --with-file-notification=inotify
45;; --with-file-notification=kqueue
46;; --with-file-notification=gfile
47;; --with-file-notification=w32
48
22;; A whole test run can be performed calling the command `auto-revert-test-all'. 49;; A whole test run can be performed calling the command `auto-revert-test-all'.
23 50
24;;; Code: 51;;; Code:
@@ -26,8 +53,14 @@
26(require 'ert) 53(require 'ert)
27(require 'ert-x) 54(require 'ert-x)
28(require 'autorevert) 55(require 'autorevert)
29(setq auto-revert-notify-exclude-dir-regexp "nothing-to-be-excluded" 56(require 'tramp)
30 auto-revert-stop-on-user-input nil) 57
58(setq auto-revert-debug nil
59 auto-revert-notify-exclude-dir-regexp "nothing-to-be-excluded"
60 auto-revert-stop-on-user-input nil
61 file-notify-debug nil
62 tramp-verbose 0
63 tramp-message-show-message nil)
31 64
32(defconst auto-revert--timeout 10 65(defconst auto-revert--timeout 10
33 "Time to wait for a message.") 66 "Time to wait for a message.")
@@ -35,19 +68,90 @@
35(defvar auto-revert--messages nil 68(defvar auto-revert--messages nil
36 "Used to collect messages issued during a section of a test.") 69 "Used to collect messages issued during a section of a test.")
37 70
71;; There is no default value on w32 systems, which could work out of the box.
72(defconst auto-revert-test-remote-temporary-file-directory
73 (cond
74 ((getenv "REMOTE_TEMPORARY_FILE_DIRECTORY"))
75 ((eq system-type 'windows-nt) null-device)
76 (t (add-to-list
77 'tramp-methods
78 '("mock"
79 (tramp-login-program "sh")
80 (tramp-login-args (("-i")))
81 (tramp-remote-shell "/bin/sh")
82 (tramp-remote-shell-args ("-c"))
83 (tramp-connection-timeout 10)))
84 (add-to-list
85 'tramp-default-host-alist
86 `("\\`mock\\'" nil ,(system-name)))
87 ;; Emacs' Makefile sets $HOME to a nonexistent value. Needed in
88 ;; batch mode only, therefore. `temporary-file-directory' might
89 ;; be quoted, so we unquote it just in case.
90 (unless (and (null noninteractive) (file-directory-p "~/"))
91 (setenv "HOME" (file-name-unquote temporary-file-directory)))
92 (format "/mock::%s" temporary-file-directory)))
93 "Temporary directory for Tramp tests.")
94
95;; Filter suppressed remote file-notify libraries.
96(when (stringp (getenv "REMOTE_FILE_NOTIFY_LIBRARY"))
97 (dolist (lib '("inotifywait" "gio-monitor" "gvfs-monitor-dir"))
98 (unless (string-equal (getenv "REMOTE_FILE_NOTIFY_LIBRARY") lib)
99 (add-to-list 'tramp-connection-properties `(nil ,lib nil)))))
100
101(defvar auto-revert--test-enabled-remote-checked nil
102 "Cached result of `auto-revert--test-enabled-remote'.
103If the function did run, the value is a cons cell, the `cdr'
104being the result.")
105
106(defun auto-revert--test-enabled-remote ()
107 "Whether remote file access is enabled."
108 (unless (consp auto-revert--test-enabled-remote-checked)
109 (setq
110 auto-revert--test-enabled-remote-checked
111 (cons
112 t (ignore-errors
113 (and
114 (file-remote-p auto-revert-test-remote-temporary-file-directory)
115 (file-directory-p auto-revert-test-remote-temporary-file-directory)
116 (file-writable-p
117 auto-revert-test-remote-temporary-file-directory))))))
118 ;; Return result.
119 (cdr auto-revert--test-enabled-remote-checked))
120
38(defun auto-revert--wait-for-revert (buffer) 121(defun auto-revert--wait-for-revert (buffer)
39 "Wait until a message reports reversion of BUFFER. 122 "Wait until a message reports reversion of BUFFER.
40This expects `auto-revert--messages' to be bound by 123This expects `auto-revert--messages' to be bound by
41`ert-with-message-capture' before calling." 124`ert-with-message-capture' before calling."
42 (with-timeout (auto-revert--timeout nil) 125 ;; Remote files do not cooperate well with timers. So we count ourselves.
43 (while 126 (let ((ct (current-time)))
44 (null (string-match 127 (while (and (< (float-time (time-subtract (current-time) ct))
45 (format-message "Reverting buffer `%s'." (buffer-name buffer)) 128 auto-revert--timeout)
46 auto-revert--messages)) 129 (null (string-match
130 (format-message
131 "Reverting buffer `%s'\\." (buffer-name buffer))
132 auto-revert--messages)))
47 (if (with-current-buffer buffer auto-revert-use-notify) 133 (if (with-current-buffer buffer auto-revert-use-notify)
48 (read-event nil nil 0.1) 134 (read-event nil nil 0.1)
49 (sleep-for 0.1))))) 135 (sleep-for 0.1)))))
50 136
137(defmacro auto-revert--deftest-remote (test docstring)
138 "Define ert `TEST-remote' for remote files."
139 (declare (indent 1))
140 `(ert-deftest ,(intern (concat (symbol-name test) "-remote")) ()
141 ,docstring
142 :tags '(:expensive-test)
143 (let ((temporary-file-directory
144 auto-revert-test-remote-temporary-file-directory)
145 (auto-revert-remote-files t)
146 (ert-test (ert-get-test ',test))
147 vc-handled-backends)
148 (skip-unless (auto-revert--test-enabled-remote))
149 (tramp-cleanup-connection
150 (tramp-dissect-file-name temporary-file-directory) nil 'keep-password)
151 (condition-case err
152 (funcall (ert-test-body ert-test))
153 (error (message "%s" err) (signal (car err) (cdr err)))))))
154
51(ert-deftest auto-revert-test00-auto-revert-mode () 155(ert-deftest auto-revert-test00-auto-revert-mode ()
52 "Check autorevert for a file." 156 "Check autorevert for a file."
53 ;; `auto-revert-buffers' runs every 5". And we must wait, until the 157 ;; `auto-revert-buffers' runs every 5". And we must wait, until the
@@ -93,13 +197,16 @@ This expects `auto-revert--messages' to be bound by
93 (kill-buffer buf)) 197 (kill-buffer buf))
94 (ignore-errors (delete-file tmpfile))))) 198 (ignore-errors (delete-file tmpfile)))))
95 199
200(auto-revert--deftest-remote auto-revert-test00-auto-revert-mode
201 "Check autorevert for a remote file.")
202
96;; This is inspired by Bug#21841. 203;; This is inspired by Bug#21841.
97(ert-deftest auto-revert-test01-auto-revert-several-files () 204(ert-deftest auto-revert-test01-auto-revert-several-files ()
98 "Check autorevert for several files at once." 205 "Check autorevert for several files at once."
99 :tags '(:expensive-test) 206 :tags '(:expensive-test)
100 (skip-unless (executable-find "cp")) 207 (skip-unless (executable-find "cp" (file-remote-p temporary-file-directory)))
101 208
102 (let* ((cp (executable-find "cp")) 209 (let* ((cp (executable-find "cp" (file-remote-p temporary-file-directory)))
103 (tmpdir1 (make-temp-file "auto-revert-test" 'dir)) 210 (tmpdir1 (make-temp-file "auto-revert-test" 'dir))
104 (tmpdir2 (make-temp-file "auto-revert-test" 'dir)) 211 (tmpdir2 (make-temp-file "auto-revert-test" 'dir))
105 (tmpfile1 212 (tmpfile1
@@ -139,7 +246,9 @@ This expects `auto-revert--messages' to be bound by
139 ;; Strange, that `copy-directory' does not work as expected. 246 ;; Strange, that `copy-directory' does not work as expected.
140 ;; The following shell command is not portable on all 247 ;; The following shell command is not portable on all
141 ;; platforms, unfortunately. 248 ;; platforms, unfortunately.
142 (shell-command (format "%s -f %s/* %s" cp tmpdir2 tmpdir1)) 249 (shell-command
250 (format "%s -f %s/* %s"
251 cp (file-local-name tmpdir2) (file-local-name tmpdir1)))
143 252
144 ;; Check, that the buffers have been reverted. 253 ;; Check, that the buffers have been reverted.
145 (dolist (buf (list buf1 buf2)) 254 (dolist (buf (list buf1 buf2))
@@ -155,6 +264,9 @@ This expects `auto-revert--messages' to be bound by
155 (ignore-errors (delete-directory tmpdir1 'recursive)) 264 (ignore-errors (delete-directory tmpdir1 'recursive))
156 (ignore-errors (delete-directory tmpdir2 'recursive))))) 265 (ignore-errors (delete-directory tmpdir2 'recursive)))))
157 266
267(auto-revert--deftest-remote auto-revert-test01-auto-revert-several-files
268 "Check autorevert for several remote files at once.")
269
158;; This is inspired by Bug#23276. 270;; This is inspired by Bug#23276.
159(ert-deftest auto-revert-test02-auto-revert-deleted-file () 271(ert-deftest auto-revert-test02-auto-revert-deleted-file ()
160 "Check autorevert for a deleted file." 272 "Check autorevert for a deleted file."
@@ -185,8 +297,8 @@ This expects `auto-revert--messages' to be bound by
185 (add-hook 297 (add-hook
186 'before-revert-hook 298 'before-revert-hook
187 (lambda () 299 (lambda ()
188 ;; Temporarily. 300 (when auto-revert-debug
189 (message "%s deleted" buffer-file-name) 301 (message "%s deleted" buffer-file-name))
190 (delete-file buffer-file-name)) 302 (delete-file buffer-file-name))
191 nil t) 303 nil t)
192 304
@@ -198,8 +310,9 @@ This expects `auto-revert--messages' to be bound by
198 ;; notification should be disabled, falling back to 310 ;; notification should be disabled, falling back to
199 ;; polling. 311 ;; polling.
200 (should (string-match "any text" (buffer-string))) 312 (should (string-match "any text" (buffer-string)))
201 ;; With w32notify, the 'stopped' events are not sent. 313 ;; With w32notify, and on emba, the `stopped' events are not sent.
202 (or (eq file-notify--library 'w32notify) 314 (or (eq file-notify--library 'w32notify)
315 (getenv "EMACS_EMBA_CI")
203 (should-not auto-revert-notify-watch-descriptor)) 316 (should-not auto-revert-notify-watch-descriptor))
204 317
205 ;; Once the file has been recreated, the buffer shall be 318 ;; Once the file has been recreated, the buffer shall be
@@ -231,6 +344,9 @@ This expects `auto-revert--messages' to be bound by
231 (kill-buffer buf)) 344 (kill-buffer buf))
232 (ignore-errors (delete-file tmpfile))))) 345 (ignore-errors (delete-file tmpfile)))))
233 346
347(auto-revert--deftest-remote auto-revert-test02-auto-revert-deleted-file
348 "Check autorevert for a deleted remote file.")
349
234(ert-deftest auto-revert-test03-auto-revert-tail-mode () 350(ert-deftest auto-revert-test03-auto-revert-tail-mode ()
235 "Check autorevert tail mode." 351 "Check autorevert tail mode."
236 ;; `auto-revert-buffers' runs every 5". And we must wait, until the 352 ;; `auto-revert-buffers' runs every 5". And we must wait, until the
@@ -266,6 +382,9 @@ This expects `auto-revert--messages' to be bound by
266 (ignore-errors (kill-buffer buf)) 382 (ignore-errors (kill-buffer buf))
267 (ignore-errors (delete-file tmpfile))))) 383 (ignore-errors (delete-file tmpfile)))))
268 384
385(auto-revert--deftest-remote auto-revert-test03-auto-revert-tail-mode
386 "Check remote autorevert tail mode.")
387
269(ert-deftest auto-revert-test04-auto-revert-mode-dired () 388(ert-deftest auto-revert-test04-auto-revert-mode-dired ()
270 "Check autorevert for dired." 389 "Check autorevert for dired."
271 ;; `auto-revert-buffers' runs every 5". And we must wait, until the 390 ;; `auto-revert-buffers' runs every 5". And we must wait, until the
@@ -314,6 +433,114 @@ This expects `auto-revert--messages' to be bound by
314 (kill-buffer buf)) 433 (kill-buffer buf))
315 (ignore-errors (delete-file tmpfile))))) 434 (ignore-errors (delete-file tmpfile)))))
316 435
436(auto-revert--deftest-remote auto-revert-test04-auto-revert-mode-dired
437 "Check remote autorevert for dired.")
438
439(defun auto-revert-test--write-file (string file)
440 "Write STRING to FILE."
441 (write-region string nil file nil 'no-message))
442
443(defun auto-revert-test--buffer-string (buffer)
444 "Contents of BUFFER as a string."
445 (with-current-buffer buffer
446 (buffer-string)))
447
448(defun auto-revert-test--wait-for (pred max-wait)
449 "Wait until PRED is true, or MAX-WAIT seconds elapsed."
450 (let ((ct (current-time)))
451 (while (and (< (float-time (time-subtract (current-time) ct)) max-wait)
452 (not (funcall pred)))
453 (read-event nil nil 0.1))))
454
455(defun auto-revert-test--wait-for-buffer-text (buffer string max-wait)
456 "Wait until BUFFER has the contents STRING, or MAX-WAIT seconds elapsed."
457 (auto-revert-test--wait-for
458 (lambda () (string-equal (auto-revert-test--buffer-string buffer) string))
459 max-wait))
460
461(ert-deftest auto-revert-test05-global-notify ()
462 "Test `global-auto-revert-mode' without polling."
463 :tags '(:expensive-test)
464 (skip-unless (or file-notify--library
465 (file-remote-p temporary-file-directory)))
466 (let* ((auto-revert-use-notify t)
467 (auto-revert-avoid-polling t)
468 (was-in-global-auto-revert-mode global-auto-revert-mode)
469 (file-1 (make-temp-file "global-auto-revert-test-1"))
470 (file-2 (make-temp-file "global-auto-revert-test-2"))
471 (file-3 (make-temp-file "global-auto-revert-test-3"))
472 (file-2b (concat file-2 "-b"))
473 buf-1 buf-2 buf-3)
474 (unwind-protect
475 (progn
476 (setq buf-1 (find-file-noselect file-1))
477 (setq buf-2 (find-file-noselect file-2))
478 (auto-revert-test--write-file "1-a" file-1)
479 (should (equal (auto-revert-test--buffer-string buf-1) ""))
480
481 (global-auto-revert-mode 1) ; Turn it on.
482
483 (should (buffer-local-value
484 'auto-revert-notify-watch-descriptor buf-1))
485 (should (buffer-local-value
486 'auto-revert-notify-watch-descriptor buf-2))
487
488 ;; buf-1 should have been reverted immediately when the mode
489 ;; was enabled.
490 (should (equal (auto-revert-test--buffer-string buf-1) "1-a"))
491
492 ;; Alter a file.
493 (auto-revert-test--write-file "2-a" file-2)
494 ;; Allow for some time to handle notification events.
495 (auto-revert-test--wait-for-buffer-text buf-2 "2-a" 1)
496 (should (equal (auto-revert-test--buffer-string buf-2) "2-a"))
497
498 ;; Visit a file, and modify it on disk.
499 (setq buf-3 (find-file-noselect file-3))
500 ;; Newly opened buffers won't be use notification until the
501 ;; first poll cycle; wait for it.
502 (auto-revert-test--wait-for
503 (lambda () (buffer-local-value
504 'auto-revert-notify-watch-descriptor buf-3))
505 (+ auto-revert-interval 1))
506 (should (buffer-local-value
507 'auto-revert-notify-watch-descriptor buf-3))
508 (auto-revert-test--write-file "3-a" file-3)
509 (auto-revert-test--wait-for-buffer-text buf-3 "3-a" 1)
510 (should (equal (auto-revert-test--buffer-string buf-3) "3-a"))
511
512 ;; Delete a visited file, and re-create it with new contents.
513 (delete-file file-1)
514 (sleep-for 0.5)
515 (should (equal (auto-revert-test--buffer-string buf-1) "1-a"))
516 (auto-revert-test--write-file "1-b" file-1)
517 (auto-revert-test--wait-for-buffer-text buf-1 "1-b"
518 (+ auto-revert-interval 1))
519 (should (buffer-local-value
520 'auto-revert-notify-watch-descriptor buf-1))
521
522 ;; Write a buffer to a new file, then modify the new file on disk.
523 (with-current-buffer buf-2
524 (write-file file-2b))
525 (should (equal (auto-revert-test--buffer-string buf-2) "2-a"))
526 (auto-revert-test--write-file "2-b" file-2b)
527 (auto-revert-test--wait-for-buffer-text buf-2 "2-b"
528 (+ auto-revert-interval 1))
529 (should (buffer-local-value
530 'auto-revert-notify-watch-descriptor buf-2)))
531
532 ;; Clean up.
533 (unless was-in-global-auto-revert-mode
534 (global-auto-revert-mode 0)) ; Turn it off.
535 (dolist (buf (list buf-1 buf-2 buf-3))
536 (ignore-errors (kill-buffer buf)))
537 (dolist (file (list file-1 file-2 file-2b file-3))
538 (ignore-errors (delete-file file)))
539 )))
540
541(auto-revert--deftest-remote auto-revert-test04-auto-revert-mode-dired
542 "Test `global-auto-revert-mode' without polling for remote buffers.")
543
317(defun auto-revert-test-all (&optional interactive) 544(defun auto-revert-test-all (&optional interactive)
318 "Run all tests for \\[auto-revert]." 545 "Run all tests for \\[auto-revert]."
319 (interactive "p") 546 (interactive "p")
diff --git a/test/lisp/delim-col-tests.el b/test/lisp/delim-col-tests.el
new file mode 100644
index 00000000000..f2a0377b07b
--- /dev/null
+++ b/test/lisp/delim-col-tests.el
@@ -0,0 +1,181 @@
1;;; delim-col-tests.el --- Tests for delim-col.el -*- lexical-binding: t; -*-
2
3;; Copyright (C) 2019 Free Software Foundation, Inc.
4
5;; Author: Stefan Kangas <stefankangas@gmail.com>
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 <https://www.gnu.org/licenses/>.
21
22;;; Commentary:
23
24;;; Code:
25
26(require 'ert)
27(require 'delim-col)
28
29(ert-deftest delim-col-tests-delimit-columns ()
30 (with-temp-buffer
31 (insert "a b c\n")
32 (delimit-columns-region (point-min) (point-max))
33 (should (equal (buffer-string) "a, b, c\n")))
34 (with-temp-buffer
35 (insert "a b c d\n"
36 "aaaa bb ccc ddddd\n"
37 "aaa bbb cccc dddd\n"
38 "aa bb ccccccc ddd\n")
39 (delimit-columns-region (point-min) (point-max))
40 (should (equal (buffer-string)
41 (concat "a, b, c, d \n"
42 "aaaa, bb, ccc, ddddd\n"
43 "aaa, bbb, cccc, dddd \n"
44 "aa, bb, ccccccc, ddd \n")))))
45
46(ert-deftest delim-col-tests-delimit-rectangle ()
47 (with-temp-buffer
48 (insert "a b c d\n"
49 "aaaa bb ccc ddddd\n"
50 "aaa bbb cccc dddd\n"
51 "aa bb ccccccc ddd\n")
52 (delimit-columns-rectangle 3 58) ; from first b to last c
53 (should (equal (buffer-string)
54 (concat "a b, c d\n"
55 "aaaa bb, ccc ddddd\n"
56 "aaa bbb, cccc dddd\n"
57 "aa bb, ccccccc ddd\n")))))
58
59(ert-deftest delim-col-tests-delimit-columns-str-separator ()
60 (let ((delimit-columns-str-separator ":"))
61 (with-temp-buffer
62 (insert "a b\n")
63 (delimit-columns-region (point-min) (point-max))
64 (should (equal (buffer-string) "a:b\n")))
65 (with-temp-buffer
66 (insert "a b c d\n"
67 "aa bb cc dd\n")
68 (delimit-columns-rectangle 3 16) ; from first b to last c
69 (should (equal (buffer-string)
70 (concat "a b: c d\n"
71 "aa bb:cc dd\n"))))))
72
73(ert-deftest delim-col-tests-delimit-columns-str-before-after ()
74 (let ((delimit-columns-str-before "[ ")
75 (delimit-columns-str-after " ]"))
76 (with-temp-buffer
77 (insert "a b c\n")
78 (delimit-columns-region (point-min) (point-max))
79 (should (equal (buffer-string) "[ a, b, c ]\n")))
80 (with-temp-buffer
81 (insert "a b c d\n"
82 "aaaa bb ccc ddddd\n"
83 "aaa bbb cccc dddd\n"
84 "aa bb ccccccc ddd\n")
85 (delimit-columns-region (point-min) (point-max))
86 (should (equal (buffer-string)
87 (concat "[ a, b, c, d ]\n"
88 "[ aaaa, bb, ccc, ddddd ]\n"
89 "[ aaa, bbb, cccc, dddd ]\n"
90 "[ aa, bb, ccccccc, ddd ]\n"))))
91 (with-temp-buffer
92 (insert "a b c d\n"
93 "aaaa bb ccc ddddd\n"
94 "aaa bbb cccc dddd\n"
95 "aa bb ccccccc ddd\n")
96 (delimit-columns-rectangle 3 58) ; from first b to last c
97 (should (equal (buffer-string)
98 (concat "a [ b, c ] d\n"
99 "aaaa [ bb, ccc ] ddddd\n"
100 "aaa [ bbb, cccc ] dddd\n"
101 "aa [ bb, ccccccc ] ddd\n"))))))
102
103(ert-deftest delim-col-tests-delimit-colummns-before-after ()
104 (let ((delimit-columns-before "<")
105 (delimit-columns-after ">"))
106 (with-temp-buffer
107 (insert "a b\n")
108 (delimit-columns-region (point-min) (point-max))
109 (should (equal (buffer-string) "<a>, <b>\n")))
110 (with-temp-buffer
111 (insert "a b c d\n"
112 "aa bb cc dd\n")
113 (delimit-columns-rectangle 3 17)
114 (should (equal (buffer-string)
115 (concat "a <b>, <c> d\n"
116 "aa <bb>, <cc> dd\n"))))))
117
118(ert-deftest delim-col-tests-delimit-columns-separator ()
119 (let ((delimit-columns-separator ","))
120 (with-temp-buffer
121 (insert "a,b,c\n")
122 (delimit-columns-region (point-min) (point-max))
123 (should (equal (buffer-string) "a, b, c\n")))))
124
125(ert-deftest delim-col-tests-delimit-columns-format/nil ()
126 (let ((delimit-columns-format nil))
127 (with-temp-buffer
128 (insert "a b\n"
129 "aa bb\n")
130 (delimit-columns-region (point-min) (point-max))
131 (should (equal (buffer-string)
132 (concat "a, b\n"
133 "aa, bb\n"))))
134 (with-temp-buffer
135 (insert "a b c d\n"
136 "aa bb cc dd\n")
137 (delimit-columns-rectangle 3 17) ; from first b to last c
138 (should (equal (buffer-string)
139 (concat "a b, c d\n"
140 "aa bb, cc dd\n"))))))
141
142(ert-deftest delim-col-tests-delimit-columns-format/separator ()
143 (let ((delimit-columns-format 'separator)
144 (delimit-columns-before "<")
145 (delimit-columns-after ">"))
146 (with-temp-buffer
147 (insert "a b\n"
148 "aa bb\n")
149 (delimit-columns-region (point-min) (point-max))
150 (should (equal (buffer-string)
151 (concat "<a> , <b> \n"
152 "<aa>, <bb>\n"))))
153 (with-temp-buffer
154 (insert "a b c d\n"
155 "aa bb cc dd\n")
156 (delimit-columns-rectangle 3 17) ; from first b to last c
157 (should (equal (buffer-string)
158 (concat "a <b> , <c> d\n"
159 "aa <bb>, <cc> dd\n"))))))
160
161(ert-deftest delim-col-tests-delimit-columns-format/padding ()
162 (let ((delimit-columns-format 'padding)
163 (delimit-columns-before "<")
164 (delimit-columns-after ">"))
165 (with-temp-buffer
166 (insert "a b\n"
167 "aa bb\n")
168 (delimit-columns-region (point-min) (point-max))
169 (should (equal (buffer-string)
170 (concat "<a >, <b >\n"
171 "<aa>, <bb>\n"))))
172 (with-temp-buffer
173 (insert "a b c d\n"
174 "aa bb cc dd\n")
175 (delimit-columns-rectangle 3 17) ; from first b to last c
176 (should (equal (buffer-string)
177 (concat "a <b >, <c > d\n"
178 "aa <bb>, <cc> dd\n"))))))
179
180(provide 'delim-col-tests)
181;;; delim-col-tests.el ends here
diff --git a/test/lisp/emacs-lisp/cl-macs-tests.el b/test/lisp/emacs-lisp/cl-macs-tests.el
index 989553bd7bd..09ce660a2fd 100644
--- a/test/lisp/emacs-lisp/cl-macs-tests.el
+++ b/test/lisp/emacs-lisp/cl-macs-tests.el
@@ -513,4 +513,21 @@ collection clause."
513 (macroexpand '(cl-defstruct (hash-table (:predicate hash-table-p)))) 513 (macroexpand '(cl-defstruct (hash-table (:predicate hash-table-p))))
514 :type 'wrong-type-argument)) 514 :type 'wrong-type-argument))
515 515
516(ert-deftest cl-macs-test--symbol-macrolet ()
517 ;; A `setq' shouldn't be converted to a `setf' just because it occurs within
518 ;; a symbol-macrolet!
519 (should-error
520 ;; Use `eval' so the error is signaled when running the test rather than
521 ;; when macroexpanding it.
522 (eval '(let ((l (list 1))) (cl-symbol-macrolet ((x 1)) (setq (car l) 0)))))
523 ;; Make sure `gv-synthetic-place' isn't macro-expanded before `setf' gets to
524 ;; see its `gv-expander'.
525 (should (equal (let ((l '(0)))
526 (let ((cl (car l)))
527 (cl-symbol-macrolet
528 ((p (gv-synthetic-place cl (lambda (v) `(setcar l ,v)))))
529 (cl-incf p)))
530 l)
531 '(1))))
532
516;;; cl-macs-tests.el ends here 533;;; cl-macs-tests.el ends here
diff --git a/test/lisp/emacs-lisp/eieio-tests/eieio-tests.el b/test/lisp/emacs-lisp/eieio-tests/eieio-tests.el
index ea6df0f36fc..e6a35c4cd7a 100644
--- a/test/lisp/emacs-lisp/eieio-tests/eieio-tests.el
+++ b/test/lisp/emacs-lisp/eieio-tests/eieio-tests.el
@@ -696,6 +696,17 @@ Do not override for `prot-2'."
696 (setq eitest-II3 (clone eitest-II2 "eitest-II3 Test.")) 696 (setq eitest-II3 (clone eitest-II2 "eitest-II3 Test."))
697 (oset eitest-II3 slot3 'penguin) 697 (oset eitest-II3 slot3 'penguin)
698 698
699 ;; Test that slots are non-initialized slots are unbounded
700 (oref eitest-II2 slot1)
701 (should (slot-boundp eitest-II2 'slot1))
702 (should-not (slot-boundp eitest-II2 'slot2))
703 (should-not (slot-boundp eitest-II2 'slot3))
704 (should-not (slot-boundp eitest-II3 'slot2))
705 (should-not (slot-boundp eitest-II3 'slot1))
706 (should-not (slot-boundp eitest-II3 'slot2))
707 (should (eieio-instance-inheritor-slot-boundp eitest-II3 'slot2))
708 (should (slot-boundp eitest-II3 'slot3))
709
699 ;; Test level 1 inheritance 710 ;; Test level 1 inheritance
700 (should (eq (oref eitest-II3 slot1) 'moose)) 711 (should (eq (oref eitest-II3 slot1) 'moose))
701 ;; Test level 2 inheritance 712 ;; Test level 2 inheritance
@@ -862,8 +873,7 @@ Subclasses to override slot attributes.")
862 (should (oref obj1 a-slot)))) 873 (should (oref obj1 a-slot))))
863 874
864(defclass NAMED (eieio-named) 875(defclass NAMED (eieio-named)
865 ((some-slot :initform nil) 876 ((some-slot :initform nil))
866 )
867 "A class inheriting from eieio-named.") 877 "A class inheriting from eieio-named.")
868 878
869(ert-deftest eieio-test-35-named-object () 879(ert-deftest eieio-test-35-named-object ()
@@ -902,6 +912,48 @@ Subclasses to override slot attributes.")
902 (should 912 (should
903 (fboundp 'eieio--defalias))) 913 (fboundp 'eieio--defalias)))
904 914
915(ert-deftest eieio-test-38-clone-named-object ()
916 (let* ((A (NAMED :object-name "aa"))
917 (B (clone A :object-name "bb"))
918 (C (clone A "cc"))
919 (D (clone A))
920 (E (clone D)))
921 (should (string= "aa" (oref A object-name)))
922 (should (string= "bb" (oref B object-name)))
923 (should (string= "cc" (oref C object-name)))
924 (should (string= "aa-1" (oref D object-name)))
925 (should (string= "aa-2" (oref E object-name)))))
926
927(defclass TII (eieio-instance-inheritor)
928 ((a :initform 1 :initarg :a)
929 (b :initarg :b)
930 (c :initarg :c))
931 "Instance Inheritor test class.")
932
933(ert-deftest eieio-test-39-clone-instance-inheritor-with-args ()
934 (let* ((A (TII))
935 (B (clone A :b "bb"))
936 (C (clone B :a "aa")))
937
938 (should (string= "aa" (oref C :a)))
939 (should (string= "bb" (oref C :b)))
940
941 (should (slot-boundp A :a))
942 (should-not (slot-boundp A :b))
943 (should-not (slot-boundp A :c))
944
945 (should-not (slot-boundp B :a))
946 (should (slot-boundp B :b))
947 (should-not (slot-boundp A :c))
948
949 (should (slot-boundp C :a))
950 (should-not (slot-boundp C :b))
951 (should-not (slot-boundp C :c))
952
953 (should (eieio-instance-inheritor-slot-boundp C :a))
954 (should (eieio-instance-inheritor-slot-boundp C :b))
955 (should-not (eieio-instance-inheritor-slot-boundp C :c))))
956
905 957
906(provide 'eieio-tests) 958(provide 'eieio-tests)
907 959
diff --git a/test/lisp/emacs-lisp/lisp-mode-tests.el b/test/lisp/emacs-lisp/lisp-mode-tests.el
index a6370742ab4..63632449ca5 100644
--- a/test/lisp/emacs-lisp/lisp-mode-tests.el
+++ b/test/lisp/emacs-lisp/lisp-mode-tests.el
@@ -136,6 +136,34 @@ noindent\" 3
136 (indent-sexp) 136 (indent-sexp)
137 (should (equal (buffer-string) "(())")))) 137 (should (equal (buffer-string) "(())"))))
138 138
139(ert-deftest indent-sexp-stop-before-eol-comment ()
140 "`indent-sexp' shouldn't look for more sexps after an eol comment."
141 ;; See https://debbugs.gnu.org/35286.
142 (with-temp-buffer
143 (emacs-lisp-mode)
144 (let ((str "() ;;\n x"))
145 (insert str)
146 (goto-char (point-min))
147 (indent-sexp)
148 ;; The "x" is in the next sexp, so it shouldn't get indented.
149 (should (equal (buffer-string) str)))))
150
151(ert-deftest indent-sexp-stop-before-eol-non-lisp ()
152 "`indent-sexp' shouldn't be too agressive in non-Lisp modes."
153 ;; See https://debbugs.gnu.org/35286#13.
154 (with-temp-buffer
155 (prolog-mode)
156 (let ((str "\
157x(H) -->
158 {y(H)}.
159a(A) -->
160 b(A)."))
161 (insert str)
162 (search-backward "{")
163 (indent-sexp)
164 ;; There's no line-spanning sexp, so nothing should be indented.
165 (should (equal (buffer-string) str)))))
166
139(ert-deftest lisp-indent-region () 167(ert-deftest lisp-indent-region ()
140 "Test basics of `lisp-indent-region'." 168 "Test basics of `lisp-indent-region'."
141 (with-temp-buffer 169 (with-temp-buffer
diff --git a/test/lisp/emacs-lisp/map-tests.el b/test/lisp/emacs-lisp/map-tests.el
index a54af8059b3..5e044d4be81 100644
--- a/test/lisp/emacs-lisp/map-tests.el
+++ b/test/lisp/emacs-lisp/map-tests.el
@@ -3,7 +3,6 @@
3;; Copyright (C) 2015-2019 Free Software Foundation, Inc. 3;; Copyright (C) 2015-2019 Free Software Foundation, Inc.
4 4
5;; Author: Nicolas Petton <nicolas@petton.fr> 5;; Author: Nicolas Petton <nicolas@petton.fr>
6;; Maintainer: emacs-devel@gnu.org
7 6
8;; This file is part of GNU Emacs. 7;; This file is part of GNU Emacs.
9 8
diff --git a/test/lisp/emacs-lisp/rx-tests.el b/test/lisp/emacs-lisp/rx-tests.el
index 4a5919edf02..6f392d616d1 100644
--- a/test/lisp/emacs-lisp/rx-tests.el
+++ b/test/lisp/emacs-lisp/rx-tests.el
@@ -107,7 +107,13 @@
107 "ab")) 107 "ab"))
108 (should (equal (and (string-match (rx (or "a" "ab" "abc")) s) 108 (should (equal (and (string-match (rx (or "a" "ab" "abc")) s)
109 (match-string 0 s)) 109 (match-string 0 s))
110 "a")))) 110 "a")))
111 ;; Test zero-argument `or'.
112 (should (equal (rx (or)) regexp-unmatchable)))
113
114(ert-deftest rx-seq ()
115 ;; Test zero-argument `seq'.
116 (should (equal (rx (seq)) "")))
111 117
112(provide 'rx-tests) 118(provide 'rx-tests)
113;; rx-tests.el ends here. 119;; rx-tests.el ends here.
diff --git a/test/lisp/emacs-lisp/seq-tests.el b/test/lisp/emacs-lisp/seq-tests.el
index ef05e2b389d..8f66ba4f92f 100644
--- a/test/lisp/emacs-lisp/seq-tests.el
+++ b/test/lisp/emacs-lisp/seq-tests.el
@@ -3,7 +3,6 @@
3;; Copyright (C) 2014-2019 Free Software Foundation, Inc. 3;; Copyright (C) 2014-2019 Free Software Foundation, Inc.
4 4
5;; Author: Nicolas Petton <nicolas@petton.fr> 5;; Author: Nicolas Petton <nicolas@petton.fr>
6;; Maintainer: emacs-devel@gnu.org
7 6
8;; This file is part of GNU Emacs. 7;; This file is part of GNU Emacs.
9 8
diff --git a/test/lisp/emacs-lisp/thunk-tests.el b/test/lisp/emacs-lisp/thunk-tests.el
index caa2c415460..69bfc196383 100644
--- a/test/lisp/emacs-lisp/thunk-tests.el
+++ b/test/lisp/emacs-lisp/thunk-tests.el
@@ -3,7 +3,6 @@
3;; Copyright (C) 2015-2019 Free Software Foundation, Inc. 3;; Copyright (C) 2015-2019 Free Software Foundation, Inc.
4 4
5;; Author: Nicolas Petton <nicolas@petton.fr> 5;; Author: Nicolas Petton <nicolas@petton.fr>
6;; Maintainer: emacs-devel@gnu.org
7 6
8;; This file is part of GNU Emacs. 7;; This file is part of GNU Emacs.
9 8
diff --git a/test/lisp/filenotify-tests.el b/test/lisp/filenotify-tests.el
index a40dc720786..9dfa794e307 100644
--- a/test/lisp/filenotify-tests.el
+++ b/test/lisp/filenotify-tests.el
@@ -195,7 +195,8 @@ Return nil when any other file notification watch is still active."
195 file-notify--test-events nil 195 file-notify--test-events nil
196 file-notify--test-monitors nil)) 196 file-notify--test-monitors nil))
197 197
198(setq password-cache-expiry nil 198(setq file-notify-debug nil
199 password-cache-expiry nil
199 tramp-verbose 0 200 tramp-verbose 0
200 tramp-message-show-message nil) 201 tramp-message-show-message nil)
201 202
@@ -515,8 +516,9 @@ and the event to `file-notify--test-events'."
515 (unless (string-match 516 (unless (string-match
516 (regexp-quote ".#") 517 (regexp-quote ".#")
517 (file-notify--event-file-name file-notify--test-event)) 518 (file-notify--event-file-name file-notify--test-event))
518 ;;(message "file-notify--test-event-handler result: %s event: %S" 519 (when file-notify-debug
519 ;;(null (ert-test-failed-p result)) file-notify--test-event) 520 (message "file-notify--test-event-handler result: %s event: %S"
521 (null (ert-test-failed-p result)) file-notify--test-event))
520 (setq file-notify--test-events 522 (setq file-notify--test-events
521 (append file-notify--test-events `(,file-notify--test-event)) 523 (append file-notify--test-events `(,file-notify--test-event))
522 file-notify--test-results 524 file-notify--test-results
@@ -680,17 +682,18 @@ delivered."
680 (file-notify--test-library) "gvfs-monitor-dir.exe") 682 (file-notify--test-library) "gvfs-monitor-dir.exe")
681 '((deleted stopped) 683 '((deleted stopped)
682 (created deleted stopped))) 684 (created deleted stopped)))
683 ;; There are two `deleted' events, for the file and for
684 ;; the directory. Except for cygwin and kqueue. And
685 ;; cygwin does not raise a `changed' event.
686 ((eq system-type 'cygwin)
687 '(created deleted stopped))
688 ((string-equal (file-notify--test-library) "kqueue")
689 '(created changed deleted stopped))
690 ;; On emba, `deleted' and `stopped' events of the 685 ;; On emba, `deleted' and `stopped' events of the
691 ;; directory are not detected. 686 ;; directory are not detected.
692 ((getenv "EMACS_EMBA_CI") 687 ((getenv "EMACS_EMBA_CI")
693 '(created changed deleted)) 688 '(created changed deleted))
689 ;; There are two `deleted' events, for the file and for
690 ;; the directory. Except for cygwin, kqueue and remote
691 ;; files. And cygwin does not raise a `changed' event.
692 ((eq system-type 'cygwin)
693 '(created deleted stopped))
694 ((or (string-equal (file-notify--test-library) "kqueue")
695 (file-remote-p temporary-file-directory))
696 '(created changed deleted stopped))
694 (t '(created changed deleted deleted stopped))) 697 (t '(created changed deleted deleted stopped)))
695 (write-region 698 (write-region
696 "any text" nil file-notify--test-tmpfile nil 'no-message) 699 "any text" nil file-notify--test-tmpfile nil 'no-message)
@@ -740,6 +743,9 @@ delivered."
740 ;; directory are not detected. 743 ;; directory are not detected.
741 ((getenv "EMACS_EMBA_CI") 744 ((getenv "EMACS_EMBA_CI")
742 '(created changed created changed deleted deleted)) 745 '(created changed created changed deleted deleted))
746 ;; Remote files return two `deleted' events.
747 ((file-remote-p temporary-file-directory)
748 '(created changed created changed deleted deleted stopped))
743 (t '(created changed created changed 749 (t '(created changed created changed
744 deleted deleted deleted stopped))) 750 deleted deleted deleted stopped)))
745 (write-region 751 (write-region
@@ -784,18 +790,19 @@ delivered."
784 (file-notify--test-library) "gvfs-monitor-dir.exe") 790 (file-notify--test-library) "gvfs-monitor-dir.exe")
785 '((deleted stopped) 791 '((deleted stopped)
786 (created deleted stopped))) 792 (created deleted stopped)))
787 ;; There are two `deleted' events, for the file and for
788 ;; the directory. Except for cygwin and kqueue. And
789 ;; cygwin raises `created' and `deleted' events instead
790 ;; of a `renamed' event.
791 ((eq system-type 'cygwin)
792 '(created created deleted deleted stopped))
793 ((string-equal (file-notify--test-library) "kqueue")
794 '(created changed renamed deleted stopped))
795 ;; On emba, `deleted' and `stopped' events of the 793 ;; On emba, `deleted' and `stopped' events of the
796 ;; directory are not detected. 794 ;; directory are not detected.
797 ((getenv "EMACS_EMBA_CI") 795 ((getenv "EMACS_EMBA_CI")
798 '(created changed renamed deleted)) 796 '(created changed renamed deleted))
797 ;; There are two `deleted' events, for the file and for
798 ;; the directory. Except for cygwin, kqueue and remote
799 ;; files. And cygwin raises `created' and `deleted'
800 ;; events instead of a `renamed' event.
801 ((eq system-type 'cygwin)
802 '(created created deleted deleted stopped))
803 ((or (string-equal (file-notify--test-library) "kqueue")
804 (file-remote-p temporary-file-directory))
805 '(created changed renamed deleted stopped))
799 (t '(created changed renamed deleted deleted stopped))) 806 (t '(created changed renamed deleted deleted stopped)))
800 (write-region 807 (write-region
801 "any text" nil file-notify--test-tmpfile nil 'no-message) 808 "any text" nil file-notify--test-tmpfile nil 'no-message)
@@ -1039,11 +1046,12 @@ delivered."
1039 '((deleted stopped) 1046 '((deleted stopped)
1040 (created deleted stopped))) 1047 (created deleted stopped)))
1041 ;; There are two `deleted' events, for the file and for 1048 ;; There are two `deleted' events, for the file and for
1042 ;; the directory. Except for cygwin and kqueue. And 1049 ;; the directory. Except for cygwin, kqueue and remote
1043 ;; cygwin does not raise a `changed' event. 1050 ;; files. And cygwin does not raise a `changed' event.
1044 ((eq system-type 'cygwin) 1051 ((eq system-type 'cygwin)
1045 '(created deleted stopped)) 1052 '(created deleted stopped))
1046 ((string-equal (file-notify--test-library) "kqueue") 1053 ((or (string-equal (file-notify--test-library) "kqueue")
1054 (file-remote-p temporary-file-directory))
1047 '(created changed deleted stopped)) 1055 '(created changed deleted stopped))
1048 (t '(created changed deleted deleted stopped))) 1056 (t '(created changed deleted deleted stopped)))
1049 (write-region 1057 (write-region
@@ -1259,7 +1267,8 @@ delivered."
1259 (file-notify--test-with-events 1267 (file-notify--test-with-events
1260 (cond 1268 (cond
1261 ;; On cygwin we only get the `changed' event. 1269 ;; On cygwin we only get the `changed' event.
1262 ((eq system-type 'cygwin) '(changed)) 1270 ((eq system-type 'cygwin)
1271 '(changed))
1263 (t '(renamed created changed))) 1272 (t '(renamed created changed)))
1264 ;; The file is renamed when creating a backup. It shall 1273 ;; The file is renamed when creating a backup. It shall
1265 ;; still be watched. 1274 ;; still be watched.
@@ -1400,11 +1409,15 @@ the file watch."
1400 (cond 1409 (cond
1401 ;; w32notify does not raise `deleted' and `stopped' 1410 ;; w32notify does not raise `deleted' and `stopped'
1402 ;; events for the watched directory. 1411 ;; events for the watched directory.
1403 ((string-equal (file-notify--test-library) "w32notify") '()) 1412 ((string-equal (file-notify--test-library) "w32notify")
1413 '())
1404 ;; On emba, `deleted' and `stopped' events of the 1414 ;; On emba, `deleted' and `stopped' events of the
1405 ;; directory are not detected. 1415 ;; directory are not detected.
1406 ((getenv "EMACS_EMBA_CI") 1416 ((getenv "EMACS_EMBA_CI")
1407 '()) 1417 '())
1418 ;; Remote files send just one `stopped' event.
1419 ((file-remote-p temporary-file-directory)
1420 '(stopped))
1408 (t '(deleted stopped)))))) 1421 (t '(deleted stopped))))))
1409 (delete-directory file-notify--test-tmpfile 'recursive)) 1422 (delete-directory file-notify--test-tmpfile 'recursive))
1410 (unless (getenv "EMACS_EMBA_CI") 1423 (unless (getenv "EMACS_EMBA_CI")
diff --git a/test/lisp/files-tests.el b/test/lisp/files-tests.el
index ae8ea41a797..fe2e958f1c3 100644
--- a/test/lisp/files-tests.el
+++ b/test/lisp/files-tests.el
@@ -1244,5 +1244,20 @@ See <https://debbugs.gnu.org/35241>."
1244 (executable-find (file-name-nondirectory tmpfile)))))) 1244 (executable-find (file-name-nondirectory tmpfile))))))
1245 (delete-file tmpfile)))) 1245 (delete-file tmpfile))))
1246 1246
1247(ert-deftest files-tests-dont-rewrite-precious-files ()
1248 "Test that `file-precious-flag' forces files to be saved by
1249renaming only, rather than modified in-place."
1250 (let* ((temp-file-name (make-temp-file "files-tests"))
1251 (advice (lambda (_start _end filename &rest _r)
1252 (should-not (string= filename temp-file-name)))))
1253 (unwind-protect
1254 (with-current-buffer (find-file-noselect temp-file-name)
1255 (advice-add #'write-region :before advice)
1256 (setq-local file-precious-flag t)
1257 (insert "foobar")
1258 (should (null (save-buffer))))
1259 (ignore-errors (advice-remove #'write-region advice))
1260 (ignore-errors (delete-file temp-file-name)))))
1261
1247(provide 'files-tests) 1262(provide 'files-tests)
1248;;; files-tests.el ends here 1263;;; files-tests.el ends here
diff --git a/test/lisp/font-lock-tests.el b/test/lisp/font-lock-tests.el
new file mode 100644
index 00000000000..5d127039ff9
--- /dev/null
+++ b/test/lisp/font-lock-tests.el
@@ -0,0 +1,41 @@
1;;; font-lock-tests.el --- Test suite for font-lock. -*- lexical-binding: t -*-
2
3;; Copyright (C) 2019 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 <https://www.gnu.org/licenses/>.
19
20;;; Code:
21(require 'ert)
22
23(ert-deftest font-lock-test-append-anonymous-face ()
24 "Ensure `font-lock-append-text-property' does not splice anonymous faces."
25 (with-temp-buffer
26 (insert "foo")
27 (add-text-properties 1 3 '(face italic))
28 (font-lock-append-text-property 1 3 'face '(:strike-through t))
29 (should (equal (get-text-property 1 'face (current-buffer))
30 '(italic (:strike-through t))))))
31
32(ert-deftest font-lock-test-prepend-anonymous-face ()
33 "Ensure `font-lock-prepend-text-property' does not splice anonymous faces."
34 (with-temp-buffer
35 (insert "foo")
36 (add-text-properties 1 3 '(face italic))
37 (font-lock-prepend-text-property 1 3 'face '(:strike-through t))
38 (should (equal (get-text-property 1 'face (current-buffer))
39 '((:strike-through t) italic)))))
40
41;; font-lock-tests.el ends here
diff --git a/test/lisp/help-fns-tests.el b/test/lisp/help-fns-tests.el
index e31ac6a4d48..2e9483074e0 100644
--- a/test/lisp/help-fns-tests.el
+++ b/test/lisp/help-fns-tests.el
@@ -2,8 +2,6 @@
2 2
3;; Copyright (C) 2014-2019 Free Software Foundation, Inc. 3;; Copyright (C) 2014-2019 Free Software Foundation, Inc.
4 4
5;; Maintainer: emacs-devel@gnu.org
6
7;; This file is part of GNU Emacs. 5;; This file is part of GNU Emacs.
8 6
9;; GNU Emacs is free software: you can redistribute it and/or modify 7;; GNU Emacs is free software: you can redistribute it and/or modify
diff --git a/test/lisp/image-file-tests.el b/test/lisp/image-file-tests.el
new file mode 100644
index 00000000000..b3676d1f02c
--- /dev/null
+++ b/test/lisp/image-file-tests.el
@@ -0,0 +1,44 @@
1;;; image-file-tests.el --- Test suite for image-files -*- lexical-binding: t; -*-
2
3;; Copyright (C) 2019 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 <https://www.gnu.org/licenses/>.
19
20;;; Commentary:
21
22;;; Code:
23
24(require 'ert)
25(require 'image-file)
26
27(defconst image-file-tests-data-directory
28 (expand-file-name "data/image" (getenv "EMACS_TEST_DIRECTORY"))
29 "Directory containing image test data.")
30
31(ert-deftest insert-image-file ()
32 (skip-unless (image-type-available-p 'png))
33 (with-temp-buffer
34 (set-buffer-multibyte t)
35 (insert-image-file (expand-file-name "blank-100x200.png"
36 image-file-tests-data-directory))
37 (should (image--get-image)))
38 (with-temp-buffer
39 (set-buffer-multibyte nil)
40 (insert-image-file (expand-file-name "blank-100x200.png"
41 image-file-tests-data-directory))
42 (should (image--get-image))))
43
44;;; image-file-tests.el ends here
diff --git a/test/lisp/image-tests.el b/test/lisp/image-tests.el
index 89b926e629d..621646e5750 100644
--- a/test/lisp/image-tests.el
+++ b/test/lisp/image-tests.el
@@ -22,6 +22,10 @@
22(require 'ert) 22(require 'ert)
23(require 'image) 23(require 'image)
24 24
25(defconst image-tests--emacs-images-directory
26 (expand-file-name "../etc/images" (getenv "EMACS_TEST_DIRECTORY"))
27 "Directory containing Emacs images.")
28
25(ert-deftest image--set-property () 29(ert-deftest image--set-property ()
26 "Test `image--set-property' behavior." 30 "Test `image--set-property' behavior."
27 (let ((image (list 'image))) 31 (let ((image (list 'image)))
@@ -42,4 +46,11 @@
42 (setf (image-property image :width) nil) 46 (setf (image-property image :width) nil)
43 (should (equal image '(image))))) 47 (should (equal image '(image)))))
44 48
49(ert-deftest image-type-from-file-header-test ()
50 "Test image-type-from-file-header."
51 (should (eq 'svg
52 (image-type-from-file-header
53 (expand-file-name "splash.svg"
54 image-tests--emacs-images-directory)))))
55
45;;; image-tests.el ends here 56;;; image-tests.el ends here
diff --git a/test/lisp/mail/footnote-tests.el b/test/lisp/mail/footnote-tests.el
new file mode 100644
index 00000000000..464443f4039
--- /dev/null
+++ b/test/lisp/mail/footnote-tests.el
@@ -0,0 +1,47 @@
1;;; footnote-tests.el --- Tests for footnote-mode -*- lexical-binding: t; -*-
2
3;; Copyright (C) 2019 Free Software Foundation, Inc.
4
5;; Author: Stefan Monnier <monnier@iro.umontreal.ca>
6;; Keywords:
7
8;; This program is free software; you can redistribute it and/or modify
9;; it under the terms of the GNU General Public License as published by
10;; the Free Software Foundation, either version 3 of the License, or
11;; (at your option) any later version.
12
13;; This program is distributed in the hope that it will be useful,
14;; but WITHOUT ANY WARRANTY; without even the implied warranty of
15;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16;; GNU General Public License for more details.
17
18;; You should have received a copy of the GNU General Public License
19;; along with this program. If not, see <https://www.gnu.org/licenses/>.
20
21;;; Commentary:
22
23;;
24
25;;; Code:
26
27(ert-deftest footnote-tests-same-place ()
28 (with-temp-buffer
29 (footnote-mode 1)
30 (insert "hello world")
31 (beginning-of-line) (forward-word)
32 (footnote-add-footnote)
33 (insert "footnote")
34 (footnote-back-to-message)
35 (should (equal (buffer-substring (point-min) (point))
36 "hello[1]"))
37 (beginning-of-line) (forward-word)
38 (footnote-add-footnote)
39 (insert "other footnote")
40 (footnote-back-to-message)
41 (should (equal (buffer-substring (point-min) (point))
42 "hello[1]"))
43 (should (equal (buffer-substring (point-min) (line-end-position))
44 "hello[1][2] world"))))
45
46(provide 'footnote-tests)
47;;; footnote-tests.el ends here
diff --git a/test/lisp/md4-tests.el b/test/lisp/md4-tests.el
index 9712411419a..56b09c14de5 100644
--- a/test/lisp/md4-tests.el
+++ b/test/lisp/md4-tests.el
@@ -3,7 +3,6 @@
3;; Copyright (C) 2017-2019 Free Software Foundation, Inc. 3;; Copyright (C) 2017-2019 Free Software Foundation, Inc.
4 4
5;; Author: Mark Oteiza <mvoteiza@udel.edu> 5;; Author: Mark Oteiza <mvoteiza@udel.edu>
6;; Maintainer: emacs-devel@gnu.org
7 6
8;; This file is part of GNU Emacs. 7;; This file is part of GNU Emacs.
9 8
diff --git a/test/lisp/net/tramp-tests.el b/test/lisp/net/tramp-tests.el
index 4495a1fce42..5fc37c1934f 100644
--- a/test/lisp/net/tramp-tests.el
+++ b/test/lisp/net/tramp-tests.el
@@ -41,6 +41,7 @@
41 41
42;;; Code: 42;;; Code:
43 43
44(require 'cl-lib)
44(require 'dired) 45(require 'dired)
45(require 'ert) 46(require 'ert)
46(require 'ert-x) 47(require 'ert-x)
@@ -2270,6 +2271,37 @@ This checks also `file-name-as-directory', `file-name-directory',
2270 ;; Cleanup. 2271 ;; Cleanup.
2271 (ignore-errors (delete-file tmp-name)))))) 2272 (ignore-errors (delete-file tmp-name))))))
2272 2273
2274;; The following test is inspired by Bug#35497.
2275(ert-deftest tramp-test10-write-region-file-precious-flag ()
2276 "Check that `file-precious-flag' is respected with Tramp in use."
2277 (skip-unless (tramp--test-enabled))
2278 (skip-unless (tramp--test-sh-p))
2279 ;; The bug is fixed in Emacs 27.1.
2280 (skip-unless (tramp--test-emacs27-p))
2281
2282 (let* ((tmp-name (tramp--test-make-temp-name))
2283 written-files
2284 (advice (lambda (_start _end filename &rest _r)
2285 (push filename written-files))))
2286
2287 (unwind-protect
2288 (with-current-buffer (find-file-noselect tmp-name)
2289 ;; Write initial contents. Adapt `visited-file-modtime'
2290 ;; in order to suppress confirmation.
2291 (insert "foo")
2292 (write-region nil nil tmp-name)
2293 (set-visited-file-modtime)
2294 ;; Run the test.
2295 (advice-add 'write-region :before advice)
2296 (setq-local file-precious-flag t)
2297 (insert "bar")
2298 (should (null (save-buffer)))
2299 (should-not (cl-member tmp-name written-files :test #'string=)))
2300
2301 ;; Cleanup.
2302 (ignore-errors (advice-remove 'write-region advice))
2303 (ignore-errors (delete-file tmp-name)))))
2304
2273(ert-deftest tramp-test11-copy-file () 2305(ert-deftest tramp-test11-copy-file ()
2274 "Check `copy-file'." 2306 "Check `copy-file'."
2275 (skip-unless (tramp--test-enabled)) 2307 (skip-unless (tramp--test-enabled))
@@ -2762,7 +2794,9 @@ This tests also `file-directory-p' and `file-accessible-directory-p'."
2762 ;; returns `file-missing'. 2794 ;; returns `file-missing'.
2763 (delete-directory tmp-name1 'recursive) 2795 (delete-directory tmp-name1 'recursive)
2764 (with-temp-buffer 2796 (with-temp-buffer
2765 (should-error (insert-directory tmp-name1 nil)))) 2797 (should-error
2798 (insert-directory tmp-name1 nil)
2799 :type tramp-file-missing)))
2766 2800
2767 ;; Cleanup. 2801 ;; Cleanup.
2768 (ignore-errors (delete-directory tmp-name1 'recursive)))))) 2802 (ignore-errors (delete-directory tmp-name1 'recursive))))))
@@ -3846,6 +3880,10 @@ This tests also `make-symbolic-link', `file-truename' and `add-name-to-file'."
3846(defun tramp--test-timeout-handler (&rest _ignore) 3880(defun tramp--test-timeout-handler (&rest _ignore)
3847 "Timeout handler, reporting a failed test." 3881 "Timeout handler, reporting a failed test."
3848 (interactive) 3882 (interactive)
3883 (let ((proc (get-buffer-process (current-buffer))))
3884 (when (processp proc)
3885 (tramp--test-message
3886 "cmd: %s\n%s" (process-command proc) (buffer-string))))
3849 (ert-fail (format "`%s' timed out" (ert-test-name (ert-running-test))))) 3887 (ert-fail (format "`%s' timed out" (ert-test-name (ert-running-test)))))
3850 3888
3851(ert-deftest tramp-test29-start-file-process () 3889(ert-deftest tramp-test29-start-file-process ()
@@ -3926,7 +3964,8 @@ This tests also `make-symbolic-link', `file-truename' and `add-name-to-file'."
3926 :tags '(:expensive-test) 3964 :tags '(:expensive-test)
3927 (skip-unless (tramp--test-enabled)) 3965 (skip-unless (tramp--test-enabled))
3928 (skip-unless (or (tramp--test-adb-p) (tramp--test-sh-p))) 3966 (skip-unless (or (tramp--test-adb-p) (tramp--test-sh-p)))
3929 ;; `make-process' supports file name handlers since Emacs 27. 3967 ;; `make-process' has been inserted in Emacs 25.1. It supports file
3968 ;; name handlers since Emacs 27.
3930 (skip-unless (tramp--test-emacs27-p)) 3969 (skip-unless (tramp--test-emacs27-p))
3931 3970
3932 (tramp--test-instrument-test-case 0 3971 (tramp--test-instrument-test-case 0
@@ -3934,15 +3973,16 @@ This tests also `make-symbolic-link', `file-truename' and `add-name-to-file'."
3934 (let ((default-directory tramp-test-temporary-file-directory) 3973 (let ((default-directory tramp-test-temporary-file-directory)
3935 (tmp-name (tramp--test-make-temp-name nil quoted)) 3974 (tmp-name (tramp--test-make-temp-name nil quoted))
3936 kill-buffer-query-functions proc) 3975 kill-buffer-query-functions proc)
3937 (should-not (make-process)) 3976 (should-not (with-no-warnings (make-process)))
3938 3977
3939 ;; Simple process. 3978 ;; Simple process.
3940 (unwind-protect 3979 (unwind-protect
3941 (with-temp-buffer 3980 (with-temp-buffer
3942 (setq proc 3981 (setq proc
3943 (make-process 3982 (with-no-warnings
3944 :name "test1" :buffer (current-buffer) :command '("cat") 3983 (make-process
3945 :file-handler t)) 3984 :name "test1" :buffer (current-buffer) :command '("cat")
3985 :file-handler t)))
3946 (should (processp proc)) 3986 (should (processp proc))
3947 (should (equal (process-status proc) 'run)) 3987 (should (equal (process-status proc) 'run))
3948 (process-send-string proc "foo") 3988 (process-send-string proc "foo")
@@ -3964,10 +4004,11 @@ This tests also `make-symbolic-link', `file-truename' and `add-name-to-file'."
3964 (write-region "foo" nil tmp-name) 4004 (write-region "foo" nil tmp-name)
3965 (should (file-exists-p tmp-name)) 4005 (should (file-exists-p tmp-name))
3966 (setq proc 4006 (setq proc
3967 (make-process 4007 (with-no-warnings
3968 :name "test2" :buffer (current-buffer) 4008 (make-process
3969 :command `("cat" ,(file-name-nondirectory tmp-name)) 4009 :name "test2" :buffer (current-buffer)
3970 :file-handler t)) 4010 :command `("cat" ,(file-name-nondirectory tmp-name))
4011 :file-handler t)))
3971 (should (processp proc)) 4012 (should (processp proc))
3972 ;; Read output. 4013 ;; Read output.
3973 (with-timeout (10 (tramp--test-timeout-handler)) 4014 (with-timeout (10 (tramp--test-timeout-handler))
@@ -3984,12 +4025,13 @@ This tests also `make-symbolic-link', `file-truename' and `add-name-to-file'."
3984 (unwind-protect 4025 (unwind-protect
3985 (with-temp-buffer 4026 (with-temp-buffer
3986 (setq proc 4027 (setq proc
3987 (make-process 4028 (with-no-warnings
3988 :name "test3" :buffer (current-buffer) :command '("cat") 4029 (make-process
3989 :filter 4030 :name "test3" :buffer (current-buffer) :command '("cat")
3990 (lambda (p s) 4031 :filter
3991 (with-current-buffer (process-buffer p) (insert s))) 4032 (lambda (p s)
3992 :file-handler t)) 4033 (with-current-buffer (process-buffer p) (insert s)))
4034 :file-handler t)))
3993 (should (processp proc)) 4035 (should (processp proc))
3994 (should (equal (process-status proc) 'run)) 4036 (should (equal (process-status proc) 'run))
3995 (process-send-string proc "foo") 4037 (process-send-string proc "foo")
@@ -4009,12 +4051,13 @@ This tests also `make-symbolic-link', `file-truename' and `add-name-to-file'."
4009 (unwind-protect 4051 (unwind-protect
4010 (with-temp-buffer 4052 (with-temp-buffer
4011 (setq proc 4053 (setq proc
4012 (make-process 4054 (with-no-warnings
4013 :name "test4" :buffer (current-buffer) :command '("cat") 4055 (make-process
4014 :sentinel 4056 :name "test4" :buffer (current-buffer) :command '("cat")
4015 (lambda (p s) 4057 :sentinel
4016 (with-current-buffer (process-buffer p) (insert s))) 4058 (lambda (p s)
4017 :file-handler t)) 4059 (with-current-buffer (process-buffer p) (insert s)))
4060 :file-handler t)))
4018 (should (processp proc)) 4061 (should (processp proc))
4019 (should (equal (process-status proc) 'run)) 4062 (should (equal (process-status proc) 'run))
4020 (process-send-string proc "foo") 4063 (process-send-string proc "foo")
@@ -4037,11 +4080,12 @@ This tests also `make-symbolic-link', `file-truename' and `add-name-to-file'."
4037 (unwind-protect 4080 (unwind-protect
4038 (with-temp-buffer 4081 (with-temp-buffer
4039 (setq proc 4082 (setq proc
4040 (make-process 4083 (with-no-warnings
4041 :name "test5" :buffer (current-buffer) 4084 (make-process
4042 :command '("cat" "/") 4085 :name "test5" :buffer (current-buffer)
4043 :stderr stderr 4086 :command '("cat" "/")
4044 :file-handler t)) 4087 :stderr stderr
4088 :file-handler t)))
4045 (should (processp proc)) 4089 (should (processp proc))
4046 ;; Read stderr. 4090 ;; Read stderr.
4047 (with-current-buffer stderr 4091 (with-current-buffer stderr
@@ -4188,18 +4232,17 @@ This tests also `make-symbolic-link', `file-truename' and `add-name-to-file'."
4188 ;; Cleanup. 4232 ;; Cleanup.
4189 (ignore-errors (delete-file tmp-name))) 4233 (ignore-errors (delete-file tmp-name)))
4190 4234
4191 ;; Test `shell-command-width' of `async-shell-command'. 4235 ;; Test `async-shell-command-width'. Since Emacs 27.1.
4192 ;; Since Emacs 27.1. 4236 (when (and (boundp 'async-shell-command-width)
4193 (when (and (boundp 'shell-command-width)
4194 (zerop (call-process "tput" nil nil nil "cols")) 4237 (zerop (call-process "tput" nil nil nil "cols"))
4195 (zerop (process-file "tput" nil nil nil "cols"))) 4238 (zerop (process-file "tput" nil nil nil "cols")))
4196 (let (shell-command-width) 4239 (let (async-shell-command-width)
4197 (should 4240 (should
4198 (string-equal 4241 (string-equal
4199 (format "%s\n" (car (process-lines "tput" "cols"))) 4242 (format "%s\n" (car (process-lines "tput" "cols")))
4200 (tramp--test-shell-command-to-string-asynchronously 4243 (tramp--test-shell-command-to-string-asynchronously
4201 "tput cols"))) 4244 "tput cols")))
4202 (setq shell-command-width 1024) 4245 (setq async-shell-command-width 1024)
4203 (should 4246 (should
4204 (string-equal 4247 (string-equal
4205 "1024\n" 4248 "1024\n"
@@ -5720,7 +5763,7 @@ Since it unloads Tramp, it shall be the last test to run."
5720 (ert-fail (format "`%s' still bound" x))))) 5763 (ert-fail (format "`%s' still bound" x)))))
5721 ;; The defstruct `tramp-file-name' and all its internal functions 5764 ;; The defstruct `tramp-file-name' and all its internal functions
5722 ;; shall be purged. 5765 ;; shall be purged.
5723 (should-not (cl--find-class 'tramp-file-name)) 5766 (should-not (with-no-warnings (cl--find-class 'tramp-file-name)))
5724 (mapatoms 5767 (mapatoms
5725 (lambda (x) 5768 (lambda (x)
5726 (and (functionp x) 5769 (and (functionp x)
diff --git a/test/lisp/nxml/nxml-mode-tests.el b/test/lisp/nxml/nxml-mode-tests.el
new file mode 100644
index 00000000000..92744be619d
--- /dev/null
+++ b/test/lisp/nxml/nxml-mode-tests.el
@@ -0,0 +1,82 @@
1;;; nxml-mode-tests.el --- Test NXML Mode -*- lexical-binding: t; -*-
2
3;; Copyright (C) 2019 Free Software Foundation, Inc.
4
5;; GNU Emacs is free software: you can redistribute it and/or modify
6;; it under the terms of the GNU General Public License as published by
7;; the Free Software Foundation, either version 3 of the License, or
8;; (at your option) any later version.
9
10;; GNU Emacs is distributed in the hope that it will be useful,
11;; but WITHOUT ANY WARRANTY; without even the implied warranty of
12;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13;; GNU General Public License for more details.
14
15;; You should have received a copy of the GNU General Public License
16;; along with GNU Emacs. If not, see <https://www.gnu.org/licenses/>.
17
18;;; Code:
19
20(require 'ert)
21(require 'nxml-mode)
22
23(defun nxml-mode-tests-correctly-indented-string (str)
24 (with-temp-buffer
25 (nxml-mode)
26 (insert str)
27 (indent-region (point-min) (point-max))
28 (equal (buffer-string) str)))
29
30(ert-deftest nxml-indent-line-after-attribute ()
31 (should (nxml-mode-tests-correctly-indented-string "
32<settings
33 xmlns=\"http://maven.apache.org/SETTINGS/1.0.0\"
34 xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"
35 xsi:schemaLocation=\"http://maven.apache.org/SETTINGS/1.0.0
36 https://maven.apache.org/xsd/settings-1.0.0.xsd\">
37 <mirrors>
38 ...
39 </mirrors>
40</settings>
41"))
42 (should (nxml-mode-tests-correctly-indented-string "\
43<x>
44 <abc xx=\"x/x/x/x/x/x/x/
45 y/y/y/y/y/y/
46 \">
47 <zzz/>
48 </abc>
49 <nl>&#10;</nl>
50</x>
51")))
52
53(ert-deftest nxml-balanced-close-start-tag-inline ()
54 (with-temp-buffer
55 (nxml-mode)
56 (insert "<a><b c=\"\"</a>")
57 (search-backward "</a>")
58 (nxml-balanced-close-start-tag-inline)
59 (should (equal (buffer-string) "<a><b c=\"\"></b></a>"))))
60
61(ert-deftest nxml-mode-font-lock-quotes ()
62 (with-temp-buffer
63 (nxml-mode)
64 (insert "<x a=\"dquote attr\" b='squote attr'>\"dquote text\"'squote text'</x>")
65 (font-lock-ensure)
66 (let ((squote-txt-pos (search-backward "squote text"))
67 (dquote-txt-pos (search-backward "dquote text"))
68 (squote-att-pos (search-backward "squote attr"))
69 (dquote-att-pos (search-backward "dquote attr")))
70 ;; Just make sure that each quote uses the same face for quoted
71 ;; attribute values, and a different face for quoted text
72 ;; outside tags. Don't test `font-lock-string-face' vs
73 ;; `nxml-attribute-value' here.
74 (should (equal (get-text-property squote-att-pos 'face)
75 (get-text-property dquote-att-pos 'face)))
76 (should (equal (get-text-property squote-txt-pos 'face)
77 (get-text-property dquote-txt-pos 'face)))
78 (should-not (equal (get-text-property squote-txt-pos 'face)
79 (get-text-property dquote-att-pos 'face))))))
80
81(provide 'nxml-mode-tests)
82;;; nxml-mode-tests.el ends here
diff --git a/test/lisp/org/org-tests.el b/test/lisp/org/org-tests.el
index 4b82aa8382f..33f9e459464 100644
--- a/test/lisp/org/org-tests.el
+++ b/test/lisp/org/org-tests.el
@@ -2,8 +2,6 @@
2 2
3;; Copyright (C) 2018-2019 Free Software Foundation, Inc. 3;; Copyright (C) 2018-2019 Free Software Foundation, Inc.
4 4
5;; Maintainer: emacs-devel@gnu.org
6
7;; This file is part of GNU Emacs. 5;; This file is part of GNU Emacs.
8 6
9;; GNU Emacs is free software: you can redistribute it and/or modify 7;; GNU Emacs is free software: you can redistribute it and/or modify
diff --git a/test/lisp/progmodes/python-tests.el b/test/lisp/progmodes/python-tests.el
index b940f45bb90..a5179097172 100644
--- a/test/lisp/progmodes/python-tests.el
+++ b/test/lisp/progmodes/python-tests.el
@@ -260,6 +260,19 @@ foo = long_function_name(
260 (should (eq (car (python-indent-context)) :inside-paren-newline-start)) 260 (should (eq (car (python-indent-context)) :inside-paren-newline-start))
261 (should (= (python-indent-calculate-indentation) 4)))) 261 (should (= (python-indent-calculate-indentation) 4))))
262 262
263(ert-deftest python-indent-hanging-close-paren ()
264 "Like first pep8 case, but with hanging close paren." ;; See Bug#20742.
265 (python-tests-with-temp-buffer
266 "\
267foo = long_function_name(var_one, var_two,
268 var_three, var_four
269 )
270"
271 (should (= (python-indent-calculate-indentation) 0))
272 (python-tests-look-at ")")
273 (should (eq (car (python-indent-context)) :inside-paren-at-closing-paren))
274 (should (= (python-indent-calculate-indentation) 25))))
275
263(ert-deftest python-indent-base-case () 276(ert-deftest python-indent-base-case ()
264 "Check base case does not trigger errors." 277 "Check base case does not trigger errors."
265 (python-tests-with-temp-buffer 278 (python-tests-with-temp-buffer
diff --git a/test/lisp/soundex-tests.el b/test/lisp/soundex-tests.el
index d8d79b85cea..4de45f9d53a 100644
--- a/test/lisp/soundex-tests.el
+++ b/test/lisp/soundex-tests.el
@@ -2,8 +2,6 @@
2 2
3;; Copyright (C) 2017-2019 Free Software Foundation, Inc. 3;; Copyright (C) 2017-2019 Free Software Foundation, Inc.
4 4
5;; Maintainer: emacs-devel@gnu.org
6
7;; This file is part of GNU Emacs. 5;; This file is part of GNU Emacs.
8 6
9;; GNU Emacs is free software: you can redistribute it and/or modify 7;; GNU Emacs is free software: you can redistribute it and/or modify
diff --git a/test/lisp/tempo-tests.el b/test/lisp/tempo-tests.el
new file mode 100644
index 00000000000..6e610ffa6ea
--- /dev/null
+++ b/test/lisp/tempo-tests.el
@@ -0,0 +1,228 @@
1;;; tempo-tests.el --- Test suite for tempo.el -*- lexical-binding: t; -*-
2
3;; Copyright (C) 2019 Free Software Foundation, Inc.
4
5;; Author: Federico Tedin <federicotedin@gmail.com>
6;; Keywords: abbrev
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 <https://www.gnu.org/licenses/>.
22
23;;; Code:
24
25(require 'tempo)
26(eval-when-compile (require 'cl-lib))
27
28(ert-deftest tempo-string-element-test ()
29 "Test a template containing a string element."
30 (with-temp-buffer
31 (tempo-define-template "test" '("GNU Emacs Tempo test"))
32 (tempo-insert-template 'tempo-template-test nil)
33 (should (equal (buffer-string) "GNU Emacs Tempo test"))))
34
35(ert-deftest tempo-p-bare-element-test ()
36 "Test a template containing a bare `p' element."
37 (with-temp-buffer
38 (tempo-define-template "test" '("abcde" p))
39 (tempo-insert-template 'tempo-template-test nil)
40 (tempo-forward-mark)
41 (should (equal (point) 6))))
42
43(ert-deftest tempo-r-bare-element-test ()
44 "Test a template containing a bare `r' element."
45 (with-temp-buffer
46 (tempo-define-template "test" '("abcde" r "ghijk"))
47 (insert "F")
48 (set-mark (point))
49 (goto-char (point-min))
50 (tempo-insert-template 'tempo-template-test t)
51 (should (equal (buffer-string) "abcdeFghijk"))))
52
53(ert-deftest tempo-p-element-test ()
54 "Testing template containing a `p' (prompt) element."
55 (with-temp-buffer
56 (tempo-define-template "test" '("hello " (p ">")))
57 (let ((tempo-interactive t))
58 (cl-letf (((symbol-function 'read-string) (lambda (&rest _) "world")))
59 (tempo-insert-template 'tempo-template-test nil))
60 (should (equal (buffer-string) "hello world")))))
61
62(ert-deftest tempo-P-element-test ()
63 "Testing template containing a `P' (prompt) element."
64 (with-temp-buffer
65 (tempo-define-template "test" '("hello " (P ">")))
66 ;; By default, `tempo-interactive' is nil, `P' should ignore this.
67 (cl-letf (((symbol-function 'read-string) (lambda (&rest _) "world")))
68 (tempo-insert-template 'tempo-template-test nil))
69 (should (equal (buffer-string) "hello world"))))
70
71(ert-deftest tempo-r-element-test ()
72 "Testing template containing an `r' (with prompt) element."
73 (with-temp-buffer
74 (tempo-define-template "test" '("abcde" (r ">") "ghijk"))
75 (let ((tempo-interactive t))
76 (cl-letf (((symbol-function 'read-string) (lambda (&rest _) "F")))
77 (tempo-insert-template 'tempo-template-test nil))
78 (should (equal (buffer-string) "abcdeFghijk")))))
79
80(ert-deftest tempo-s-element-test ()
81 "Testing template containing an `s' element."
82 (with-temp-buffer
83 (tempo-define-template "test" '("hello " (p ">" P1) " " (s P1)))
84 (let ((tempo-interactive t))
85 (cl-letf (((symbol-function 'read-string) (lambda (&rest _) "world!")))
86 (tempo-insert-template 'tempo-template-test nil))
87 (should (equal (buffer-string) "hello world! world!")))))
88
89(ert-deftest tempo-&-element-test ()
90 "Testing template containing an `&' element."
91 (tempo-define-template "test" '(& "test"))
92 (with-temp-buffer
93 (insert " ")
94 (tempo-insert-template 'tempo-template-test nil)
95 (should (equal (buffer-string) " test")))
96 (with-temp-buffer
97 (insert "hello")
98 (tempo-insert-template 'tempo-template-test nil)
99 (should (equal (buffer-string) "hello\ntest"))))
100
101(ert-deftest tempo-%-element-test ()
102 "Testing template containing an `%' element."
103 (tempo-define-template "test" '("test" %))
104 (with-temp-buffer
105 (tempo-insert-template 'tempo-template-test nil)
106 (should (equal (buffer-string) "test")))
107 (with-temp-buffer
108 (insert "hello")
109 (goto-char (point-min))
110 (tempo-insert-template 'tempo-template-test nil)
111 (should (equal (buffer-string) "test\nhello"))))
112
113(ert-deftest tempo-n-element-test ()
114 "Testing template containing an `n' element."
115 (tempo-define-template "test" '("test" n "test"))
116 (with-temp-buffer
117 (tempo-insert-template 'tempo-template-test nil)
118 (should (equal (buffer-string) "test\ntest"))))
119
120(ert-deftest tempo-n>-element-test ()
121 "Testing template containing an `n>' element."
122 (tempo-define-template "test" '("(progn" n> "(list 1 2 3))"))
123 (with-temp-buffer
124 (emacs-lisp-mode)
125 (tempo-insert-template 'tempo-template-test nil)
126 ;; Tempo should have inserted two spaces before (list 1 2 3)
127 (should (equal (buffer-string) "(progn\n (list 1 2 3))"))))
128
129(ert-deftest tempo->-element-test ()
130 "Testing template containing a `>' element."
131 (with-temp-buffer
132 (emacs-lisp-mode)
133 (insert "(progn\n)")
134 (backward-char)
135 (tempo-define-template "test" '("(list 1 2 3)" >))
136 (tempo-insert-template 'tempo-template-test nil)
137 ;; Tempo should have inserted two spaces before (list 1 2 3)
138 (should (equal (buffer-string) "(progn\n (list 1 2 3))"))))
139
140(ert-deftest tempo-r>-bare-element-test ()
141 "Testing template containing a bare `r>' element."
142 (with-temp-buffer
143 (tempo-define-template "test" '("(progn" n r> ")"))
144 (emacs-lisp-mode)
145 (insert "(list 1 2 3)")
146 (set-mark (point))
147 (goto-char (point-min))
148 (tempo-insert-template 'tempo-template-test t)
149 ;; Tempo should have inserted two spaces before (list 1 2 3)
150 (should (equal (buffer-string) "(progn\n (list 1 2 3))"))))
151
152(ert-deftest tempo-r>-element-test ()
153 "Testing template containing an `r>' (with prompt) element."
154 (tempo-define-template "test" '("(progn" n (r> ":") ")"))
155 (with-temp-buffer
156 ;; Test on-region use
157 (emacs-lisp-mode)
158 (insert "(list 1 2 3)")
159 (set-mark (point))
160 (goto-char (point-min))
161 (tempo-insert-template 'tempo-template-test t)
162 (should (equal (buffer-string) "(progn\n (list 1 2 3))")))
163 (with-temp-buffer
164 ;; Test interactive use
165 (emacs-lisp-mode)
166 (let ((tempo-interactive t))
167 (cl-letf (((symbol-function 'read-string) (lambda (&rest _) " (list 1 2 3)")))
168 (tempo-insert-template 'tempo-template-test nil))
169 (should (equal (buffer-string) "(progn\n (list 1 2 3))")))))
170
171(ert-deftest tempo-o-element-test ()
172 "Testing template containing an `o' element."
173 (with-temp-buffer
174 (tempo-define-template "test" '("test" o))
175 (insert "hello")
176 (goto-char (point-min))
177 (tempo-insert-template 'tempo-template-test nil)
178 (should (equal (buffer-string) "test\nhello"))
179 (should (equal (point) 5))))
180
181(ert-deftest tempo-nil-element-test ()
182 "Testing template with nil elements."
183 (with-temp-buffer
184 (tempo-define-template "test" '("Hello," nil " World!"))
185 (tempo-insert-template 'tempo-template-test nil)
186 (should (equal (buffer-string) "Hello, World!"))))
187
188(ert-deftest tempo-eval-element-test ()
189 "Testing template with Emacs Lisp expressions."
190 (with-temp-buffer
191 (tempo-define-template "test" '((int-to-string (+ 1 1)) "=" (concat "1" "+1")))
192 (tempo-insert-template 'tempo-template-test nil)
193 (should (equal (buffer-string) "2=1+1"))))
194
195(ert-deftest tempo-l-element-test ()
196 "Testing template containing an `l' element."
197 (with-temp-buffer
198 (tempo-define-template "test" '("list: " (l "1, " "2, " (int-to-string (+ 1 2)))))
199 (tempo-insert-template 'tempo-template-test nil)
200 (should (equal (buffer-string) "list: 1, 2, 3"))))
201
202(ert-deftest tempo-tempo-user-elements-test ()
203 "Testing a template with elements for `tempo-user-elements'."
204 (with-temp-buffer
205 (make-local-variable 'tempo-user-elements)
206 (add-to-list 'tempo-user-elements (lambda (x) (int-to-string (* x x))))
207 (tempo-define-template "test" '(1 " " 2 " " 3 " " 4))
208 (tempo-insert-template 'tempo-template-test nil)
209 (should (equal (buffer-string) "1 4 9 16"))))
210
211(ert-deftest tempo-expand-tag-test ()
212 "Testing expansion of a template with a tag."
213 (with-temp-buffer
214 (tempo-define-template "test" '("Hello, World!") "hello")
215 (insert "hello")
216 (tempo-complete-tag)
217 (should (equal (buffer-string) "Hello, World!"))))
218
219(ert-deftest tempo-expand-partial-tag-test ()
220 "Testing expansion of a template with a tag, with a partial match."
221 (with-temp-buffer
222 (tempo-define-template "test" '("Hello, World!") "hello")
223 (insert "hel")
224 (tempo-complete-tag)
225 (should (equal (buffer-string) "Hello, World!"))))
226
227(provide 'tempo-tests)
228;;; tempo-tests.el ends here
diff --git a/test/lisp/term-tests.el b/test/lisp/term-tests.el
index 9f5dcd559eb..6923096d224 100644
--- a/test/lisp/term-tests.el
+++ b/test/lisp/term-tests.el
@@ -119,7 +119,141 @@ line3\r
119line4\r 119line4\r
120line5\r 120line5\r
121line6\r 121line6\r
122")))) 122")))
123
124 ;; test reverse scrolling
125 (should (equal "line1
126line7
127line6
128line2
129line5"
130 (term-test-screen-from-input 40 5
131 '("\e[0;0H"
132 "\e[J"
133 "line1\r
134line2\r
135line3\r
136line4\r
137line5"
138 "\e[2;4r"
139 "\e[2;0H"
140 "\e[2;0H"
141 "\eMline6"
142 "\e[2;0H"
143 "\eMline7"))))
144
145 ;; test scrolling down
146 (should (equal "line1
147line3
148line4
149line7
150line5"
151 (term-test-screen-from-input 40 5
152 '("\e[0;0H"
153 "\e[J"
154 "line1\r
155line2\r
156line3\r
157line4\r
158line5"
159 "\e[2;4r"
160 "\e[2;0H"
161 "\e[4;5H"
162 "\n\rline7"))))
163
164 ;; setting the scroll region end beyond the max height should not
165 ;; turn on term-scroll-with-delete
166 (should (equal "line1
167line2
168line3
169line4
170line5
171line6
172line7"
173 (term-test-screen-from-input 40 5
174 '("\e[1;10r"
175 "line1\r
176line2\r
177line3\r
178line4\r
179line5\r
180line6\r
181line7"))))
182
183
184 ;; resetting the terminal should set the scroll region end to (1- term-height).
185 (should (equal "
186line1
187line2
188line3
189line4
190"
191 (term-test-screen-from-input 40 5
192 '("\e[1;10r"
193 "\ec" ;reset
194 "line1\r
195line2\r
196line3\r
197line4\r
198line5"
199 "\e[1;1H"
200 "\e[L"))))
201
202 ;; scroll region should be limited to the (1- term-height). Note,
203 ;; this fixes an off by one error when comparing the scroll region
204 ;; end with term-height.
205 (should (equal "
206line1
207line2
208line3
209line4
210"
211 (term-test-screen-from-input 40 5
212 '("\e[1;6r"
213 "line1\r
214line2\r
215line3\r
216line4\r
217line5"
218 "\e[1;1H" ;go back to home
219 "\e[L" ;insert a new line at the top
220 ))))
221
222 ;; setting the scroll region to the entire height should not turn on
223 ;; term-scroll-with-delete
224 (should (equal "line1
225line2
226line3
227line4
228line5
229line6"
230 (term-test-screen-from-input 40 5
231 '("\e[1;5r"
232 "line1\r
233line2\r
234line3\r
235line4\r
236line5\r
237line6"))))
238
239 ;; reset should reset term-scroll-with-delete
240 (should (equal "line1
241line2
242line3
243line4
244line5
245line6
246line7"
247 (term-test-screen-from-input 40 5
248 '("\e[2;5r" ;set the region
249 "\ec" ;reset
250 "line1\r
251line2\r
252line3\r
253line4\r
254line5\r
255line6\r
256line7")))))
123 257
124(ert-deftest term-set-directory () 258(ert-deftest term-set-directory ()
125 (let ((term-ansi-at-user (user-real-login-name))) 259 (let ((term-ansi-at-user (user-real-login-name)))
diff --git a/test/lisp/textmodes/sgml-mode-tests.el b/test/lisp/textmodes/sgml-mode-tests.el
index 61ae87e36db..1b8965e3440 100644
--- a/test/lisp/textmodes/sgml-mode-tests.el
+++ b/test/lisp/textmodes/sgml-mode-tests.el
@@ -125,7 +125,6 @@ The point is set to the beginning of the buffer."
125 (should (string= content (buffer-string)))))) 125 (should (string= content (buffer-string))))))
126 126
127(ert-deftest sgml-delete-tag-bug-8203-should-not-delete-apostrophe () 127(ert-deftest sgml-delete-tag-bug-8203-should-not-delete-apostrophe ()
128 :expected-result :failed
129 (sgml-with-content 128 (sgml-with-content
130 "<title>Winter is comin'</title>" 129 "<title>Winter is comin'</title>"
131 (sgml-delete-tag 1) 130 (sgml-delete-tag 1)
@@ -161,5 +160,16 @@ The point is set to the beginning of the buffer."
161 (sgml-quote (point-min) (point-max) t) 160 (sgml-quote (point-min) (point-max) t)
162 (should (string= "&&" (buffer-string)))))) 161 (should (string= "&&" (buffer-string))))))
163 162
163(ert-deftest sgml-tests--quotes-syntax ()
164 (with-temp-buffer
165 (sgml-mode)
166 (insert "a\"b <tag>c'd</tag>")
167 (should (= 1 (car (syntax-ppss (1- (point-max))))))
168 (should (= 0 (car (syntax-ppss (point-max)))))
169 (erase-buffer)
170 (insert "<tag>c>d</tag>")
171 (should (= 1 (car (syntax-ppss (1- (point-max))))))
172 (should (= 0 (car (syntax-ppss (point-max)))))))
173
164(provide 'sgml-mode-tests) 174(provide 'sgml-mode-tests)
165;;; sgml-mode-tests.el ends here 175;;; sgml-mode-tests.el ends here
diff --git a/test/lisp/vc/diff-mode-tests.el b/test/lisp/vc/diff-mode-tests.el
index 676d461076b..d809b64634f 100644
--- a/test/lisp/vc/diff-mode-tests.el
+++ b/test/lisp/vc/diff-mode-tests.el
@@ -1,7 +1,6 @@
1;; Copyright (C) 2017-2019 Free Software Foundation, Inc. 1;; Copyright (C) 2017-2019 Free Software Foundation, Inc.
2 2
3;; Author: Dima Kogan <dima@secretsauce.net> 3;; Author: Dima Kogan <dima@secretsauce.net>
4;; Maintainer: emacs-devel@gnu.org
5 4
6;; This file is part of GNU Emacs. 5;; This file is part of GNU Emacs.
7 6
diff --git a/test/lisp/vc/smerge-mode-tests.el b/test/lisp/vc/smerge-mode-tests.el
index 032afa9dc24..67f64689220 100644
--- a/test/lisp/vc/smerge-mode-tests.el
+++ b/test/lisp/vc/smerge-mode-tests.el
@@ -1,7 +1,5 @@
1;; Copyright (C) 2017-2019 Free Software Foundation, Inc. 1;; Copyright (C) 2017-2019 Free Software Foundation, Inc.
2 2
3;; Maintainer: emacs-devel@gnu.org
4
5;; This file is part of GNU Emacs. 3;; This file is part of GNU Emacs.
6 4
7;; GNU Emacs is free software: you can redistribute it and/or modify 5;; GNU Emacs is free software: you can redistribute it and/or modify
diff --git a/test/lisp/vc/vc-bzr-tests.el b/test/lisp/vc/vc-bzr-tests.el
index 8fa16cdccb1..04c869ed935 100644
--- a/test/lisp/vc/vc-bzr-tests.el
+++ b/test/lisp/vc/vc-bzr-tests.el
@@ -3,7 +3,6 @@
3;; Copyright (C) 2011-2019 Free Software Foundation, Inc. 3;; Copyright (C) 2011-2019 Free Software Foundation, Inc.
4 4
5;; Author: Glenn Morris <rgm@gnu.org> 5;; Author: Glenn Morris <rgm@gnu.org>
6;; Maintainer: emacs-devel@gnu.org
7 6
8;; This file is part of GNU Emacs. 7;; This file is part of GNU Emacs.
9 8
diff --git a/test/lisp/vc/vc-hg-tests.el b/test/lisp/vc/vc-hg-tests.el
index 1bdc3204c03..7fc84610a01 100644
--- a/test/lisp/vc/vc-hg-tests.el
+++ b/test/lisp/vc/vc-hg-tests.el
@@ -3,7 +3,6 @@
3;; Copyright (C) 2016-2019 Free Software Foundation, Inc. 3;; Copyright (C) 2016-2019 Free Software Foundation, Inc.
4 4
5;; Author: Dmitry Gutov <dgutov@yandex.ru> 5;; Author: Dmitry Gutov <dgutov@yandex.ru>
6;; Maintainer: emacs-devel@gnu.org
7 6
8;; This file is part of GNU Emacs. 7;; This file is part of GNU Emacs.
9 8
diff --git a/test/lisp/xdg-tests.el b/test/lisp/xdg-tests.el
index 9c815065b2a..b8bd606ec11 100644
--- a/test/lisp/xdg-tests.el
+++ b/test/lisp/xdg-tests.el
@@ -2,7 +2,6 @@
2 2
3;; Copyright (C) 2017-2019 Free Software Foundation, Inc. 3;; Copyright (C) 2017-2019 Free Software Foundation, Inc.
4 4
5;; Maintainer: emacs-devel@gnu.org
6;; Author: Mark Oteiza <mvoteiza@udel.edu> 5;; Author: Mark Oteiza <mvoteiza@udel.edu>
7 6
8;; This file is part of GNU Emacs. 7;; This file is part of GNU Emacs.
diff --git a/test/manual/biditest.el b/test/manual/biditest.el
index d813642f780..f257910877b 100644
--- a/test/manual/biditest.el
+++ b/test/manual/biditest.el
@@ -3,7 +3,6 @@
3;; Copyright (C) 2013-2019 Free Software Foundation, Inc. 3;; Copyright (C) 2013-2019 Free Software Foundation, Inc.
4 4
5;; Author: Eli Zaretskii 5;; Author: Eli Zaretskii
6;; Maintainer: emacs-devel@gnu.org
7;; Package: emacs 6;; Package: emacs
8 7
9;; This program is free software: you can redistribute it and/or modify 8;; This program is free software: you can redistribute it and/or modify
diff --git a/test/manual/etags/el-src/emacs/lisp/progmodes/etags.el b/test/manual/etags/el-src/emacs/lisp/progmodes/etags.el
index 250aeb1cf26..30ad34099b7 100644
--- a/test/manual/etags/el-src/emacs/lisp/progmodes/etags.el
+++ b/test/manual/etags/el-src/emacs/lisp/progmodes/etags.el
@@ -4,7 +4,6 @@
4;; Software Foundation, Inc. 4;; Software Foundation, Inc.
5 5
6;; Author: Roland McGrath <roland@gnu.org> 6;; Author: Roland McGrath <roland@gnu.org>
7;; Maintainer: emacs-devel@gnu.org
8;; Keywords: tools 7;; Keywords: tools
9 8
10;; This file is part of GNU Emacs. 9;; This file is part of GNU Emacs.
diff --git a/test/src/emacs-module-tests.el b/test/src/emacs-module-tests.el
index 173b63670fc..5349de055ed 100644
--- a/test/src/emacs-module-tests.el
+++ b/test/src/emacs-module-tests.el
@@ -1,4 +1,4 @@
1;;; Test GNU Emacs modules. 1;;; emacs-module-tests --- Test GNU Emacs modules. -*- lexical-binding: t; -*-
2 2
3;; Copyright 2015-2019 Free Software Foundation, Inc. 3;; Copyright 2015-2019 Free Software Foundation, Inc.
4 4
@@ -17,6 +17,14 @@
17;; You should have received a copy of the GNU General Public License 17;; You should have received a copy of the GNU General Public License
18;; along with GNU Emacs. If not, see <https://www.gnu.org/licenses/>. */ 18;; along with GNU Emacs. If not, see <https://www.gnu.org/licenses/>. */
19 19
20;;; Commentary:
21
22;; Unit tests for the dynamic module facility. See Info node `(elisp)
23;; Writing Dynamic Modules'. These tests make use of a small test
24;; module in test/data/emacs-module.
25
26;;; Code:
27
20(require 'cl-lib) 28(require 'cl-lib)
21(require 'ert) 29(require 'ert)
22(require 'help-fns) 30(require 'help-fns)
@@ -137,8 +145,9 @@ changes."
137;; 145;;
138 146
139(defun multiply-string (s n) 147(defun multiply-string (s n)
148 "Return N copies of S concatenated together."
140 (let ((res "")) 149 (let ((res ""))
141 (dotimes (i n) 150 (dotimes (_ n)
142 (setq res (concat res s))) 151 (setq res (concat res s)))
143 res)) 152 res))
144 153
@@ -304,7 +313,7 @@ Interactively, you can try hitting \\[keyboard-quit] to quit."
304 ;; Interactively, run for 5 seconds to give the 313 ;; Interactively, run for 5 seconds to give the
305 ;; user time to quit. In batch mode, run only 314 ;; user time to quit. In batch mode, run only
306 ;; briefly since the user can't quit. 315 ;; briefly since the user can't quit.
307 (float-time (time-add nil (if noninteractive 0.1 5))) 316 (time-add nil (if noninteractive 0.1 5))
308 ;; should_quit or process_input 317 ;; should_quit or process_input
309 arg)) 318 arg))
310 'finished)) 319 'finished))
diff --git a/test/src/lcms-tests.el b/test/src/lcms-tests.el
index f1d1110283d..d92ebcbeab5 100644
--- a/test/src/lcms-tests.el
+++ b/test/src/lcms-tests.el
@@ -2,8 +2,6 @@
2 2
3;; Copyright (C) 2017-2019 Free Software Foundation, Inc. 3;; Copyright (C) 2017-2019 Free Software Foundation, Inc.
4 4
5;; Maintainer: emacs-devel@gnu.org
6
7;; This file is part of GNU Emacs. 5;; This file is part of GNU Emacs.
8 6
9;; GNU Emacs is free software: you can redistribute it and/or modify 7;; GNU Emacs is free software: you can redistribute it and/or modify
diff --git a/test/src/timefns-tests.el b/test/src/timefns-tests.el
index 5c858ef3bd8..2c90af757f0 100644
--- a/test/src/timefns-tests.el
+++ b/test/src/timefns-tests.el
@@ -142,3 +142,9 @@
142 (< 0.99 (/ x y) 1.01) 142 (< 0.99 (/ x y) 1.01)
143 (< 0.99 (/ (- (float-time a)) (float-time b)) 143 (< 0.99 (/ (- (float-time a)) (float-time b))
144 1.01)))))))) 144 1.01))))))))
145
146(ert-deftest encode-time-dst-numeric-zone ()
147 "Check for Bug#35502."
148 (should (time-equal-p
149 (encode-time '(29 31 17 30 4 2019 2 t 7200))
150 '(23752 27217))))