aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorMichael R. Mauger2017-04-02 18:10:57 -0400
committerMichael R. Mauger2017-04-02 18:10:57 -0400
commit77083e2d34ba5559ae2899d3b03cf08c2e6c5ad4 (patch)
tree27da92c2a61d664b700860c2d527a4d36000ca37 /test
parentc5a31f8292c94d19b80a3dbe0b3026693cc1090e (diff)
parent8e394a7f35c2ba9297d222faa2689e177f268924 (diff)
downloademacs-77083e2d34ba5559ae2899d3b03cf08c2e6c5ad4.tar.gz
emacs-77083e2d34ba5559ae2899d3b03cf08c2e6c5ad4.zip
Merge branch 'master' of git.sv.gnu.org:/srv/git/emacs
Diffstat (limited to 'test')
-rw-r--r--test/Makefile.in64
-rw-r--r--test/file-organization.org6
-rw-r--r--test/lisp/dired-x-tests.el53
-rw-r--r--test/lisp/emacs-lisp/cl-lib-tests.el26
-rw-r--r--test/lisp/emacs-lisp/lisp-mode-tests.el4
-rw-r--r--test/lisp/filenotify-tests.el65
-rw-r--r--test/lisp/net/tramp-tests.el18
-rw-r--r--test/lisp/progmodes/js-tests.el37
-rw-r--r--test/lisp/progmodes/python-tests.el19
-rw-r--r--test/lisp/url/url-auth-tests.el51
-rw-r--r--test/lisp/vc/ediff-ptch-tests.el69
-rw-r--r--test/make-test-deps.emacs-lisp98
-rw-r--r--test/src/inotify-tests.el9
13 files changed, 363 insertions, 156 deletions
diff --git a/test/Makefile.in b/test/Makefile.in
index 5849e9c3ac9..a1b772de216 100644
--- a/test/Makefile.in
+++ b/test/Makefile.in
@@ -33,6 +33,7 @@ SHELL = @SHELL@
33srcdir = @srcdir@ 33srcdir = @srcdir@
34VPATH = $(srcdir) 34VPATH = $(srcdir)
35 35
36FIND_DELETE = @FIND_DELETE@
36MKDIR_P = @MKDIR_P@ 37MKDIR_P = @MKDIR_P@
37 38
38SEPCHAR = @SEPCHAR@ 39SEPCHAR = @SEPCHAR@
@@ -123,14 +124,12 @@ endif
123 $(emacs) -l ert -l $$loadfile \ 124 $(emacs) -l ert -l $$loadfile \
124 --eval "(ert-run-tests-batch-and-exit ${SELECTOR_ACTUAL})" ${WRITE_LOG} 125 --eval "(ert-run-tests-batch-and-exit ${SELECTOR_ACTUAL})" ${WRITE_LOG}
125 126
126ELFILES = $(shell find ${srcdir} -path "${srcdir}/manual" -prune -o \ 127ELFILES := $(shell find ${srcdir} -path "${srcdir}/manual" -prune -o \
127 -path "*resources" -prune -o -name "*el" -print) 128 -name "*resources" -prune -o -name "*.el" -print)
128## .elc files may be in a different directory for out of source builds 129## .log files may be in a different directory for out of source builds
129ELCFILES = $(patsubst %.el,%.elc, \ 130LOGFILES := $(patsubst %.el,%.log, \
130 $(patsubst $(srcdir)%,.%,$(ELFILES))) 131 $(patsubst $(srcdir)/%,%,$(ELFILES)))
131LOGFILES = $(patsubst %.elc,%.log,${ELCFILES}) 132TESTS := $(LOGFILES:.log=)
132LOGSAVEFILES = $(patsubst %.elc,%.log~,${ELCFILES})
133TESTS = $(subst ${srcdir}/,,$(LOGFILES:.log=))
134 133
135## If we have to interrupt a hanging test, preserve the log so we can 134## If we have to interrupt a hanging test, preserve the log so we can
136## see what the problem was. 135## see what the problem was.
@@ -138,15 +137,24 @@ TESTS = $(subst ${srcdir}/,,$(LOGFILES:.log=))
138 137
139.PHONY: ${TESTS} 138.PHONY: ${TESTS}
140 139
141## The short aliases that always re-run the tests, with no logging.
142## Define an alias both with and without the directory name for ease
143## of use.
144define test_template 140define test_template
145$(1): 141 ## A test FOO-tests depends on the source file with the similar
146 @test ! -f ./$(1).log || mv ./$(1).log ./$(1).log~ 142 ## name, unless FOO itself contains the string '-tests/'.
147 @${MAKE} ./$(1).log WRITE_LOG= 143 ## The similar name is FOO.c if FOO begins with 'src/', FOO.el
148 144 ## otherwise. Although this heuristic does not identify all the
149$(notdir $(1)): $(1) 145 ## dependencies, it is better than nothing.
146 ifeq (,$(patsubst %-tests,,$(1))$(findstring -tests/,$(1)))
147 $(1).log: $(patsubst %-tests,$(srcdir)/../%,$(1))$(if \
148 $(patsubst src/%,,$(1)),.el,.c)
149 endif
150
151 ## Short aliases that always re-run the tests, with no logging.
152 ## Define both with and without the directory name for ease of use.
153 .PHONY: $(1) $(notdir $(1))
154 $(1):
155 @test ! -f $(1).log || mv $(1).log $(1).log~
156 @$(MAKE) $(1).log WRITE_LOG=
157 $(notdir $(1)): $(1)
150endef 158endef
151 159
152$(foreach test,${TESTS},$(eval $(call test_template,${test}))) 160$(foreach test,${TESTS},$(eval $(call test_template,${test})))
@@ -158,11 +166,6 @@ $(foreach test,${TESTS},$(eval $(call test_template,${test})))
158check-no-automated-subdir: 166check-no-automated-subdir:
159 test ! -d $(srcdir)/automated 167 test ! -d $(srcdir)/automated
160 168
161## Include dependencies between test files and the files they test.
162## We could do this without the file and eval directly, but then we
163## would have to run Emacs for every make invocation, and it might not
164## be available during clean.
165-include make-test-deps.mk
166## Rerun all default tests. 169## Rerun all default tests.
167check: mostlyclean check-no-automated-subdir 170check: mostlyclean check-no-automated-subdir
168 @${MAKE} check-doit SELECTOR="${SELECTOR_ACTUAL}" 171 @${MAKE} check-doit SELECTOR="${SELECTOR_ACTUAL}"
@@ -174,9 +177,7 @@ check-expensive: mostlyclean check-no-automated-subdir
174 177
175## Re-run all tests which are outdated. A test is outdated if its 178## Re-run all tests which are outdated. A test is outdated if its
176## logfile is out-of-date with either the test file, or the source 179## logfile is out-of-date with either the test file, or the source
177## files that the tests depend on. The source file dependencies are 180## files that the tests depend on. See test_template.
178## determined by a heuristic and does not identify the full dependency
179## graph. See make-test-deps.emacs-lisp for details.
180.PHONY: check-maybe 181.PHONY: check-maybe
181check-maybe: check-no-automated-subdir 182check-maybe: check-no-automated-subdir
182 @${MAKE} check-doit SELECTOR="${SELECTOR_ACTUAL}" 183 @${MAKE} check-doit SELECTOR="${SELECTOR_ACTUAL}"
@@ -184,7 +185,7 @@ check-maybe: check-no-automated-subdir
184## Run the tests. 185## Run the tests.
185.PHONY: check-doit 186.PHONY: check-doit
186check-doit: ${LOGFILES} 187check-doit: ${LOGFILES}
187 $(emacs) -l ert -f ert-summarize-tests-batch-and-exit $^ 188 @$(emacs) -l ert -f ert-summarize-tests-batch-and-exit $^
188 189
189.PHONY: mostlyclean clean bootstrap-clean distclean maintainer-clean 190.PHONY: mostlyclean clean bootstrap-clean distclean maintainer-clean
190 191
@@ -193,21 +194,12 @@ mostlyclean:
193 rm -f *.tmp 194 rm -f *.tmp
194 195
195clean: 196clean:
196 -rm -f ${LOGFILES} ${LOGSAVEFILES} 197 find . '(' -name '*.log' -o -name '*.log~' ')' $(FIND_DELETE)
197 -rm make-test-deps.mk
198 198
199bootstrap-clean: clean 199bootstrap-clean: clean
200 -rm -f ${ELCFILES} 200 find $(srcdir) -name '*.elc' $(FIND_DELETE)
201 201
202distclean: clean 202distclean: clean
203 rm -f Makefile 203 rm -f Makefile
204 204
205maintainer-clean: distclean bootstrap-clean 205maintainer-clean: distclean bootstrap-clean
206
207make-test-deps.mk: $(ELFILES) make-test-deps.emacs-lisp
208 $(EMACS) --batch -l $(srcdir)/make-test-deps.emacs-lisp \
209 --eval "(make-test-deps \"$(srcdir)\")" \
210 2> $@.tmp
211 # Hack to elide any CANNOT_DUMP=yes chatter.
212 sed '/\.log: /!d' $@.tmp >$@
213 rm -f $@.tmp
diff --git a/test/file-organization.org b/test/file-organization.org
index 8d9c6716372..4d76c0068e3 100644
--- a/test/file-organization.org
+++ b/test/file-organization.org
@@ -50,9 +50,9 @@ not run by the "make check" command and its derivatives.
50Resource files for tests (containing test data) should reside in a 50Resource files for tests (containing test data) should reside in a
51directory named after the feature with a ~-resources~ suffix, and 51directory named after the feature with a ~-resources~ suffix, and
52located in the same directory as the feature. Hence, the lisp file 52located in the same directory as the feature. Hence, the lisp file
53~flymake.el~ should have test files in 53~lisp/progmodes/flymake.el~, with tests in
54~/test/automated/lisp/progmodes/flymake-tests.el~ should reside in a 54~test/lisp/progmodes/flymake-tests.el~, should have resources in a
55directory called ~/test/automated/lisp/progmodes/flymake-resources~. 55directory called ~test/lisp/progmodes/flymake-resources~.
56 56
57No guidance is given for the organization of resource files inside the 57No guidance is given for the organization of resource files inside the
58~-resource~ directory; files can be organized at the author's 58~-resource~ directory; files can be organized at the author's
diff --git a/test/lisp/dired-x-tests.el b/test/lisp/dired-x-tests.el
new file mode 100644
index 00000000000..e8352a4ecaf
--- /dev/null
+++ b/test/lisp/dired-x-tests.el
@@ -0,0 +1,53 @@
1;;; dired-x-tests.el --- Test suite for dired-x. -*- lexical-binding: t -*-
2
3;; Copyright (C) 2017 Free Software Foundation, Inc.
4
5;; This file is part of GNU Emacs.
6
7;; GNU Emacs is free software: you can redistribute it and/or modify
8;; it under the terms of the GNU General Public License as published by
9;; the Free Software Foundation, either version 3 of the License, or
10;; (at your option) any later version.
11
12;; GNU Emacs is distributed in the hope that it will be useful,
13;; but WITHOUT ANY WARRANTY; without even the implied warranty of
14;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15;; GNU General Public License for more details.
16
17;; You should have received a copy of the GNU General Public License
18;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
19
20;;; Code:
21(require 'ert)
22(require 'dired-x)
23
24
25(ert-deftest dired-test-bug25942 ()
26 "Test for http://debbugs.gnu.org/25942 ."
27 (let* ((dirs (list "Public" "Music"))
28 (files (list ".bashrc" "bar.c" "foo.c" "c" ".c"))
29 (all-but-c
30 (sort
31 (append (copy-sequence dirs)
32 (delete "c" (copy-sequence files)))
33 #'string<))
34 (dir (make-temp-file "Bug25942" 'dir))
35 (extension "c"))
36 (unwind-protect
37 (progn
38 (dolist (d dirs)
39 (make-directory (expand-file-name d dir)))
40 (dolist (f files)
41 (write-region nil nil (expand-file-name f dir)))
42 (dired dir)
43 (dired-mark-extension extension)
44 (should (equal '("bar.c" "foo.c")
45 (sort (dired-get-marked-files 'local) #'string<)))
46 (dired-unmark-all-marks)
47 (dired-mark-suffix extension)
48 (should (equal all-but-c
49 (sort (dired-get-marked-files 'local) #'string<))))
50 (delete-directory dir 'recursive))))
51
52(provide 'dired-x-tests)
53;; dired-x-tests.el ends here
diff --git a/test/lisp/emacs-lisp/cl-lib-tests.el b/test/lisp/emacs-lisp/cl-lib-tests.el
index 5edc3e72bf2..093cb3476c1 100644
--- a/test/lisp/emacs-lisp/cl-lib-tests.el
+++ b/test/lisp/emacs-lisp/cl-lib-tests.el
@@ -493,4 +493,30 @@
493 (should (cl-typep '* 'cl-lib-test-type)) 493 (should (cl-typep '* 'cl-lib-test-type))
494 (should-not (cl-typep 1 'cl-lib-test-type))) 494 (should-not (cl-typep 1 'cl-lib-test-type)))
495 495
496(ert-deftest cl-lib-symbol-macrolet ()
497 ;; bug#26325
498 :expected-result :failed
499 (should (equal (cl-flet ((f (x) (+ x 5)))
500 (let ((x 5))
501 (f (+ x 6))))
502 ;; Go through `eval', otherwise the macro-expansion
503 ;; error prevents running the whole test suite :-(
504 (eval '(cl-symbol-macrolet ((f (+ x 6)))
505 (cl-flet ((f (x) (+ x 5)))
506 (let ((x 5))
507 (f f))))
508 t))))
509
510(defmacro cl-lib-symbol-macrolet-4+5 ()
511 ;; bug#26068
512 (let* ((sname "x")
513 (s1 (make-symbol sname))
514 (s2 (make-symbol sname)))
515 `(cl-symbol-macrolet ((,s1 4)
516 (,s2 5))
517 (+ ,s1 ,s2))))
518
519(ert-deftest cl-lib-symbol-macrolet-2 ()
520 (should (equal (cl-lib-symbol-macrolet-4+5) (+ 4 5))))
521
496;;; cl-lib.el ends here 522;;; cl-lib.el ends here
diff --git a/test/lisp/emacs-lisp/lisp-mode-tests.el b/test/lisp/emacs-lisp/lisp-mode-tests.el
index 2801f23df63..8e3f2e185cf 100644
--- a/test/lisp/emacs-lisp/lisp-mode-tests.el
+++ b/test/lisp/emacs-lisp/lisp-mode-tests.el
@@ -77,6 +77,10 @@ noindent\" 3
77 (search-backward "d2") 77 (search-backward "d2")
78 (up-list -1) 78 (up-list -1)
79 (indent-sexp) 79 (indent-sexp)
80 (should (equal (buffer-string) correct))
81 (backward-sexp)
82 (end-of-line)
83 (indent-sexp)
80 (should (equal (buffer-string) correct))))) 84 (should (equal (buffer-string) correct)))))
81 85
82(ert-deftest indent-sexp-in-string () 86(ert-deftest indent-sexp-in-string ()
diff --git a/test/lisp/filenotify-tests.el b/test/lisp/filenotify-tests.el
index 72080322379..54e7ebfc0e5 100644
--- a/test/lisp/filenotify-tests.el
+++ b/test/lisp/filenotify-tests.el
@@ -294,13 +294,20 @@ This returns only for the local case and gfilenotify; otherwise it is nil.
294 (file-notify-add-watch 294 (file-notify-add-watch
295 temporary-file-directory '(change attribute-change) #'ignore))) 295 temporary-file-directory '(change attribute-change) #'ignore)))
296 (file-notify-rm-watch file-notify--test-desc) 296 (file-notify-rm-watch file-notify--test-desc)
297 (write-region "any text" nil file-notify--test-tmpfile nil 'no-message) 297
298 ;; File monitors like kqueue insist, that the watched file
299 ;; exists. Directory monitors are not bound to this
300 ;; restriction.
301 (when (string-equal (file-notify--test-library) "kqueue")
302 (write-region
303 "any text" nil file-notify--test-tmpfile nil 'no-message))
298 (should 304 (should
299 (setq file-notify--test-desc 305 (setq file-notify--test-desc
300 (file-notify-add-watch 306 (file-notify-add-watch
301 file-notify--test-tmpfile '(change attribute-change) #'ignore))) 307 file-notify--test-tmpfile '(change attribute-change) #'ignore)))
302 (file-notify-rm-watch file-notify--test-desc) 308 (file-notify-rm-watch file-notify--test-desc)
303 (delete-file file-notify--test-tmpfile) 309 (when (string-equal (file-notify--test-library) "kqueue")
310 (delete-file file-notify--test-tmpfile))
304 311
305 ;; Check error handling. 312 ;; Check error handling.
306 (should-error (file-notify-add-watch 1 2 3 4) 313 (should-error (file-notify-add-watch 1 2 3 4)
@@ -340,20 +347,19 @@ This returns only for the local case and gfilenotify; otherwise it is nil.
340 (expand-file-name 347 (expand-file-name
341 (make-temp-name "file-notify-test") temporary-file-directory)) 348 (make-temp-name "file-notify-test") temporary-file-directory))
342 349
343;; This test is inspired by Bug#26127. 350;; This test is inspired by Bug#26126 and Bug#26127.
344(ert-deftest file-notify-test02-rm-watch () 351(ert-deftest file-notify-test02-rm-watch ()
345 "Check `file-notify-rm-watch'." 352 "Check `file-notify-rm-watch'."
346 (skip-unless (file-notify--test-local-enabled)) 353 (skip-unless (file-notify--test-local-enabled))
347 354
348 (unwind-protect 355 (unwind-protect
356 ;; Check, that `file-notify-rm-watch' works.
349 (progn 357 (progn
350 ;; Check, that `file-notify-rm-watch' works.
351 (should 358 (should
352 (setq file-notify--test-desc 359 (setq file-notify--test-desc
353 (file-notify-add-watch 360 (file-notify-add-watch
354 temporary-file-directory '(change) #'ignore))) 361 temporary-file-directory '(change) #'ignore)))
355 (file-notify-rm-watch file-notify--test-desc) 362 (file-notify-rm-watch file-notify--test-desc)
356
357 ;; Check, that any parameter is accepted. 363 ;; Check, that any parameter is accepted.
358 (condition-case err 364 (condition-case err
359 (progn 365 (progn
@@ -363,9 +369,19 @@ This returns only for the local case and gfilenotify; otherwise it is nil.
363 (file-notify-rm-watch 'foo)) 369 (file-notify-rm-watch 'foo))
364 (error (ert-fail err))) 370 (error (ert-fail err)))
365 371
366 ;; Check, that no error is returned removing a watch descriptor twice. 372 ;; The environment shall be cleaned up.
373 (file-notify--test-cleanup-p))
374
375 ;; Cleanup.
376 (file-notify--test-cleanup))
377
378 (unwind-protect
379 ;; Check, that no error is returned removing a watch descriptor twice.
380 (progn
367 (setq file-notify--test-tmpfile (file-notify--test-make-temp-name) 381 (setq file-notify--test-tmpfile (file-notify--test-make-temp-name)
368 file-notify--test-tmpfile1 (file-notify--test-make-temp-name)) 382 file-notify--test-tmpfile1 (file-notify--test-make-temp-name))
383 (write-region "any text" nil file-notify--test-tmpfile nil 'no-message)
384 (write-region "any text" nil file-notify--test-tmpfile1 nil 'no-message)
369 (should 385 (should
370 (setq file-notify--test-desc 386 (setq file-notify--test-desc
371 (file-notify-add-watch 387 (file-notify-add-watch
@@ -374,14 +390,51 @@ This returns only for the local case and gfilenotify; otherwise it is nil.
374 (setq file-notify--test-desc1 390 (setq file-notify--test-desc1
375 (file-notify-add-watch 391 (file-notify-add-watch
376 file-notify--test-tmpfile1 '(change) #'ignore))) 392 file-notify--test-tmpfile1 '(change) #'ignore)))
393 ;; Remove `file-notify--test-desc' twice.
377 (file-notify-rm-watch file-notify--test-desc) 394 (file-notify-rm-watch file-notify--test-desc)
378 (file-notify-rm-watch file-notify--test-desc) 395 (file-notify-rm-watch file-notify--test-desc)
379 (file-notify-rm-watch file-notify--test-desc1) 396 (file-notify-rm-watch file-notify--test-desc1)
397 (delete-file file-notify--test-tmpfile)
398 (delete-file file-notify--test-tmpfile1)
380 399
381 ;; The environment shall be cleaned up. 400 ;; The environment shall be cleaned up.
382 (file-notify--test-cleanup-p)) 401 (file-notify--test-cleanup-p))
383 402
384 ;; Cleanup. 403 ;; Cleanup.
404 (file-notify--test-cleanup))
405
406 (unwind-protect
407 ;; Check, that removing watch descriptors out of order do not harm.
408 (let (results)
409 (cl-flet ((first-callback (event)
410 (when (eq (nth 1 event) 'deleted) (push 1 results)))
411 (second-callback (event)
412 (when (eq (nth 1 event) 'deleted) (push 2 results))))
413 (setq file-notify--test-tmpfile (file-notify--test-make-temp-name))
414 (write-region
415 "any text" nil file-notify--test-tmpfile nil 'no-message)
416 (should
417 (setq file-notify--test-desc
418 (file-notify-add-watch
419 file-notify--test-tmpfile
420 '(change) #'first-callback)))
421 (should
422 (setq file-notify--test-desc1
423 (file-notify-add-watch
424 file-notify--test-tmpfile
425 '(change) #'second-callback)))
426 ;; Remove first watch.
427 (file-notify-rm-watch file-notify--test-desc)
428 ;; Only the second callback shall run.
429 (delete-file file-notify--test-tmpfile)
430 (file-notify--wait-for-events
431 (file-notify--test-timeout) results)
432 (should (equal results (list 2)))
433
434 ;; The environment shall be cleaned up.
435 (file-notify--test-cleanup-p)))
436
437 ;; Cleanup.
385 (file-notify--test-cleanup))) 438 (file-notify--test-cleanup)))
386 439
387(file-notify--deftest-remote file-notify-test02-rm-watch 440(file-notify--deftest-remote file-notify-test02-rm-watch
diff --git a/test/lisp/net/tramp-tests.el b/test/lisp/net/tramp-tests.el
index 45b4ff2f5ab..2a4ef740a04 100644
--- a/test/lisp/net/tramp-tests.el
+++ b/test/lisp/net/tramp-tests.el
@@ -1,4 +1,4 @@
1;;; tramp-tests.el --- Tests of remote file access 1;;; tramp-tests.el --- Tests of remote file access -*- lexical-binding:t -*-
2 2
3;; Copyright (C) 2013-2017 Free Software Foundation, Inc. 3;; Copyright (C) 2013-2017 Free Software Foundation, Inc.
4 4
@@ -37,6 +37,7 @@
37 37
38;;; Code: 38;;; Code:
39 39
40(require 'dired)
40(require 'ert) 41(require 'ert)
41(require 'tramp) 42(require 'tramp)
42(require 'vc) 43(require 'vc)
@@ -44,11 +45,11 @@
44(require 'vc-git) 45(require 'vc-git)
45(require 'vc-hg) 46(require 'vc-hg)
46 47
47(autoload 'dired-uncache "dired")
48(declare-function tramp-find-executable "tramp-sh") 48(declare-function tramp-find-executable "tramp-sh")
49(declare-function tramp-get-remote-path "tramp-sh") 49(declare-function tramp-get-remote-path "tramp-sh")
50(declare-function tramp-get-remote-stat "tramp-sh") 50(declare-function tramp-get-remote-stat "tramp-sh")
51(declare-function tramp-get-remote-perl "tramp-sh") 51(declare-function tramp-get-remote-perl "tramp-sh")
52(defvar auto-save-file-name-transforms)
52(defvar tramp-copy-size-limit) 53(defvar tramp-copy-size-limit)
53(defvar tramp-persistency-file-name) 54(defvar tramp-persistency-file-name)
54(defvar tramp-remote-process-environment) 55(defvar tramp-remote-process-environment)
@@ -2083,17 +2084,20 @@ This tests also `make-symbolic-link', `file-truename' and `add-name-to-file'."
2083 (skip-unless 2084 (skip-unless
2084 (and (fboundp 'make-nearby-temp-file) (fboundp 'temporary-file-directory))) 2085 (and (fboundp 'make-nearby-temp-file) (fboundp 'temporary-file-directory)))
2085 2086
2087 ;; `make-nearby-temp-file' and `temporary-file-directory' exists
2088 ;; since Emacs 26. We don't want to see compiler warnings for older
2089 ;; Emacsen."
2086 (let ((default-directory tramp-test-temporary-file-directory) 2090 (let ((default-directory tramp-test-temporary-file-directory)
2087 tmp-file) 2091 tmp-file)
2088 ;; The remote host shall know a temporary file directory. 2092 ;; The remote host shall know a temporary file directory.
2089 (should (stringp (temporary-file-directory))) 2093 (should (stringp (with-no-warnings (temporary-file-directory))))
2090 (should 2094 (should
2091 (string-equal 2095 (string-equal
2092 (file-remote-p default-directory) 2096 (file-remote-p default-directory)
2093 (file-remote-p (temporary-file-directory)))) 2097 (file-remote-p (with-no-warnings (temporary-file-directory)))))
2094 2098
2095 ;; The temporary file shall be located on the remote host. 2099 ;; The temporary file shall be located on the remote host.
2096 (setq tmp-file (make-nearby-temp-file "tramp-test")) 2100 (setq tmp-file (with-no-warnings (make-nearby-temp-file "tramp-test")))
2097 (should (file-exists-p tmp-file)) 2101 (should (file-exists-p tmp-file))
2098 (should (file-regular-p tmp-file)) 2102 (should (file-regular-p tmp-file))
2099 (should 2103 (should
@@ -2103,7 +2107,7 @@ This tests also `make-symbolic-link', `file-truename' and `add-name-to-file'."
2103 (delete-file tmp-file) 2107 (delete-file tmp-file)
2104 (should-not (file-exists-p tmp-file)) 2108 (should-not (file-exists-p tmp-file))
2105 2109
2106 (setq tmp-file (make-nearby-temp-file "tramp-test" 'dir)) 2110 (setq tmp-file (with-no-warnings (make-nearby-temp-file "tramp-test" 'dir)))
2107 (should (file-exists-p tmp-file)) 2111 (should (file-exists-p tmp-file))
2108 (should (file-directory-p tmp-file)) 2112 (should (file-directory-p tmp-file))
2109 (delete-directory tmp-file) 2113 (delete-directory tmp-file)
@@ -2582,7 +2586,7 @@ process sentinels. They shall not disturb each other."
2582 ;; Create temporary buffers. The number of buffers 2586 ;; Create temporary buffers. The number of buffers
2583 ;; corresponds to the number of processes; it could be 2587 ;; corresponds to the number of processes; it could be
2584 ;; increased in order to make pressure on Tramp. 2588 ;; increased in order to make pressure on Tramp.
2585 (dotimes (i 5) 2589 (dotimes (_i 5)
2586 (add-to-list 'buffers (generate-new-buffer "*temp*"))) 2590 (add-to-list 'buffers (generate-new-buffer "*temp*")))
2587 2591
2588 ;; Open asynchronous processes. Set process sentinel. 2592 ;; Open asynchronous processes. Set process sentinel.
diff --git a/test/lisp/progmodes/js-tests.el b/test/lisp/progmodes/js-tests.el
index e030675e07c..8e1bac10cd1 100644
--- a/test/lisp/progmodes/js-tests.el
+++ b/test/lisp/progmodes/js-tests.el
@@ -140,6 +140,43 @@ if (!/[ (:,='\"]/.test(value)) {
140 (font-lock-ensure) 140 (font-lock-ensure)
141 (should (eq (get-text-property (point) 'face) (caddr test)))))) 141 (should (eq (get-text-property (point) 'face) (caddr test))))))
142 142
143(ert-deftest js-mode-propertize-bug-1 ()
144 (with-temp-buffer
145 (js-mode)
146 (save-excursion (insert "x"))
147 (insert "/")
148 ;; The bug was a hang.
149 (should t)))
150
151(ert-deftest js-mode-propertize-bug-2 ()
152 (with-temp-buffer
153 (js-mode)
154 (insert "function f() {
155 function g()
156 {
157 1 / 2;
158 }
159
160 function h() {
161")
162 (save-excursion
163 (insert "
164 00000000000000000000000000000000000000000000000000;
165 00000000000000000000000000000000000000000000000000;
166 00000000000000000000000000000000000000000000000000;
167 00000000000000000000000000000000000000000000000000;
168 00000000000000000000000000000000000000000000000000;
169 00000000000000000000000000000000000000000000000000;
170 00000000000000000000000000000000000000000000000000;
171 00000000000000000000000000000000000000000000000000;
172 00;
173 }
174}
175"))
176 (insert "/")
177 ;; The bug was a hang.
178 (should t)))
179
143(provide 'js-tests) 180(provide 'js-tests)
144 181
145;;; js-tests.el ends here 182;;; js-tests.el ends here
diff --git a/test/lisp/progmodes/python-tests.el b/test/lisp/progmodes/python-tests.el
index 1e6b867d30b..2f4c2fb849d 100644
--- a/test/lisp/progmodes/python-tests.el
+++ b/test/lisp/progmodes/python-tests.el
@@ -5314,6 +5314,25 @@ class SomeClass:
5314 (or enabled (hs-minor-mode -1))))) 5314 (or enabled (hs-minor-mode -1)))))
5315 5315
5316 5316
5317(ert-deftest python-tests--python-nav-end-of-statement--infloop ()
5318 "Checks that `python-nav-end-of-statement' doesn't infloop in a
5319buffer with overlapping strings."
5320 (python-tests-with-temp-buffer "''' '\n''' ' '\n"
5321 (syntax-propertize (point-max))
5322 ;; Create a situation where strings nominally overlap. This
5323 ;; shouldn't happen in practice, but apparently it can happen when
5324 ;; a package calls `syntax-ppss' in a narrowed buffer during JIT
5325 ;; lock.
5326 (put-text-property 4 5 'syntax-table (string-to-syntax "|"))
5327 (remove-text-properties 8 9 '(syntax-table nil))
5328 (goto-char 4)
5329 (setq-local syntax-propertize-function nil)
5330 ;; The next form should not infloop. We have to disable
5331 ;; ‘debug-on-error’ so that ‘cl-assert’ doesn’t call the debugger.
5332 (should-error (let ((debug-on-error nil))
5333 (python-nav-end-of-statement)))
5334 (should (eolp))))
5335
5317 5336
5318(provide 'python-tests) 5337(provide 'python-tests)
5319 5338
diff --git a/test/lisp/url/url-auth-tests.el b/test/lisp/url/url-auth-tests.el
index 11e5a479720..30636db083c 100644
--- a/test/lisp/url/url-auth-tests.el
+++ b/test/lisp/url/url-auth-tests.el
@@ -77,6 +77,49 @@ server's WWW-Authenticate header field.")
77 :expected-ha2 "b44272ea65ee4af7fb26c5dba58f6863" 77 :expected-ha2 "b44272ea65ee4af7fb26c5dba58f6863"
78 :expected-response "0d84884d967e04440efc77e9e2b5b561"))) 78 :expected-response "0d84884d967e04440efc77e9e2b5b561")))
79 79
80(ert-deftest url-auth-test-colonjoin ()
81 "Check joining strings with `:'."
82 (should (string= (url-digest-auth-colonjoin) ""))
83 (should (string= (url-digest-auth-colonjoin nil) ""))
84 (should (string= (url-digest-auth-colonjoin nil nil nil) "::"))
85 (should (string= (url-digest-auth-colonjoin "") ""))
86 (should (string= (url-digest-auth-colonjoin "" "") ":"))
87 (should (string= (url-digest-auth-colonjoin "one") "one"))
88 (should (string= (url-digest-auth-colonjoin "one" "two" "three") "one:two:three")))
89
90(ert-deftest url-auth-test-digest-ha1 ()
91 "Check HA1 computation."
92 (dolist (row url-auth-test-challenges)
93 (should (string= (url-digest-auth-make-ha1 (plist-get row :username)
94 (plist-get row :realm)
95 (plist-get row :password))
96 (plist-get row :expected-ha1)
97 ))))
98
99(ert-deftest url-auth-test-digest-ha2 ()
100 "Check HA2 computation."
101 (dolist (row url-auth-test-challenges)
102 (should (string= (url-digest-auth-make-ha2 (plist-get row :method)
103 (plist-get row :uri))
104 (plist-get row :expected-ha2)))))
105
106(ert-deftest url-auth-test-digest-request-digest ()
107 "Check digest response value."
108 (dolist (row url-auth-test-challenges)
109 (should (string= (plist-get row :expected-response)
110 (if (plist-member row :qop)
111 (url-digest-auth-make-request-digest-qop
112 (plist-get row :qop)
113 (plist-get row :expected-ha1)
114 (plist-get row :expected-ha2)
115 (plist-get row :nonce)
116 (plist-get row :nc)
117 (plist-get row :cnonce))
118 (url-digest-auth-make-request-digest
119 (plist-get row :expected-ha1)
120 (plist-get row :expected-ha2)
121 (plist-get row :nonce)))))))
122
80(ert-deftest url-auth-test-digest-create-key () 123(ert-deftest url-auth-test-digest-create-key ()
81 "Check user credentials in their hashed form." 124 "Check user credentials in their hashed form."
82 (dolist (challenge url-auth-test-challenges) 125 (dolist (challenge url-auth-test-challenges)
@@ -223,14 +266,12 @@ test and cannot be passed by arguments to `url-digest-auth'."
223 (progn 266 (progn
224 ;; We don't know these, just check that they exists. 267 ;; We don't know these, just check that they exists.
225 (should (string-match-p ".*response=\".*?\".*" auth)) 268 (should (string-match-p ".*response=\".*?\".*" auth))
226 ;; url-digest-auth doesn't return these AFAICS. 269 (should (string-match-p ".*nc=\".*?\".*" auth))
227;;; (should (string-match-p ".*nc=\".*?\".*" auth)) 270 (should (string-match-p ".*cnonce=\".*?\".*" auth)))
228;;; (should (string-match-p ".*cnonce=\".*?\".*" auth))
229 )
230 (should (string-match ".*response=\"\\(.*?\\)\".*" auth)) 271 (should (string-match ".*response=\"\\(.*?\\)\".*" auth))
231 (should (string= (match-string 1 auth) 272 (should (string= (match-string 1 auth)
232 (plist-get challenge :expected-response)))) 273 (plist-get challenge :expected-response))))
233 ))) 274 )))
234 275
235(ert-deftest url-auth-test-digest-auth-opaque () 276(ert-deftest url-auth-test-digest-auth-opaque ()
236 "Check that `opaque' value is added to result when presented by 277 "Check that `opaque' value is added to result when presented by
diff --git a/test/lisp/vc/ediff-ptch-tests.el b/test/lisp/vc/ediff-ptch-tests.el
index 912c6b1e818..387786ced06 100644
--- a/test/lisp/vc/ediff-ptch-tests.el
+++ b/test/lisp/vc/ediff-ptch-tests.el
@@ -22,7 +22,7 @@
22(require 'ert) 22(require 'ert)
23(require 'ediff-ptch) 23(require 'ediff-ptch)
24 24
25(ert-deftest ibuffer-test-bug25010 () 25(ert-deftest ediff-ptch-test-bug25010 ()
26 "Test for http://debbugs.gnu.org/25010 ." 26 "Test for http://debbugs.gnu.org/25010 ."
27 (with-temp-buffer 27 (with-temp-buffer
28 (insert "diff --git a/lisp/vc/ediff-ptch.el b/lisp/vc/ediff-ptch.el 28 (insert "diff --git a/lisp/vc/ediff-ptch.el b/lisp/vc/ediff-ptch.el
@@ -38,5 +38,72 @@ index 6a07f80..6e8e947 100644
38 (match-string 1)))) 38 (match-string 1))))
39 (should-not (string-suffix-p "@@" filename))))) 39 (should-not (string-suffix-p "@@" filename)))))
40 40
41
42(ert-deftest ediff-ptch-test-bug26084 ()
43 "Test for http://debbugs.gnu.org/26084 ."
44 (skip-unless (executable-find "git"))
45 (skip-unless (executable-find ediff-patch-program))
46 (let* ((tmpdir (make-temp-file "ediff-ptch-test" t))
47 (default-directory (file-name-as-directory tmpdir))
48 (patch (make-temp-file "ediff-ptch-test"))
49 (qux (expand-file-name "qux.txt" tmpdir))
50 (bar (expand-file-name "bar.txt" tmpdir))
51 (git-program (executable-find "git")))
52 ;; Create repository.
53 (with-temp-buffer
54 (insert "qux here\n")
55 (write-region nil nil qux nil 'silent)
56 (erase-buffer)
57 (insert "bar here\n")
58 (write-region nil nil bar nil 'silent))
59 (call-process git-program nil nil nil "init")
60 (call-process git-program nil nil nil "add" ".")
61 (call-process git-program nil nil nil "commit" "-m" "Test repository.")
62 ;; Update repo., save the diff and reset to initial state.
63 (with-temp-buffer
64 (insert "foo here\n")
65 (write-region nil nil qux nil 'silent)
66 (write-region nil nil bar nil 'silent))
67 (call-process git-program nil `(:file ,patch) nil "diff")
68 (call-process git-program nil nil nil "reset" "--hard" "HEAD")
69 (find-file patch)
70 (unwind-protect
71 (let* ((info
72 (progn (ediff-map-patch-buffer (current-buffer)) ediff-patch-map))
73 (patch1
74 (buffer-substring-no-properties
75 (car (nth 3 (car info)))
76 (car (nth 4 (car info)))))
77 (patch2
78 (buffer-substring-no-properties
79 (car (nth 3 (cadr info)))
80 (car (nth 4 (cadr info))))))
81 ;; Apply both patches.
82 (dolist (x (list (cons patch1 bar) (cons patch2 qux)))
83 (with-temp-buffer
84 (insert (car x))
85 (call-process-region (point-min)
86 (point-max)
87 ediff-patch-program
88 nil nil nil
89 "-b" (cdr x))))
90 ;; Check backup files were saved correctly.
91 (dolist (x (list qux bar))
92 (let ((backup
93 (car
94 (directory-files
95 tmpdir 'full
96 (concat (file-name-nondirectory x) ".")))))
97 (should-not
98 (string= (with-temp-buffer
99 (insert-file-contents x)
100 (buffer-string))
101 (with-temp-buffer
102 (insert-file-contents backup)
103 (buffer-string))))))
104 (delete-directory tmpdir 'recursive)
105 (delete-file patch)))))
106
107
41(provide 'ediff-ptch-tests) 108(provide 'ediff-ptch-tests)
42;;; ediff-ptch-tests.el ends here 109;;; ediff-ptch-tests.el ends here
diff --git a/test/make-test-deps.emacs-lisp b/test/make-test-deps.emacs-lisp
deleted file mode 100644
index 609e9276186..00000000000
--- a/test/make-test-deps.emacs-lisp
+++ /dev/null
@@ -1,98 +0,0 @@
1;; -*- emacs-lisp -*-
2
3;; Copyright (C) 2015-2017 Free Software Foundation, Inc.
4
5;; This file is part of GNU Emacs.
6
7;; GNU Emacs is free software: you can redistribute it and/or modify
8;; it under the terms of the GNU General Public License as published by
9;; the Free Software Foundation, either version 3 of the License, or
10;; (at your option) any later version.
11
12;; GNU Emacs is distributed in the hope that it will be useful,
13;; but WITHOUT ANY WARRANTY; without even the implied warranty of
14;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15;; GNU General Public License for more details.
16
17;; You should have received a copy of the GNU General Public License
18;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
19
20;;; Commentary:
21
22;; This file generates dependencies between test files and the files
23;; that they test.
24
25;; It has an .emacs-lisp extension because it makes the Makefile easier!
26
27(require 'seq)
28
29(defun make-test-deps (src-dir)
30 (let ((src-dir (file-truename src-dir)))
31 (message
32 "%s"
33 (concat
34 (make-test-deps-lisp src-dir)
35 (make-test-deps-src src-dir)))))
36
37(defun make-test-deps-lisp (src-dir)
38 (mapconcat
39 (lambda (file-without-suffix)
40 (format "./%s-tests.log: %s/../%s.el\n"
41 file-without-suffix
42 src-dir
43 file-without-suffix))
44 (make-test-test-files src-dir "lisp") ""))
45
46(defun make-test-deps-src (src-dir)
47 (mapconcat
48 (lambda (file-without-suffix)
49 (format "./%s-tests.log: %s/../%s.c\n"
50 file-without-suffix
51 src-dir
52 file-without-suffix))
53 (make-test-test-files src-dir "src") ""))
54
55(defun make-test-test-files (src-dir sub-src-dir)
56 (make-test-munge-files
57 src-dir
58 (directory-files-recursively
59 (concat src-dir "/" sub-src-dir)
60 ".*-tests.el$")))
61
62(defun make-test-munge-files (src-dir files)
63 (make-test-sans-suffix
64 (make-test-de-stem
65 src-dir
66 (make-test-no-legacy
67 (make-test-no-test-dir
68 (make-test-no-resources
69 files))))))
70
71(defun make-test-sans-suffix (files)
72 (mapcar
73 (lambda (file)
74 (substring file 0 -9))
75 files))
76
77(defun make-test-de-stem (stem files)
78 (mapcar
79 (lambda (file)
80 (substring
81 file
82 (+ 1 (length stem))))
83 files))
84
85(defun make-test-no-legacy (list)
86 (make-test-remove list "legacy/"))
87
88(defun make-test-no-resources (list)
89 (make-test-remove list "-resources/"))
90
91(defun make-test-no-test-dir (list)
92 (make-test-remove list "-tests/"))
93
94(defun make-test-remove (list match)
95 (seq-remove
96 (lambda (file)
97 (string-match-p match file))
98 list))
diff --git a/test/src/inotify-tests.el b/test/src/inotify-tests.el
index f30aecc9c4f..987e1fc0777 100644
--- a/test/src/inotify-tests.el
+++ b/test/src/inotify-tests.el
@@ -28,6 +28,13 @@
28(declare-function inotify-add-watch "inotify.c" (file-name aspect callback)) 28(declare-function inotify-add-watch "inotify.c" (file-name aspect callback))
29(declare-function inotify-rm-watch "inotify.c" (watch-descriptor)) 29(declare-function inotify-rm-watch "inotify.c" (watch-descriptor))
30 30
31(ert-deftest inotify-valid-p-simple ()
32 "Simple tests for `inotify-valid-p'."
33 (skip-unless (featurep 'inotify))
34 (should-not (inotify-valid-p 0))
35 (should-not (inotify-valid-p nil))
36 (should-not (inotify-valid-p '(0 . 0))))
37
31;; (ert-deftest filewatch-file-watch-aspects-check () 38;; (ert-deftest filewatch-file-watch-aspects-check ()
32;; "Test whether `file-watch' properly checks the aspects." 39;; "Test whether `file-watch' properly checks the aspects."
33;; (let ((temp-file (make-temp-file "filewatch-aspects"))) 40;; (let ((temp-file (make-temp-file "filewatch-aspects")))
@@ -56,7 +63,9 @@
56 (insert "Foo\n")) 63 (insert "Foo\n"))
57 (read-event nil nil 5) 64 (read-event nil nil 5)
58 (should (> events 0))) 65 (should (> events 0)))
66 (should (inotify-valid-p wd))
59 (inotify-rm-watch wd) 67 (inotify-rm-watch wd)
68 (should-not (inotify-valid-p wd))
60 (delete-file temp-file))))) 69 (delete-file temp-file)))))
61 70
62(provide 'inotify-tests) 71(provide 'inotify-tests)