aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorStephen Leake2019-09-10 03:37:51 -0700
committerStephen Leake2019-09-10 03:37:51 -0700
commit3d442312889ef2d14c07282d0aff6199d00cc165 (patch)
tree74034ca2dded6ed233d0701b4cb5c10a0b5e9034 /test
parentac1a2e260e8ece34500b5879f766b4e54ee57b94 (diff)
parent74e9799bd89484b8d15bdd6597c68fc00d07e7f7 (diff)
downloademacs-3d442312889ef2d14c07282d0aff6199d00cc165.tar.gz
emacs-3d442312889ef2d14c07282d0aff6199d00cc165.zip
Merge commit '74e9799bd89484b8d15bdd6597c68fc00d07e7f7'
Diffstat (limited to 'test')
-rw-r--r--test/Makefile.in1
-rw-r--r--test/README3
-rw-r--r--test/lisp/autorevert-tests.el3
-rw-r--r--test/lisp/calendar/icalendar-tests.el18
-rw-r--r--test/lisp/net/nsm-tests.el69
-rw-r--r--test/lisp/net/tramp-tests.el44
-rw-r--r--test/lisp/shadowfile-tests.el272
-rw-r--r--test/src/data-tests.el7
-rw-r--r--test/src/lread-tests.el3
-rw-r--r--test/src/process-tests.el63
-rw-r--r--test/src/timefns-tests.el50
11 files changed, 367 insertions, 166 deletions
diff --git a/test/Makefile.in b/test/Makefile.in
index b7959072083..abcba944734 100644
--- a/test/Makefile.in
+++ b/test/Makefile.in
@@ -233,6 +233,7 @@ define test_template
233 ifeq (,$(patsubst %-tests,,$(1))$(findstring -tests/,$(1))) 233 ifeq (,$(patsubst %-tests,,$(1))$(findstring -tests/,$(1)))
234 $(1).log: $(patsubst %-tests,$(srcdir)/../%,$(1))$(if \ 234 $(1).log: $(patsubst %-tests,$(srcdir)/../%,$(1))$(if \
235 $(patsubst src/%,,$(patsubst lib-src/%,,$(1))),.el,.c) 235 $(patsubst src/%,,$(patsubst lib-src/%,,$(1))),.el,.c)
236 $(notdir $(1).log): $(1).log
236 endif 237 endif
237 238
238 ## Short aliases that always re-run the tests, with no logging. 239 ## Short aliases that always re-run the tests, with no logging.
diff --git a/test/README b/test/README
index c34cdce8ef4..b55e24556f5 100644
--- a/test/README
+++ b/test/README
@@ -44,6 +44,9 @@ The Makefile in this directory supports the following targets:
44 tests. In the former case the output is shown on the terminal, in 44 tests. In the former case the output is shown on the terminal, in
45 the latter case the output is written to <filename>.log. 45 the latter case the output is written to <filename>.log.
46 46
47<filename> could be either a relative file name like
48"lisp/files-tests", or a package name like "files-tests".
49
47ERT offers selectors, which make it possible to filter out which test 50ERT offers selectors, which make it possible to filter out which test
48cases shall run. The make variable $(SELECTOR) gives you a simple 51cases shall run. The make variable $(SELECTOR) gives you a simple
49mean to use your own selectors. The ERT manual describes how 52mean to use your own selectors. The ERT manual describes how
diff --git a/test/lisp/autorevert-tests.el b/test/lisp/autorevert-tests.el
index 0ff3c5a4071..0aec1800dfe 100644
--- a/test/lisp/autorevert-tests.el
+++ b/test/lisp/autorevert-tests.el
@@ -277,6 +277,9 @@ This expects `auto-revert--messages' to be bound by
277; (skip-unless (not (getenv "EMACS_HYDRA_CI"))) 277; (skip-unless (not (getenv "EMACS_HYDRA_CI")))
278 278
279 (let ((tmpfile (make-temp-file "auto-revert-test")) 279 (let ((tmpfile (make-temp-file "auto-revert-test"))
280 ;; Try to catch bug#32645.
281 (auto-revert-debug (getenv "EMACS_HYDRA_CI"))
282 (file-notify-debug (getenv "EMACS_HYDRA_CI"))
280 buf desc) 283 buf desc)
281 (unwind-protect 284 (unwind-protect
282 (progn 285 (progn
diff --git a/test/lisp/calendar/icalendar-tests.el b/test/lisp/calendar/icalendar-tests.el
index baea4804045..0d7004d7106 100644
--- a/test/lisp/calendar/icalendar-tests.el
+++ b/test/lisp/calendar/icalendar-tests.el
@@ -1300,6 +1300,24 @@ UID:9188710a-08a7-4061-bae3-d4cf4972599a
1300" 1300"
1301)) 1301))
1302 1302
1303(ert-deftest icalendar-import-bug-33277 ()
1304 ;;bug#33277 -- start time equals end time
1305 (icalendar-tests--test-import
1306 "DTSTART:20181105T200000Z
1307DTSTAMP:20181105T181652Z
1308DESCRIPTION:
1309LAST-MODIFIED:20181105T181646Z
1310LOCATION:
1311SEQUENCE:0
1312SUMMARY:event with same start/end time
1313TRANSP:OPAQUE
1314"
1315
1316 "&2018/11/5 21:00 event with same start/end time\n"
1317 "&5/11/2018 21:00 event with same start/end time\n"
1318 "&11/5/2018 21:00 event with same start/end time\n"
1319 ))
1320
1303(ert-deftest icalendar-import-multiple-vcalendars () 1321(ert-deftest icalendar-import-multiple-vcalendars ()
1304 (icalendar-tests--test-import 1322 (icalendar-tests--test-import
1305 "DTSTART;VALUE=DATE:20110723 1323 "DTSTART;VALUE=DATE:20110723
diff --git a/test/lisp/net/nsm-tests.el b/test/lisp/net/nsm-tests.el
new file mode 100644
index 00000000000..bf6ac04b527
--- /dev/null
+++ b/test/lisp/net/nsm-tests.el
@@ -0,0 +1,69 @@
1;;; network-stream-tests.el --- tests for network security manager -*- lexical-binding: t; -*-
2
3;; Copyright (C) 2019 Free Software Foundation, Inc.
4
5;; Author: Robert Pluim <rpluim@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
25;;; Code:
26
27(require 'nsm)
28(eval-when-compile (require 'cl-lib))
29
30(ert-deftest nsm-check-local-subnet-ipv4 ()
31 "Check that nsm can be avoided for local subnets."
32 (let ((local-ip '[172 26 128 160 0])
33 (mask '[255 255 255 0 0])
34
35 (wrong-length-mask '[255 255 255])
36 (wrong-mask '[255 255 255 255 0])
37 (remote-ip-yes '[172 26 128 161 0])
38 (remote-ip-no '[172 26 129 161 0]))
39
40 (should (eq t (nsm-network-same-subnet local-ip mask remote-ip-yes)))
41 (should (eq nil (nsm-network-same-subnet local-ip mask remote-ip-no)))
42 (should-error (nsm-network-same-subnet local-ip wrong-length-mask remote-ip-yes))
43 (should (eq nil (nsm-network-same-subnet local-ip wrong-mask remote-ip-yes)))
44 (should (eq t (nsm-should-check "google.com")))
45 (should (eq t (nsm-should-check "127.1")))
46 (should (eq t (nsm-should-check "localhost")))
47 (let ((nsm-trust-local-network t))
48 (should (eq t (nsm-should-check "google.com")))
49 (should (eq nil (nsm-should-check "127.1")))
50 (should (eq nil (nsm-should-check "localhost"))))))
51
52;; FIXME This will never return true, since
53;; network-interface-list only gives the primary address of each
54;; interface, which will be the IPv4 one
55(defun nsm-ipv6-is-available ()
56 (and (featurep 'make-network-process '(:family ipv6))
57 (cl-rassoc-if
58 (lambda (elt)
59 (eq 9 (length elt)))
60 (network-interface-list))))
61
62(ert-deftest nsm-check-local-subnet-ipv6 ()
63 (skip-unless (nsm-ipv6-is-available))
64 (should (eq t (nsm-should-check "::1")))
65 (let ((nsm-trust-local-network t))
66 (should (eq nil (nsm-should-check "::1")))))
67
68
69;;; nsm-tests.el ends here
diff --git a/test/lisp/net/tramp-tests.el b/test/lisp/net/tramp-tests.el
index 180f746c647..dd6b9edd000 100644
--- a/test/lisp/net/tramp-tests.el
+++ b/test/lisp/net/tramp-tests.el
@@ -3098,6 +3098,12 @@ They might differ only in time attributes or directory size."
3098 (let ((attr1 (copy-sequence attr1)) 3098 (let ((attr1 (copy-sequence attr1))
3099 (attr2 (copy-sequence attr2)) 3099 (attr2 (copy-sequence attr2))
3100 (start-time (- tramp--test-start-time 10))) 3100 (start-time (- tramp--test-start-time 10)))
3101 ;; Link number. For directories, it includes the number of
3102 ;; subdirectories. Set it to 1.
3103 (when (eq (tramp-compat-file-attribute-type attr1) t)
3104 (setcar (nthcdr 1 attr1) 1))
3105 (when (eq (tramp-compat-file-attribute-type attr2) t)
3106 (setcar (nthcdr 1 attr2) 1))
3101 ;; Access time. 3107 ;; Access time.
3102 (setcar (nthcdr 4 attr1) tramp-time-dont-know) 3108 (setcar (nthcdr 4 attr1) tramp-time-dont-know)
3103 (setcar (nthcdr 4 attr2) tramp-time-dont-know) 3109 (setcar (nthcdr 4 attr2) tramp-time-dont-know)
@@ -3473,7 +3479,9 @@ This tests also `make-symbolic-link', `file-truename' and `add-name-to-file'."
3473 (setq tmp-name3 (concat (file-remote-p tmp-name3) tmp-name2))))) 3479 (setq tmp-name3 (concat (file-remote-p tmp-name3) tmp-name2)))))
3474 3480
3475 ;; Cleanup. 3481 ;; Cleanup.
3476 (ignore-errors (delete-directory tmp-name1 'recursive))) 3482 (ignore-errors
3483 (delete-file tmp-name3)
3484 (delete-directory tmp-name1 'recursive)))
3477 3485
3478 ;; Detect cyclic symbolic links. 3486 ;; Detect cyclic symbolic links.
3479 (unwind-protect 3487 (unwind-protect
@@ -3533,9 +3541,10 @@ This tests also `make-symbolic-link', `file-truename' and `add-name-to-file'."
3533 (file-attributes tmp-name1)) 3541 (file-attributes tmp-name1))
3534 tramp-time-dont-know) 3542 tramp-time-dont-know)
3535 (should 3543 (should
3536 (equal (tramp-compat-file-attribute-modification-time 3544 (tramp-compat-time-equal-p
3537 (file-attributes tmp-name1)) 3545 (tramp-compat-file-attribute-modification-time
3538 (seconds-to-time 1))) 3546 (file-attributes tmp-name1))
3547 (seconds-to-time 1)))
3539 (write-region "bla" nil tmp-name2) 3548 (write-region "bla" nil tmp-name2)
3540 (should (file-exists-p tmp-name2)) 3549 (should (file-exists-p tmp-name2))
3541 (should (file-newer-than-file-p tmp-name2 tmp-name1)) 3550 (should (file-newer-than-file-p tmp-name2 tmp-name1))
@@ -4182,8 +4191,9 @@ This tests also `make-symbolic-link', `file-truename' and `add-name-to-file'."
4182 (with-timeout (10 (tramp--test-timeout-handler)) 4191 (with-timeout (10 (tramp--test-timeout-handler))
4183 (while (accept-process-output proc 0 nil t))) 4192 (while (accept-process-output proc 0 nil t)))
4184 ;; We cannot use `string-equal', because tramp-adb.el 4193 ;; We cannot use `string-equal', because tramp-adb.el
4185 ;; echoes also the sent string. 4194 ;; echoes also the sent string. And a remote macOS sends
4186 (should (string-match "killed\n\\'" (buffer-string)))) 4195 ;; a slightly modified string.
4196 (should (string-match "killed.*\n\\'" (buffer-string))))
4187 4197
4188 ;; Cleanup. 4198 ;; Cleanup.
4189 (ignore-errors (delete-process proc))) 4199 (ignore-errors (delete-process proc)))
@@ -5145,7 +5155,8 @@ This requires restrictions of file name syntax."
5145 (tmp-name1 (tramp--test-make-temp-name nil quoted)) 5155 (tmp-name1 (tramp--test-make-temp-name nil quoted))
5146 (tmp-name2 (tramp--test-make-temp-name 'local quoted)) 5156 (tmp-name2 (tramp--test-make-temp-name 'local quoted))
5147 (files (delq nil files)) 5157 (files (delq nil files))
5148 (process-environment process-environment)) 5158 (process-environment process-environment)
5159 (sorted-files (sort (copy-sequence files) #'string-lessp)))
5149 (unwind-protect 5160 (unwind-protect
5150 (progn 5161 (progn
5151 (make-directory tmp-name1) 5162 (make-directory tmp-name1)
@@ -5192,10 +5203,20 @@ This requires restrictions of file name syntax."
5192 ;; Check file names. 5203 ;; Check file names.
5193 (should (equal (directory-files 5204 (should (equal (directory-files
5194 tmp-name1 nil directory-files-no-dot-files-regexp) 5205 tmp-name1 nil directory-files-no-dot-files-regexp)
5195 (sort (copy-sequence files) #'string-lessp))) 5206 sorted-files))
5196 (should (equal (directory-files 5207 (should (equal (directory-files
5197 tmp-name2 nil directory-files-no-dot-files-regexp) 5208 tmp-name2 nil directory-files-no-dot-files-regexp)
5198 (sort (copy-sequence files) #'string-lessp))) 5209 sorted-files))
5210 (should (equal (mapcar
5211 #'car
5212 (directory-files-and-attributes
5213 tmp-name1 nil directory-files-no-dot-files-regexp))
5214 sorted-files))
5215 (should (equal (mapcar
5216 #'car
5217 (directory-files-and-attributes
5218 tmp-name2 nil directory-files-no-dot-files-regexp))
5219 sorted-files))
5199 5220
5200 ;; `substitute-in-file-name' could return different 5221 ;; `substitute-in-file-name' could return different
5201 ;; values. For `adb', there could be strange file 5222 ;; values. For `adb', there could be strange file
@@ -5268,7 +5289,10 @@ This requires restrictions of file name syntax."
5268 (should-not (file-exists-p file1)))) 5289 (should-not (file-exists-p file1))))
5269 5290
5270 ;; Check, that environment variables are set correctly. 5291 ;; Check, that environment variables are set correctly.
5271 (when (and (tramp--test-expensive-test) (tramp--test-sh-p)) 5292 ;; We do not run on macOS due to encoding problems. See
5293 ;; Bug#36940.
5294 (when (and (tramp--test-expensive-test) (tramp--test-sh-p)
5295 (not (eq system-type 'darwin)))
5272 (dolist (elt files) 5296 (dolist (elt files)
5273 (let ((envvar (concat "VAR_" (upcase (md5 elt)))) 5297 (let ((envvar (concat "VAR_" (upcase (md5 elt))))
5274 (elt (encode-coding-string elt coding-system-for-read)) 5298 (elt (encode-coding-string elt coding-system-for-read))
diff --git a/test/lisp/shadowfile-tests.el b/test/lisp/shadowfile-tests.el
index 2a777af4720..a93664f6536 100644
--- a/test/lisp/shadowfile-tests.el
+++ b/test/lisp/shadowfile-tests.el
@@ -64,6 +64,7 @@
64 "Temporary directory for Tramp tests.") 64 "Temporary directory for Tramp tests.")
65 65
66(setq password-cache-expiry nil 66(setq password-cache-expiry nil
67 shadow-debug t
67 tramp-verbose 0 68 tramp-verbose 0
68 tramp-message-show-message nil) 69 tramp-message-show-message nil)
69 70
@@ -79,6 +80,35 @@
79 (expand-file-name "shadow_todo_test" temporary-file-directory) 80 (expand-file-name "shadow_todo_test" temporary-file-directory)
80 "File to store the list of uncopied shadows in during tests.") 81 "File to store the list of uncopied shadows in during tests.")
81 82
83(defun shadow--tests-cleanup ()
84 "Reset all `shadowfile' internals."
85 ;; Delete auto-saved files.
86 (with-current-buffer (find-file-noselect shadow-info-file 'nowarn)
87 (ignore-errors (delete-file (make-auto-save-file-name)))
88 (set-buffer-modified-p nil)
89 (kill-buffer))
90 (with-current-buffer (find-file-noselect shadow-todo-file 'nowarn)
91 (ignore-errors (delete-file (make-auto-save-file-name)))
92 (set-buffer-modified-p nil)
93 (kill-buffer))
94 ;; Delete buffers.
95 (ignore-errors
96 (with-current-buffer shadow-info-buffer
97 (set-buffer-modified-p nil)
98 (kill-buffer)))
99 (ignore-errors
100 (with-current-buffer shadow-todo-buffer
101 (set-buffer-modified-p nil)
102 (kill-buffer)))
103 ;; Delete files.
104 (ignore-errors (delete-file shadow-info-file))
105 (ignore-errors (delete-file shadow-todo-file))
106 ;; Reset variables.
107 (setq shadow-info-buffer nil
108 shadow-hashtable nil
109 shadow-todo-buffer nil
110 shadow-files-to-copy nil))
111
82(ert-deftest shadow-test00-clusters () 112(ert-deftest shadow-test00-clusters ()
83 "Check cluster definitions. 113 "Check cluster definitions.
84Per definition, all files are identical on the different hosts of 114Per definition, all files are identical on the different hosts of
@@ -96,23 +126,21 @@ guaranteed by the originator of a cluster definition."
96 (unwind-protect 126 (unwind-protect
97 ;; We must mock `read-from-minibuffer' and `read-string', in 127 ;; We must mock `read-from-minibuffer' and `read-string', in
98 ;; order to avoid interactive arguments. 128 ;; order to avoid interactive arguments.
99 (cl-letf* (((symbol-function 'read-from-minibuffer) 129 (cl-letf* (((symbol-function #'read-from-minibuffer)
100 (lambda (&rest args) (pop mocked-input))) 130 (lambda (&rest args) (pop mocked-input)))
101 ((symbol-function 'read-string) 131 ((symbol-function #'read-string)
102 (lambda (&rest args) (pop mocked-input)))) 132 (lambda (&rest args) (pop mocked-input))))
103 133
104 ;; Cleanup. 134 ;; Cleanup & initialize.
105 (when (file-exists-p shadow-info-file) 135 (shadow--tests-cleanup)
106 (delete-file shadow-info-file)) 136 (shadow-initialize)
107 (when (file-exists-p shadow-todo-file)
108 (delete-file shadow-todo-file))
109 137
110 ;; Define a cluster. 138 ;; Define a cluster.
111 (setq cluster "cluster" 139 (setq cluster "cluster"
112 primary shadow-system-name 140 primary shadow-system-name
113 regexp (shadow-regexp-superquote primary) 141 regexp (shadow-regexp-superquote primary)
114 mocked-input `(,cluster ,primary ,regexp)) 142 mocked-input `(,cluster ,primary ,regexp))
115 (call-interactively 'shadow-define-cluster) 143 (call-interactively #'shadow-define-cluster)
116 (should 144 (should
117 (string-equal 145 (string-equal
118 (shadow-cluster-name (shadow-get-cluster cluster)) cluster)) 146 (shadow-cluster-name (shadow-get-cluster cluster)) cluster))
@@ -136,7 +164,7 @@ guaranteed by the originator of a cluster definition."
136 mocked-input `(,cluster ,cluster ,primary ,regexp)) 164 mocked-input `(,cluster ,cluster ,primary ,regexp))
137 (with-current-buffer (messages-buffer) 165 (with-current-buffer (messages-buffer)
138 (narrow-to-region (point-max) (point-max))) 166 (narrow-to-region (point-max) (point-max)))
139 (call-interactively 'shadow-define-cluster) 167 (call-interactively #'shadow-define-cluster)
140 (should 168 (should
141 (string-match 169 (string-match
142 (regexp-quote "Not a valid primary!") 170 (regexp-quote "Not a valid primary!")
@@ -157,7 +185,7 @@ guaranteed by the originator of a cluster definition."
157 mocked-input `(,cluster ,primary ,cluster ,regexp)) 185 mocked-input `(,cluster ,primary ,cluster ,regexp))
158 (with-current-buffer (messages-buffer) 186 (with-current-buffer (messages-buffer)
159 (narrow-to-region (point-max) (point-max))) 187 (narrow-to-region (point-max) (point-max)))
160 (call-interactively 'shadow-define-cluster) 188 (call-interactively #'shadow-define-cluster)
161 (should 189 (should
162 (string-match 190 (string-match
163 (regexp-quote "Regexp doesn't include the primary host!") 191 (regexp-quote "Regexp doesn't include the primary host!")
@@ -178,7 +206,7 @@ guaranteed by the originator of a cluster definition."
178 (file-remote-p shadow-test-remote-temporary-file-directory) 206 (file-remote-p shadow-test-remote-temporary-file-directory)
179 regexp (shadow-regexp-superquote primary) 207 regexp (shadow-regexp-superquote primary)
180 mocked-input `(,cluster ,primary ,regexp)) 208 mocked-input `(,cluster ,primary ,regexp))
181 (call-interactively 'shadow-define-cluster) 209 (call-interactively #'shadow-define-cluster)
182 (should 210 (should
183 (string-equal 211 (string-equal
184 (shadow-cluster-name (shadow-get-cluster cluster)) cluster)) 212 (shadow-cluster-name (shadow-get-cluster cluster)) cluster))
@@ -198,10 +226,7 @@ guaranteed by the originator of a cluster definition."
198 226
199 ;; Cleanup. 227 ;; Cleanup.
200 (with-current-buffer (messages-buffer) (widen)) 228 (with-current-buffer (messages-buffer) (widen))
201 (when (file-exists-p shadow-info-file) 229 (shadow--tests-cleanup))))
202 (delete-file shadow-info-file))
203 (when (file-exists-p shadow-todo-file)
204 (delete-file shadow-todo-file)))))
205 230
206(ert-deftest shadow-test01-sites () 231(ert-deftest shadow-test01-sites ()
207 "Check site definitions. 232 "Check site definitions.
@@ -218,16 +243,14 @@ guaranteed by the originator of a cluster definition."
218 (unwind-protect 243 (unwind-protect
219 ;; We must mock `read-from-minibuffer' and `read-string', in 244 ;; We must mock `read-from-minibuffer' and `read-string', in
220 ;; order to avoid interactive arguments. 245 ;; order to avoid interactive arguments.
221 (cl-letf* (((symbol-function 'read-from-minibuffer) 246 (cl-letf* (((symbol-function #'read-from-minibuffer)
222 (lambda (&rest args) (pop mocked-input))) 247 (lambda (&rest args) (pop mocked-input)))
223 ((symbol-function 'read-string) 248 ((symbol-function #'read-string)
224 (lambda (&rest args) (pop mocked-input)))) 249 (lambda (&rest args) (pop mocked-input))))
225 250
226 ;; Cleanup. 251 ;; Cleanup & initialize.
227 (when (file-exists-p shadow-info-file) 252 (shadow--tests-cleanup)
228 (delete-file shadow-info-file)) 253 (shadow-initialize)
229 (when (file-exists-p shadow-todo-file)
230 (delete-file shadow-todo-file))
231 254
232 ;; Define a cluster. 255 ;; Define a cluster.
233 (setq cluster1 "cluster1" 256 (setq cluster1 "cluster1"
@@ -308,10 +331,7 @@ guaranteed by the originator of a cluster definition."
308 (shadow-site-match (shadow-site-primary cluster1) cluster2))) 331 (shadow-site-match (shadow-site-primary cluster1) cluster2)))
309 332
310 ;; Cleanup. 333 ;; Cleanup.
311 (when (file-exists-p shadow-info-file) 334 (shadow--tests-cleanup))))
312 (delete-file shadow-info-file))
313 (when (file-exists-p shadow-todo-file)
314 (delete-file shadow-todo-file)))))
315 335
316(ert-deftest shadow-test02-files () 336(ert-deftest shadow-test02-files ()
317 "Check file manipulation functions." 337 "Check file manipulation functions."
@@ -324,11 +344,10 @@ guaranteed by the originator of a cluster definition."
324 cluster primary regexp file hup) 344 cluster primary regexp file hup)
325 (unwind-protect 345 (unwind-protect
326 (progn 346 (progn
327 ;; Cleanup. 347
328 (when (file-exists-p shadow-info-file) 348 ;; Cleanup & initialize.
329 (delete-file shadow-info-file)) 349 (shadow--tests-cleanup)
330 (when (file-exists-p shadow-todo-file) 350 (shadow-initialize)
331 (delete-file shadow-todo-file))
332 351
333 ;; Define a cluster. 352 ;; Define a cluster.
334 (setq cluster "cluster" 353 (setq cluster "cluster"
@@ -384,10 +403,7 @@ guaranteed by the originator of a cluster definition."
384 (should-not (shadow-local-file nil))) 403 (should-not (shadow-local-file nil)))
385 404
386 ;; Cleanup. 405 ;; Cleanup.
387 (when (file-exists-p shadow-info-file) 406 (shadow--tests-cleanup))))
388 (delete-file shadow-info-file))
389 (when (file-exists-p shadow-todo-file)
390 (delete-file shadow-todo-file)))))
391 407
392(ert-deftest shadow-test03-expand-cluster-in-file-name () 408(ert-deftest shadow-test03-expand-cluster-in-file-name ()
393 "Check canonical file name of a cluster or site." 409 "Check canonical file name of a cluster or site."
@@ -400,11 +416,10 @@ guaranteed by the originator of a cluster definition."
400 cluster primary regexp file1 file2) 416 cluster primary regexp file1 file2)
401 (unwind-protect 417 (unwind-protect
402 (progn 418 (progn
403 ;; Cleanup. 419
404 (when (file-exists-p shadow-info-file) 420 ;; Cleanup & initialize.
405 (delete-file shadow-info-file)) 421 (shadow--tests-cleanup)
406 (when (file-exists-p shadow-todo-file) 422 (shadow-initialize)
407 (delete-file shadow-todo-file))
408 423
409 ;; Define a cluster. 424 ;; Define a cluster.
410 (setq cluster "cluster" 425 (setq cluster "cluster"
@@ -455,10 +470,7 @@ guaranteed by the originator of a cluster definition."
455 (concat primary file1)))) 470 (concat primary file1))))
456 471
457 ;; Cleanup. 472 ;; Cleanup.
458 (when (file-exists-p shadow-info-file) 473 (shadow--tests-cleanup))))
459 (delete-file shadow-info-file))
460 (when (file-exists-p shadow-todo-file)
461 (delete-file shadow-todo-file)))))
462 474
463(ert-deftest shadow-test04-contract-file-name () 475(ert-deftest shadow-test04-contract-file-name ()
464 "Check canonical file name of a cluster or site." 476 "Check canonical file name of a cluster or site."
@@ -471,11 +483,10 @@ guaranteed by the originator of a cluster definition."
471 cluster primary regexp file) 483 cluster primary regexp file)
472 (unwind-protect 484 (unwind-protect
473 (progn 485 (progn
474 ;; Cleanup. 486
475 (when (file-exists-p shadow-info-file) 487 ;; Cleanup & initialize.
476 (delete-file shadow-info-file)) 488 (shadow--tests-cleanup)
477 (when (file-exists-p shadow-todo-file) 489 (shadow-initialize)
478 (delete-file shadow-todo-file))
479 490
480 ;; Define a cluster. 491 ;; Define a cluster.
481 (setq cluster "cluster" 492 (setq cluster "cluster"
@@ -516,10 +527,7 @@ guaranteed by the originator of a cluster definition."
516 (concat "/cluster:" file)))) 527 (concat "/cluster:" file))))
517 528
518 ;; Cleanup. 529 ;; Cleanup.
519 (when (file-exists-p shadow-info-file) 530 (shadow--tests-cleanup))))
520 (delete-file shadow-info-file))
521 (when (file-exists-p shadow-todo-file)
522 (delete-file shadow-todo-file)))))
523 531
524(ert-deftest shadow-test05-file-match () 532(ert-deftest shadow-test05-file-match ()
525 "Check `shadow-same-site' and `shadow-file-match'." 533 "Check `shadow-same-site' and `shadow-file-match'."
@@ -532,11 +540,10 @@ guaranteed by the originator of a cluster definition."
532 cluster primary regexp file) 540 cluster primary regexp file)
533 (unwind-protect 541 (unwind-protect
534 (progn 542 (progn
535 ;; Cleanup. 543
536 (when (file-exists-p shadow-info-file) 544 ;; Cleanup & initialize.
537 (delete-file shadow-info-file)) 545 (shadow--tests-cleanup)
538 (when (file-exists-p shadow-todo-file) 546 (shadow-initialize)
539 (delete-file shadow-todo-file))
540 547
541 ;; Define a cluster. 548 ;; Define a cluster.
542 (setq cluster "cluster" 549 (setq cluster "cluster"
@@ -575,10 +582,7 @@ guaranteed by the originator of a cluster definition."
575 file))) 582 file)))
576 583
577 ;; Cleanup. 584 ;; Cleanup.
578 (when (file-exists-p shadow-info-file) 585 (shadow--tests-cleanup))))
579 (delete-file shadow-info-file))
580 (when (file-exists-p shadow-todo-file)
581 (delete-file shadow-todo-file)))))
582 586
583(ert-deftest shadow-test06-literal-groups () 587(ert-deftest shadow-test06-literal-groups ()
584 "Check literal group definitions." 588 "Check literal group definitions."
@@ -592,16 +596,14 @@ guaranteed by the originator of a cluster definition."
592 (unwind-protect 596 (unwind-protect
593 ;; We must mock `read-from-minibuffer' and `read-string', in 597 ;; We must mock `read-from-minibuffer' and `read-string', in
594 ;; order to avoid interactive arguments. 598 ;; order to avoid interactive arguments.
595 (cl-letf* (((symbol-function 'read-from-minibuffer) 599 (cl-letf* (((symbol-function #'read-from-minibuffer)
596 (lambda (&rest args) (pop mocked-input))) 600 (lambda (&rest args) (pop mocked-input)))
597 ((symbol-function 'read-string) 601 ((symbol-function #'read-string)
598 (lambda (&rest args) (pop mocked-input)))) 602 (lambda (&rest args) (pop mocked-input))))
599 603
600 ;; Cleanup. 604 ;; Cleanup & initialize.
601 (when (file-exists-p shadow-info-file) 605 (shadow--tests-cleanup)
602 (delete-file shadow-info-file)) 606 (shadow-initialize)
603 (when (file-exists-p shadow-todo-file)
604 (delete-file shadow-todo-file))
605 607
606 ;; Define clusters. 608 ;; Define clusters.
607 (setq cluster1 "cluster1" 609 (setq cluster1 "cluster1"
@@ -627,7 +629,8 @@ guaranteed by the originator of a cluster definition."
627 mocked-input `(,cluster1 ,file1 ,cluster2 ,file2 ,(kbd "RET"))) 629 mocked-input `(,cluster1 ,file1 ,cluster2 ,file2 ,(kbd "RET")))
628 (with-temp-buffer 630 (with-temp-buffer
629 (set-visited-file-name file1) 631 (set-visited-file-name file1)
630 (call-interactively 'shadow-define-literal-group)) 632 (call-interactively #'shadow-define-literal-group)
633 (set-buffer-modified-p nil))
631 634
632 ;; `shadow-literal-groups' is a list of lists. 635 ;; `shadow-literal-groups' is a list of lists.
633 (should (consp shadow-literal-groups)) 636 (should (consp shadow-literal-groups))
@@ -640,10 +643,7 @@ guaranteed by the originator of a cluster definition."
640 (car shadow-literal-groups)))) 643 (car shadow-literal-groups))))
641 644
642 ;; Cleanup. 645 ;; Cleanup.
643 (when (file-exists-p shadow-info-file) 646 (shadow--tests-cleanup))))
644 (delete-file shadow-info-file))
645 (when (file-exists-p shadow-todo-file)
646 (delete-file shadow-todo-file)))))
647 647
648(ert-deftest shadow-test07-regexp-groups () 648(ert-deftest shadow-test07-regexp-groups ()
649 "Check regexp group definitions." 649 "Check regexp group definitions."
@@ -657,16 +657,14 @@ guaranteed by the originator of a cluster definition."
657 (unwind-protect 657 (unwind-protect
658 ;; We must mock `read-from-minibuffer' and `read-string', in 658 ;; We must mock `read-from-minibuffer' and `read-string', in
659 ;; order to avoid interactive arguments. 659 ;; order to avoid interactive arguments.
660 (cl-letf* (((symbol-function 'read-from-minibuffer) 660 (cl-letf* (((symbol-function #'read-from-minibuffer)
661 (lambda (&rest args) (pop mocked-input))) 661 (lambda (&rest args) (pop mocked-input)))
662 ((symbol-function 'read-string) 662 ((symbol-function #'read-string)
663 (lambda (&rest args) (pop mocked-input)))) 663 (lambda (&rest args) (pop mocked-input))))
664 664
665 ;; Cleanup. 665 ;; Cleanup & initialize.
666 (when (file-exists-p shadow-info-file) 666 (shadow--tests-cleanup)
667 (delete-file shadow-info-file)) 667 (shadow-initialize)
668 (when (file-exists-p shadow-todo-file)
669 (delete-file shadow-todo-file))
670 668
671 ;; Define clusters. 669 ;; Define clusters.
672 (setq cluster1 "cluster1" 670 (setq cluster1 "cluster1"
@@ -688,7 +686,8 @@ guaranteed by the originator of a cluster definition."
688 ,cluster1 ,cluster2 ,(kbd "RET"))) 686 ,cluster1 ,cluster2 ,(kbd "RET")))
689 (with-temp-buffer 687 (with-temp-buffer
690 (set-visited-file-name nil) 688 (set-visited-file-name nil)
691 (call-interactively 'shadow-define-regexp-group)) 689 (call-interactively #'shadow-define-regexp-group)
690 (set-buffer-modified-p nil))
692 691
693 ;; `shadow-regexp-groups' is a list of lists. 692 ;; `shadow-regexp-groups' is a list of lists.
694 (should (consp shadow-regexp-groups)) 693 (should (consp shadow-regexp-groups))
@@ -707,10 +706,7 @@ guaranteed by the originator of a cluster definition."
707 (car shadow-regexp-groups)))) 706 (car shadow-regexp-groups))))
708 707
709 ;; Cleanup. 708 ;; Cleanup.
710 (when (file-exists-p shadow-info-file) 709 (shadow--tests-cleanup))))
711 (delete-file shadow-info-file))
712 (when (file-exists-p shadow-todo-file)
713 (delete-file shadow-todo-file)))))
714 710
715(ert-deftest shadow-test08-shadow-todo () 711(ert-deftest shadow-test08-shadow-todo ()
716 "Check that needed shadows are added to todo." 712 "Check that needed shadows are added to todo."
@@ -722,28 +718,37 @@ guaranteed by the originator of a cluster definition."
722 (shadow-info-file shadow-test-info-file) 718 (shadow-info-file shadow-test-info-file)
723 (shadow-todo-file shadow-test-todo-file) 719 (shadow-todo-file shadow-test-todo-file)
724 (shadow-inhibit-message t) 720 (shadow-inhibit-message t)
721 (shadow-test-remote-temporary-file-directory
722 (file-truename shadow-test-remote-temporary-file-directory))
725 shadow-clusters shadow-literal-groups shadow-regexp-groups 723 shadow-clusters shadow-literal-groups shadow-regexp-groups
726 shadow-files-to-copy 724 shadow-files-to-copy
727 cluster1 cluster2 primary regexp file) 725 cluster1 cluster2 primary regexp file)
728 (unwind-protect 726 (unwind-protect
729 (progn 727 (progn
730 ;; Cleanup. 728
731 (when (file-exists-p shadow-info-file) 729 ;; Cleanup & initialize.
732 (delete-file shadow-info-file)) 730 (shadow--tests-cleanup)
733 (when (file-exists-p shadow-todo-file) 731 (shadow-initialize)
734 (delete-file shadow-todo-file))
735 732
736 ;; Define clusters. 733 ;; Define clusters.
737 (setq cluster1 "cluster1" 734 (setq cluster1 "cluster1"
738 primary shadow-system-name 735 primary shadow-system-name
739 regexp (shadow-regexp-superquote primary)) 736 regexp (shadow-regexp-superquote primary))
740 (shadow-set-cluster cluster1 primary regexp) 737 (shadow-set-cluster cluster1 primary regexp)
738 (when shadow-debug
739 (message
740 "shadow-test08-shadow-todo: %s %s %s %s"
741 cluster1 primary regexp shadow-clusters))
741 742
742 (setq cluster2 "cluster2" 743 (setq cluster2 "cluster2"
743 primary 744 primary
744 (file-remote-p shadow-test-remote-temporary-file-directory) 745 (file-remote-p shadow-test-remote-temporary-file-directory)
745 regexp (shadow-regexp-superquote primary)) 746 regexp (shadow-regexp-superquote primary))
746 (shadow-set-cluster cluster2 primary regexp) 747 (shadow-set-cluster cluster2 primary regexp)
748 (when shadow-debug
749 (message
750 "shadow-test08-shadow-todo: %s %s %s %s"
751 cluster2 primary regexp shadow-clusters))
747 752
748 ;; Define a literal group. 753 ;; Define a literal group.
749 (setq file 754 (setq file
@@ -751,12 +756,20 @@ guaranteed by the originator of a cluster definition."
751 (expand-file-name "shadowfile-tests" temporary-file-directory)) 756 (expand-file-name "shadowfile-tests" temporary-file-directory))
752 shadow-literal-groups 757 shadow-literal-groups
753 `((,(concat "/cluster1:" file) ,(concat "/cluster2:" file)))) 758 `((,(concat "/cluster1:" file) ,(concat "/cluster2:" file))))
759 (when shadow-debug
760 (message
761 "shadow-test08-shadow-todo: %s %s" file shadow-literal-groups))
754 762
755 ;; Save file from "cluster1" definition. 763 ;; Save file from "cluster1" definition.
756 (with-temp-buffer 764 (with-temp-buffer
757 (set-visited-file-name file) 765 (set-visited-file-name file)
758 (insert "foo") 766 (insert "foo")
759 (save-buffer)) 767 (save-buffer))
768 (when shadow-debug
769 (message
770 "shadow-test08-shadow-todo: %s %s"
771 (cons file (shadow-contract-file-name (concat "/cluster2:" file)))
772 shadow-files-to-copy))
760 (should 773 (should
761 (member 774 (member
762 (cons file (shadow-contract-file-name (concat "/cluster2:" file))) 775 (cons file (shadow-contract-file-name (concat "/cluster2:" file)))
@@ -767,6 +780,13 @@ guaranteed by the originator of a cluster definition."
767 (set-visited-file-name (concat (shadow-site-primary cluster2) file)) 780 (set-visited-file-name (concat (shadow-site-primary cluster2) file))
768 (insert "foo") 781 (insert "foo")
769 (save-buffer)) 782 (save-buffer))
783 (when shadow-debug
784 (message
785 "shadow-test08-shadow-todo: %s %s"
786 (cons
787 (concat (shadow-site-primary cluster2) file)
788 (shadow-contract-file-name (concat "/cluster1:" file)))
789 shadow-files-to-copy))
770 (should 790 (should
771 (member 791 (member
772 (cons 792 (cons
@@ -781,12 +801,20 @@ guaranteed by the originator of a cluster definition."
781 (shadow-regexp-superquote file)) 801 (shadow-regexp-superquote file))
782 ,(concat (shadow-site-primary cluster2) 802 ,(concat (shadow-site-primary cluster2)
783 (shadow-regexp-superquote file))))) 803 (shadow-regexp-superquote file)))))
804 (when shadow-debug
805 (message
806 "shadow-test08-shadow-todo: %s %s" file shadow-regexp-groups))
784 807
785 ;; Save file from "cluster1" definition. 808 ;; Save file from "cluster1" definition.
786 (with-temp-buffer 809 (with-temp-buffer
787 (set-visited-file-name file) 810 (set-visited-file-name file)
788 (insert "foo") 811 (insert "foo")
789 (save-buffer)) 812 (save-buffer))
813 (when shadow-debug
814 (message
815 "shadow-test08-shadow-todo: %s %s"
816 (cons file (shadow-contract-file-name (concat "/cluster2:" file)))
817 shadow-files-to-copy))
790 (should 818 (should
791 (member 819 (member
792 (cons file (shadow-contract-file-name (concat "/cluster2:" file))) 820 (cons file (shadow-contract-file-name (concat "/cluster2:" file)))
@@ -797,6 +825,13 @@ guaranteed by the originator of a cluster definition."
797 (set-visited-file-name (concat (shadow-site-primary cluster2) file)) 825 (set-visited-file-name (concat (shadow-site-primary cluster2) file))
798 (insert "foo") 826 (insert "foo")
799 (save-buffer)) 827 (save-buffer))
828 (when shadow-debug
829 (message
830 "shadow-test08-shadow-todo: %s %s"
831 (cons
832 (concat (shadow-site-primary cluster2) file)
833 (shadow-contract-file-name (concat "/cluster1:" file)))
834 shadow-files-to-copy))
800 (should 835 (should
801 (member 836 (member
802 (cons 837 (cons
@@ -805,16 +840,13 @@ guaranteed by the originator of a cluster definition."
805 shadow-files-to-copy))) 840 shadow-files-to-copy)))
806 841
807 ;; Cleanup. 842 ;; Cleanup.
808 (when (file-exists-p shadow-info-file) 843 (dolist (elt `(,file ,(concat (shadow-site-primary cluster2) file)))
809 (delete-file shadow-info-file)) 844 (ignore-errors
810 (when (file-exists-p shadow-todo-file) 845 (with-current-buffer (get-file-buffer elt)
811 (delete-file shadow-todo-file)) 846 (set-buffer-modified-p nil)
812 (ignore-errors 847 (kill-buffer)))
813 (when (file-exists-p file) 848 (ignore-errors (delete-file elt)))
814 (delete-file file))) 849 (shadow--tests-cleanup))))
815 (ignore-errors
816 (when (file-exists-p (concat (shadow-site-primary cluster2) file))
817 (delete-file (concat (shadow-site-primary cluster2) file)))))))
818 850
819(ert-deftest shadow-test09-shadow-copy-files () 851(ert-deftest shadow-test09-shadow-copy-files ()
820 "Check that needed shadow files are copied." 852 "Check that needed shadow files are copied."
@@ -826,18 +858,17 @@ guaranteed by the originator of a cluster definition."
826 (shadow-info-file shadow-test-info-file) 858 (shadow-info-file shadow-test-info-file)
827 (shadow-todo-file shadow-test-todo-file) 859 (shadow-todo-file shadow-test-todo-file)
828 (shadow-inhibit-message t) 860 (shadow-inhibit-message t)
861 (shadow-test-remote-temporary-file-directory
862 (file-truename shadow-test-remote-temporary-file-directory))
829 (shadow-noquery t) 863 (shadow-noquery t)
830 shadow-clusters shadow-files-to-copy 864 shadow-clusters shadow-files-to-copy
831 cluster1 cluster2 primary regexp file mocked-input) 865 cluster1 cluster2 primary regexp file mocked-input)
832 (unwind-protect 866 (unwind-protect
833 (progn 867 (progn
834 ;; Cleanup. 868
835 (when (file-exists-p shadow-info-file) 869 ;; Cleanup & initialize.
836 (delete-file shadow-info-file)) 870 (shadow--tests-cleanup)
837 (when (file-exists-p shadow-todo-file) 871 (shadow-initialize)
838 (delete-file shadow-todo-file))
839 (when (buffer-live-p shadow-todo-buffer)
840 (with-current-buffer shadow-todo-buffer (erase-buffer)))
841 872
842 ;; Define clusters. 873 ;; Define clusters.
843 (setq cluster1 "cluster1" 874 (setq cluster1 "cluster1"
@@ -878,7 +909,7 @@ guaranteed by the originator of a cluster definition."
878 ;; We must mock `write-region', in order to check proper 909 ;; We must mock `write-region', in order to check proper
879 ;; action. 910 ;; action.
880 (add-function 911 (add-function
881 :before (symbol-function 'write-region) 912 :before (symbol-function #'write-region)
882 (lambda (&rest args) 913 (lambda (&rest args)
883 (when (and (buffer-file-name) mocked-input) 914 (when (and (buffer-file-name) mocked-input)
884 (should (equal (buffer-file-name) (pop mocked-input))))) 915 (should (equal (buffer-file-name) (pop mocked-input)))))
@@ -893,17 +924,14 @@ guaranteed by the originator of a cluster definition."
893 (looking-at (regexp-quote "(setq shadow-files-to-copy nil)"))))) 924 (looking-at (regexp-quote "(setq shadow-files-to-copy nil)")))))
894 925
895 ;; Cleanup. 926 ;; Cleanup.
896 (remove-function (symbol-function 'write-region) "write-region-mock") 927 (remove-function (symbol-function #'write-region) "write-region-mock")
897 (when (file-exists-p shadow-info-file) 928 (dolist (elt `(,file ,(concat (shadow-site-primary cluster2) file)))
898 (delete-file shadow-info-file)) 929 (ignore-errors
899 (when (file-exists-p shadow-todo-file) 930 (with-current-buffer (get-file-buffer elt)
900 (delete-file shadow-todo-file)) 931 (set-buffer-modified-p nil)
901 (ignore-errors 932 (kill-buffer)))
902 (when (file-exists-p file) 933 (ignore-errors (delete-file elt)))
903 (delete-file file))) 934 (shadow--tests-cleanup))))
904 (ignore-errors
905 (when (file-exists-p (concat (shadow-site-primary cluster2) file))
906 (delete-file (concat (shadow-site-primary cluster2) file)))))))
907 935
908(defun shadowfile-test-all (&optional interactive) 936(defun shadowfile-test-all (&optional interactive)
909 "Run all tests for \\[shadowfile]." 937 "Run all tests for \\[shadowfile]."
@@ -912,9 +940,5 @@ guaranteed by the originator of a cluster definition."
912 (ert-run-tests-interactively "^shadowfile-") 940 (ert-run-tests-interactively "^shadowfile-")
913 (ert-run-tests-batch "^shadowfile-"))) 941 (ert-run-tests-batch "^shadowfile-")))
914 942
915(let ((shadow-info-file shadow-test-info-file)
916 (shadow-todo-file shadow-test-todo-file))
917 (shadow-initialize))
918
919(provide 'shadowfile-tests) 943(provide 'shadowfile-tests)
920;;; shadowfile-tests.el ends here 944;;; shadowfile-tests.el ends here
diff --git a/test/src/data-tests.el b/test/src/data-tests.el
index a9d48e29a8a..3a7462b6ada 100644
--- a/test/src/data-tests.el
+++ b/test/src/data-tests.el
@@ -653,6 +653,13 @@ comparing the subr with a much slower lisp implementation."
653 (data-tests-check-sign (% -1 -3) (% nb1 nb3)) 653 (data-tests-check-sign (% -1 -3) (% nb1 nb3))
654 (data-tests-check-sign (mod -1 -3) (mod nb1 nb3)))) 654 (data-tests-check-sign (mod -1 -3) (mod nb1 nb3))))
655 655
656(ert-deftest data-tests-mod-0 ()
657 (dolist (num (list (1- most-negative-fixnum) -1 0 1
658 (1+ most-positive-fixnum)))
659 (should-error (mod num 0)))
660 (when (ignore-errors (/ 0.0 0))
661 (should (equal (abs (mod 0.0 0)) (abs (- 0.0 (/ 0.0 0)))))))
662
656(ert-deftest data-tests-ash-lsh () 663(ert-deftest data-tests-ash-lsh ()
657 (should (= (ash most-negative-fixnum 1) 664 (should (= (ash most-negative-fixnum 1)
658 (* most-negative-fixnum 2))) 665 (* most-negative-fixnum 2)))
diff --git a/test/src/lread-tests.el b/test/src/lread-tests.el
index 82b75b195ca..ba5bfe0145d 100644
--- a/test/src/lread-tests.el
+++ b/test/src/lread-tests.el
@@ -220,4 +220,7 @@ literals (Bug#20852)."
220 (* most-positive-fixnum most-positive-fixnum))) 220 (* most-positive-fixnum most-positive-fixnum)))
221 (should (= n (string-to-number (format "%d." n)))))) 221 (should (= n (string-to-number (format "%d." n))))))
222 222
223(ert-deftest lread-circular-hash ()
224 (should-error (read "#s(hash-table data #0=(#0# . #0#))")))
225
223;;; lread-tests.el ends here 226;;; lread-tests.el ends here
diff --git a/test/src/process-tests.el b/test/src/process-tests.el
index 7745fccaf9d..158c036aaa7 100644
--- a/test/src/process-tests.el
+++ b/test/src/process-tests.el
@@ -22,6 +22,7 @@
22;;; Code: 22;;; Code:
23 23
24(require 'ert) 24(require 'ert)
25(require 'puny)
25 26
26;; Timeout in seconds; the test fails if the timeout is reached. 27;; Timeout in seconds; the test fails if the timeout is reached.
27(defvar process-test-sentinel-wait-timeout 2.0) 28(defvar process-test-sentinel-wait-timeout 2.0)
@@ -154,24 +155,30 @@
154 (concat invocation-directory invocation-name) 155 (concat invocation-directory invocation-name)
155 "-Q" "--batch" "--eval" 156 "-Q" "--batch" "--eval"
156 (prin1-to-string 157 (prin1-to-string
157 '(let (s) 158 '(let ((s nil) (count 0))
158 (while (setq s (read-from-minibuffer "$ ")) 159 (while (setq s (read-from-minibuffer
160 (format "%d> " count)))
159 (princ s) 161 (princ s)
160 (princ "\n"))))))) 162 (princ "\n")
163 (setq count (1+ count))))))))
161 (set-process-query-on-exit-flag proc nil) 164 (set-process-query-on-exit-flag proc nil)
162 (send-string proc "one\n") 165 (send-string proc "one\n")
163 (should 166 (while (not (equal (buffer-substring
164 (accept-process-output proc 1)) ; Read "one". 167 (line-beginning-position) (point-max))
165 (should (equal (buffer-string) "$ one\n$ ")) 168 "1> "))
169 (accept-process-output proc)) ; Read "one".
170 (should (equal (buffer-string) "0> one\n1> "))
166 (set-process-filter proc t) ; Stop reading from proc. 171 (set-process-filter proc t) ; Stop reading from proc.
167 (send-string proc "two\n") 172 (send-string proc "two\n")
168 (should-not 173 (should-not
169 (accept-process-output proc 1)) ; Can't read "two" yet. 174 (accept-process-output proc 1)) ; Can't read "two" yet.
170 (should (equal (buffer-string) "$ one\n$ ")) 175 (should (equal (buffer-string) "0> one\n1> "))
171 (set-process-filter proc nil) ; Resume reading from proc. 176 (set-process-filter proc nil) ; Resume reading from proc.
172 (should 177 (while (not (equal (buffer-substring
173 (accept-process-output proc 1)) ; Read "two" from proc. 178 (line-beginning-position) (point-max))
174 (should (equal (buffer-string) "$ one\n$ two\n$ "))))) 179 "2> "))
180 (accept-process-output proc)) ; Read "Two".
181 (should (equal (buffer-string) "0> one\n1> two\n2> ")))))
175 182
176(ert-deftest start-process-should-not-modify-arguments () 183(ert-deftest start-process-should-not-modify-arguments ()
177 "`start-process' must not modify its arguments in-place." 184 "`start-process' must not modify its arguments in-place."
@@ -322,5 +329,41 @@ See Bug#30460."
322 invocation-directory)) 329 invocation-directory))
323 :stop t))) 330 :stop t)))
324 331
332;; All the following tests require working DNS, which appears not to
333;; be the case for hydra.nixos.org, so disable them there for now.
334
335(ert-deftest lookup-family-specification ()
336 "network-lookup-address-info should only accept valid family symbols."
337 (skip-unless (not (getenv "EMACS_HYDRA_CI")))
338 (should-error (network-lookup-address-info "google.com" 'both))
339 (should (network-lookup-address-info "google.com" 'ipv4))
340 (should (network-lookup-address-info "google.com" 'ipv6)))
341
342(ert-deftest lookup-unicode-domains ()
343 "Unicode domains should fail"
344 (skip-unless (not (getenv "EMACS_HYDRA_CI")))
345 (should-error (network-lookup-address-info "faß.de"))
346 (should (network-lookup-address-info (puny-encode-domain "faß.de"))))
347
348(ert-deftest unibyte-domain-name ()
349 "Unibyte domain names should work"
350 (skip-unless (not (getenv "EMACS_HYDRA_CI")))
351 (should (network-lookup-address-info (string-to-unibyte "google.com"))))
352
353(ert-deftest lookup-google ()
354 "Check that we can look up google IP addresses"
355 (skip-unless (not (getenv "EMACS_HYDRA_CI")))
356 (let ((addresses-both (network-lookup-address-info "google.com"))
357 (addresses-v4 (network-lookup-address-info "google.com" 'ipv4))
358 (addresses-v6 (network-lookup-address-info "google.com" 'ipv6)))
359 (should addresses-both)
360 (should addresses-v4)
361 (should addresses-v6)))
362
363(ert-deftest non-existent-lookup-failure ()
364 (skip-unless (not (getenv "EMACS_HYDRA_CI")))
365 "Check that looking up non-existent domain returns nil"
366 (should (eq nil (network-lookup-address-info "emacs.invalid"))))
367
325(provide 'process-tests) 368(provide 'process-tests)
326;; process-tests.el ends here. 369;; process-tests.el ends here.
diff --git a/test/src/timefns-tests.el b/test/src/timefns-tests.el
index a30b2de3a5b..3a18a4a24dd 100644
--- a/test/src/timefns-tests.el
+++ b/test/src/timefns-tests.el
@@ -19,6 +19,12 @@
19 19
20(require 'ert) 20(require 'ert)
21 21
22(defun timefns-tests--decode-time (look zone decoded-time)
23 (should (equal (decode-time look zone t) decoded-time))
24 (should (equal (decode-time look zone 'integer)
25 (cons (time-convert (car decoded-time) 'integer)
26 (cdr decoded-time)))))
27
22;;; Check format-time-string and decode-time with various TZ settings. 28;;; Check format-time-string and decode-time with various TZ settings.
23;;; Use only POSIX-compatible TZ values, since the tests should work 29;;; Use only POSIX-compatible TZ values, since the tests should work
24;;; even if tzdb is not in use. 30;;; even if tzdb is not in use.
@@ -40,31 +46,29 @@
40 (7879679999900 . 100000) 46 (7879679999900 . 100000)
41 (78796799999999999999 . 1000000000000))) 47 (78796799999999999999 . 1000000000000)))
42 ;; UTC. 48 ;; UTC.
43 (let ((sec (time-add 59 (time-subtract (time-convert look t) 49 (let* ((look-ticks-hz (time-convert look t))
44 (time-convert look 'integer))))) 50 (hz (cdr look-ticks-hz))
51 (look-integer (time-convert look 'integer))
52 (sec (time-add (time-convert 59 hz)
53 (time-subtract look-ticks-hz
54 (time-convert look-integer hz)))))
45 (should (string-equal 55 (should (string-equal
46 (format-time-string "%Y-%m-%d %H:%M:%S.%3N %z" look t) 56 (format-time-string "%Y-%m-%d %H:%M:%S.%3N %z" look t)
47 "1972-06-30 23:59:59.999 +0000")) 57 "1972-06-30 23:59:59.999 +0000"))
48 (should (equal (decode-time look t 'integer) 58 (timefns-tests--decode-time look t
49 '(59 59 23 30 6 1972 5 nil 0))) 59 (list sec 59 23 30 6 1972 5 nil 0))
50 (should (equal (decode-time look t t)
51 (list sec 59 23 30 6 1972 5 nil 0)))
52 ;; "UTC0". 60 ;; "UTC0".
53 (should (string-equal 61 (should (string-equal
54 (format-time-string format look "UTC0") 62 (format-time-string format look "UTC0")
55 "1972-06-30 23:59:59.999 +0000 (UTC)")) 63 "1972-06-30 23:59:59.999 +0000 (UTC)"))
56 (should (equal (decode-time look "UTC0" 'integer) 64 (timefns-tests--decode-time look "UTC0"
57 '(59 59 23 30 6 1972 5 nil 0))) 65 (list sec 59 23 30 6 1972 5 nil 0))
58 (should (equal (decode-time look "UTC0" t)
59 (list sec 59 23 30 6 1972 5 nil 0)))
60 ;; Negative UTC offset, as a Lisp list. 66 ;; Negative UTC offset, as a Lisp list.
61 (should (string-equal 67 (should (string-equal
62 (format-time-string format look '(-28800 "PST")) 68 (format-time-string format look '(-28800 "PST"))
63 "1972-06-30 15:59:59.999 -0800 (PST)")) 69 "1972-06-30 15:59:59.999 -0800 (PST)"))
64 (should (equal (decode-time look '(-28800 "PST") 'integer) 70 (timefns-tests--decode-time look '(-28800 "PST")
65 '(59 59 15 30 6 1972 5 nil -28800))) 71 (list sec 59 15 30 6 1972 5 nil -28800))
66 (should (equal (decode-time look '(-28800 "PST") t)
67 (list sec 59 15 30 6 1972 5 nil -28800)))
68 ;; Negative UTC offset, as a Lisp integer. 72 ;; Negative UTC offset, as a Lisp integer.
69 (should (string-equal 73 (should (string-equal
70 (format-time-string format look -28800) 74 (format-time-string format look -28800)
@@ -73,18 +77,14 @@
73 (if (eq system-type 'windows-nt) 77 (if (eq system-type 'windows-nt)
74 "1972-06-30 15:59:59.999 -0800 (ZZZ)" 78 "1972-06-30 15:59:59.999 -0800 (ZZZ)"
75 "1972-06-30 15:59:59.999 -0800 (-08)"))) 79 "1972-06-30 15:59:59.999 -0800 (-08)")))
76 (should (equal (decode-time look -28800 'integer) 80 (timefns-tests--decode-time look -28800
77 '(59 59 15 30 6 1972 5 nil -28800))) 81 (list sec 59 15 30 6 1972 5 nil -28800))
78 (should (equal (decode-time look -28800 t)
79 (list sec 59 15 30 6 1972 5 nil -28800)))
80 ;; Positive UTC offset that is not an hour multiple, as a string. 82 ;; Positive UTC offset that is not an hour multiple, as a string.
81 (should (string-equal 83 (should (string-equal
82 (format-time-string format look "IST-5:30") 84 (format-time-string format look "IST-5:30")
83 "1972-07-01 05:29:59.999 +0530 (IST)")) 85 "1972-07-01 05:29:59.999 +0530 (IST)"))
84 (should (equal (decode-time look "IST-5:30" 'integer) 86 (timefns-tests--decode-time look "IST-5:30"
85 '(59 29 5 1 7 1972 6 nil 19800))) 87 (list sec 29 5 1 7 1972 6 nil 19800))))))
86 (should (equal (decode-time look "IST-5:30" t)
87 (list sec 29 5 1 7 1972 6 nil 19800)))))))
88 88
89(ert-deftest decode-then-encode-time () 89(ert-deftest decode-then-encode-time ()
90 (let ((time-values (list 0 -2 1 0.0 -0.0 -2.0 1.0 90 (let ((time-values (list 0 -2 1 0.0 -0.0 -2.0 1.0
@@ -129,6 +129,12 @@
129 most-negative-fixnum most-positive-fixnum 129 most-negative-fixnum most-positive-fixnum
130 (1- most-negative-fixnum) 130 (1- most-negative-fixnum)
131 (1+ most-positive-fixnum) 131 (1+ most-positive-fixnum)
132 1e1 -1e1 1e-1 -1e-1
133 1e8 -1e8 1e-8 -1e-8
134 1e9 -1e9 1e-9 -1e-9
135 1e10 -1e10 1e-10 -1e-10
136 1e16 -1e16 1e-16 -1e-16
137 1e37 -1e37 1e-37 -1e-37
132 1e+INF -1e+INF 1e+NaN -1e+NaN 138 1e+INF -1e+INF 1e+NaN -1e+NaN
133 '(0 0 0 1) '(0 0 1 0) '(0 1 0 0) '(1 0 0 0) 139 '(0 0 0 1) '(0 0 1 0) '(0 1 0 0) '(1 0 0 0)
134 '(-1 0 0 0) '(1 2 3 4) '(-1 2 3 4) 140 '(-1 0 0 0) '(1 2 3 4) '(-1 2 3 4)