diff options
author | Andrea Corallo <akrl@sdf.org> | 2021-01-16 13:26:10 +0100 |
---|---|---|
committer | Andrea Corallo <akrl@sdf.org> | 2021-01-16 13:26:10 +0100 |
commit | 0a7ac0b5504e75275699a3d8d2d5d94bcfda8708 (patch) | |
tree | bb6158c8a9edeb1e716718abfc98dca16aef9e9e /test/lisp | |
parent | f1efac1f9efbfa15b6434ebef507c00c1277633f (diff) | |
parent | 0732fc31932c75c682c8b65b4dcb4376ca63e8fd (diff) | |
download | emacs-0a7ac0b5504e75275699a3d8d2d5d94bcfda8708.tar.gz emacs-0a7ac0b5504e75275699a3d8d2d5d94bcfda8708.tar.bz2 emacs-0a7ac0b5504e75275699a3d8d2d5d94bcfda8708.zip |
Merge remote-tracking branch 'savannah/master' into native-comp
Diffstat (limited to 'test/lisp')
-rw-r--r-- | test/lisp/calendar/lunar-tests.el | 38 | ||||
-rw-r--r-- | test/lisp/calendar/solar-tests.el | 4 | ||||
-rw-r--r-- | test/lisp/cedet/semantic-utest.el | 6 | ||||
-rw-r--r-- | test/lisp/cedet/srecode-utest-getset.el | 1 | ||||
-rw-r--r-- | test/lisp/cedet/srecode-utest-template.el | 6 | ||||
-rw-r--r-- | test/lisp/emacs-lisp/cl-macs-tests.el | 23 | ||||
-rw-r--r-- | test/lisp/emacs-lisp/timer-tests.el | 4 | ||||
-rw-r--r-- | test/lisp/gnus/mm-decode-resources/win1252-multipart.bin | 44 | ||||
-rw-r--r-- | test/lisp/gnus/mm-decode-tests.el | 35 | ||||
-rw-r--r-- | test/lisp/help-mode-tests.el | 21 | ||||
-rw-r--r-- | test/lisp/help-tests.el | 4 | ||||
-rw-r--r-- | test/lisp/net/nsm-tests.el | 8 | ||||
-rw-r--r-- | test/lisp/net/socks-tests.el | 103 | ||||
-rw-r--r-- | test/lisp/net/tramp-tests.el | 197 | ||||
-rw-r--r-- | test/lisp/progmodes/tcl-tests.el | 14 | ||||
-rw-r--r-- | test/lisp/subr-tests.el | 20 | ||||
-rw-r--r-- | test/lisp/textmodes/fill-tests.el | 31 |
17 files changed, 434 insertions, 125 deletions
diff --git a/test/lisp/calendar/lunar-tests.el b/test/lisp/calendar/lunar-tests.el index 5f1f6782f1a..268dcfdb550 100644 --- a/test/lisp/calendar/lunar-tests.el +++ b/test/lisp/calendar/lunar-tests.el @@ -27,39 +27,37 @@ (defmacro with-lunar-test (&rest body) `(let ((calendar-latitude 40.1) (calendar-longitude -88.2) - (calendar-location-name "Urbana, IL") - (calendar-time-zone -360) - (calendar-standard-time-zone-name "CST") - (calendar-time-display-form '(12-hours ":" minutes am-pm))) + (calendar-location-name "Paris") + (calendar-time-zone 0) + (calendar-standard-time-zone-name "UTC") + ;; Make sure daylight saving is disabled to avoid interference + ;; from the system settings (see bug#45818). + (calendar-daylight-savings-starts nil) + (calendar-time-display-form '(24-hours ":" minutes))) ,@body)) (ert-deftest lunar-test-phase () (with-lunar-test (should (equal (lunar-phase 1) - '((1 7 1900) "11:40pm" 1 ""))))) + '((1 8 1900) "05:40" 1 ""))))) (ert-deftest lunar-test-eclipse-check () (with-lunar-test (should (equal (eclipse-check 1 1) "** Eclipse **")))) -;; This fails in certain time zones. -;; Eg TZ=America/Phoenix make lisp/calendar/lunar-tests -;; Similarly with TZ=UTC. -;; Daylight saving related? (ert-deftest lunar-test-phase-list () - :tags '(:unstable) (with-lunar-test (should (equal (lunar-phase-list 3 1871) - '(((3 20 1871) "11:03pm" 0 "") - ((3 29 1871) "1:46am" 1 "** Eclipse **") - ((4 5 1871) "9:20am" 2 "") - ((4 12 1871) "12:57am" 3 "** Eclipse possible **") - ((4 19 1871) "2:06pm" 0 "") - ((4 27 1871) "6:49pm" 1 "") - ((5 4 1871) "5:57pm" 2 "") - ((5 11 1871) "9:29am" 3 "") - ((5 19 1871) "5:46am" 0 "") - ((5 27 1871) "8:02am" 1 "")))))) + '(((3 21 1871) "04:03" 0 "") + ((3 29 1871) "06:46" 1 "** Eclipse **") + ((4 5 1871) "14:20" 2 "") + ((4 12 1871) "05:57" 3 "** Eclipse possible **") + ((4 19 1871) "19:06" 0 "") + ((4 27 1871) "23:49" 1 "") + ((5 4 1871) "22:57" 2 "") + ((5 11 1871) "14:29" 3 "") + ((5 19 1871) "10:46" 0 "") + ((5 27 1871) "13:02" 1 "")))))) (ert-deftest lunar-test-new-moon-time () (with-lunar-test diff --git a/test/lisp/calendar/solar-tests.el b/test/lisp/calendar/solar-tests.el index 7a37f8db558..337deb8ce9a 100644 --- a/test/lisp/calendar/solar-tests.el +++ b/test/lisp/calendar/solar-tests.el @@ -26,7 +26,9 @@ (calendar-longitude 75.8) (calendar-time-zone +330) (calendar-standard-time-zone-name "IST") - (calendar-daylight-time-zone-name "IST") + ;; Make sure our clockwork isn't confused by daylight saving rules + ;; in effect for any other time zone (bug#45818). + (calendar-daylight-savings-starts nil) (epsilon (/ 60.0))) ; Minute accuracy is good enough. (let* ((sunrise-sunset (solar-sunrise-sunset '(12 30 2020))) (sunrise (car (nth 0 sunrise-sunset))) diff --git a/test/lisp/cedet/semantic-utest.el b/test/lisp/cedet/semantic-utest.el index c0099386f1c..67de4a5b02d 100644 --- a/test/lisp/cedet/semantic-utest.el +++ b/test/lisp/cedet/semantic-utest.el @@ -577,10 +577,8 @@ INSERTME is the text to be inserted after the deletion." (ert-deftest semantic-utest-Javascript() - (if (fboundp 'javascript-mode) - (semantic-utest-generic (semantic-utest-fname "javascripttest.js") semantic-utest-Javascript-buffer-contents semantic-utest-Javascript-name-contents '("fun2") "//1" "//deleted line") - (message "Skipping JavaScript test: NO major mode.")) - ) + (skip-unless (fboundp 'javascript-mode)) + (semantic-utest-generic (semantic-utest-fname "javascripttest.js") semantic-utest-Javascript-buffer-contents semantic-utest-Javascript-name-contents '("fun2") "//1" "//deleted line")) (ert-deftest semantic-utest-Java() ;; If JDE is installed, it might mess things up depending on the version diff --git a/test/lisp/cedet/srecode-utest-getset.el b/test/lisp/cedet/srecode-utest-getset.el index 0497dea505d..1c6578038c0 100644 --- a/test/lisp/cedet/srecode-utest-getset.el +++ b/test/lisp/cedet/srecode-utest-getset.el @@ -128,7 +128,6 @@ private: (srecode-utest-getset-jumptotag "miscFunction")) (let ((pos (point))) - (skip-chars-backward " \t\n") ; xemacs forward-comment is different. (forward-comment -1) (re-search-forward "miscFunction" pos)) diff --git a/test/lisp/cedet/srecode-utest-template.el b/test/lisp/cedet/srecode-utest-template.el index 57d8a648050..f97ff18320e 100644 --- a/test/lisp/cedet/srecode-utest-template.el +++ b/test/lisp/cedet/srecode-utest-template.el @@ -307,13 +307,9 @@ INSIDE SECTION: ARG HANDLER ONE") (should (srecode-table major-mode)) ;; Loop over the output testpoints. - (dolist (p srecode-utest-output-entries) - (set-buffer testbuff) ;; XEmacs causes a buffer switch. I don't know why - (should-not (srecode-utest-test p)) - ) + (should-not (srecode-utest-test p))))) - )) (when (file-exists-p srecode-utest-testfile) (delete-file srecode-utest-testfile))) diff --git a/test/lisp/emacs-lisp/cl-macs-tests.el b/test/lisp/emacs-lisp/cl-macs-tests.el index 446983c2e3e..bcd63f73a3c 100644 --- a/test/lisp/emacs-lisp/cl-macs-tests.el +++ b/test/lisp/emacs-lisp/cl-macs-tests.el @@ -610,4 +610,27 @@ collection clause." ;; Just make sure the function can be instrumented. (edebug-defun))) +;;; cl-labels + +(ert-deftest cl-macs--labels () + ;; Simple recursive function. + (cl-labels ((len (xs) (if xs (1+ (len (cdr xs))) 0))) + (should (equal (len (make-list 42 t)) 42))) + + ;; Simple tail-recursive function. + (cl-labels ((len (xs n) (if xs (len (cdr xs) (1+ n)) n))) + (should (equal (len (make-list 42 t) 0) 42)) + ;; Should not bump into stack depth limits. + (should (equal (len (make-list 42000 t) 0) 42000))) + + ;; Check that non-recursive functions are handled more efficiently. + (should (pcase (macroexpand '(cl-labels ((f (x) (+ x 1))) (f 5))) + (`(let* ,_ (funcall ,_ 5)) t))) + + ;; Case of "tail-recursive lambdas". + (should (pcase (macroexpand + '(cl-labels ((len (xs n) (if xs (len (cdr xs) (1+ n)) n))) + #'len)) + (`(function (lambda (,_ ,_) . ,_)) t)))) + ;;; cl-macs-tests.el ends here diff --git a/test/lisp/emacs-lisp/timer-tests.el b/test/lisp/emacs-lisp/timer-tests.el index 74da33eff69..7856c217f9e 100644 --- a/test/lisp/emacs-lisp/timer-tests.el +++ b/test/lisp/emacs-lisp/timer-tests.el @@ -36,8 +36,8 @@ (ert-deftest timer-tests-debug-timer-check () ;; This function exists only if --enable-checking. - (if (fboundp 'debug-timer-check) - (should (debug-timer-check)) t)) + (skip-unless (fboundp 'debug-timer-check)) + (should (debug-timer-check))) (ert-deftest timer-test-multiple-of-time () (should (time-equal-p diff --git a/test/lisp/gnus/mm-decode-resources/win1252-multipart.bin b/test/lisp/gnus/mm-decode-resources/win1252-multipart.bin new file mode 100644 index 00000000000..d3c5026dcce --- /dev/null +++ b/test/lisp/gnus/mm-decode-resources/win1252-multipart.bin @@ -0,0 +1,44 @@ +To: example <example@example.org> +From: example <example@example.org> +Date: Tue, 5 Jan 2021 10:30:34 +0100 +MIME-Version: 1.0 +Content-Type: multipart/mixed; boundary="------------FB569A4368539497CC91D1DC" +Content-Language: fr +Subject: test + +--------------FB569A4368539497CC91D1DC +Content-Type: multipart/alternative; + boundary="------------61C81A7DC7592E4C6F856A85" + + +--------------61C81A7DC7592E4C6F856A85 +Content-Type: text/plain; charset=windows-1252; format=flowed +Content-Transfer-Encoding: 8bit + +déjà raté + +--------------61C81A7DC7592E4C6F856A85 +Content-Type: text/html; charset=windows-1252 +Content-Transfer-Encoding: 8bit + +<html> + <head> + <meta http-equiv="content-type" content="text/html; charset=windows-1252"> + </head> + <body> + déjà raté + </body> +</html> + +--------------61C81A7DC7592E4C6F856A85-- + +--------------FB569A4368539497CC91D1DC +Content-Type: text/plain; charset="us-ascii" +MIME-Version: 1.0 +Content-Transfer-Encoding: 7bit +Content-Disposition: inline + +mailing list signature + +--------------FB569A4368539497CC91D1DC-- + diff --git a/test/lisp/gnus/mm-decode-tests.el b/test/lisp/gnus/mm-decode-tests.el index 74591f919da..7d059cb3f87 100644 --- a/test/lisp/gnus/mm-decode-tests.el +++ b/test/lisp/gnus/mm-decode-tests.el @@ -70,20 +70,33 @@ 'charset))) "ääää\n")))))) -(ert-deftest test-mm-with-part-multibyte () +(ert-deftest test-mm-dissect-buffer-win1252 () (with-temp-buffer - (set-buffer-multibyte t) - (nnheader-insert-file-contents (ert-resource-file "8bit-multipart.bin")) - (while (search-forward "\r\n" nil t) - (replace-match "\n")) + (set-buffer-multibyte nil) + (insert-file-contents-literally (ert-resource-file "win1252-multipart.bin")) (let ((handle (mm-dissect-buffer))) + (should (equal (mm-handle-media-type handle) "multipart/mixed")) + ;; Skip multipart type. + (pop handle) + (setq handle (car handle)) (pop handle) (let ((part (pop handle))) - (should (equal (decode-coding-string - (mm-with-part part - (buffer-string)) - (intern (mail-content-type-get (mm-handle-type part) - 'charset))) - "ääää\n")))))) + (should (equal (mm-handle-media-type part) "text/plain")) + (should (eq (mm-handle-encoding part) '8bit)) + (with-current-buffer (mm-handle-buffer part) + (should (equal (decode-coding-string + (buffer-string) + (intern (mail-content-type-get (mm-handle-type part) + 'charset))) + "déjà raté\n")))) + (let ((part (pop handle))) + (should (equal (mm-handle-media-type part) "text/html")) + (should (eq (mm-handle-encoding part) '8bit)) + (with-current-buffer (mm-handle-buffer part) + (should (equal (decode-coding-string + (buffer-string) + (intern (mail-content-type-get (mm-handle-type part) + 'charset))) + "<html>\n <head>\n <meta http-equiv=\"content-type\" content=\"text/html; charset=windows-1252\">\n </head>\n <body>\n déjà raté\n </body>\n</html>\n"))))))) ;;; mm-decode-tests.el ends here diff --git a/test/lisp/help-mode-tests.el b/test/lisp/help-mode-tests.el index e0e82c9cc1a..43db59d4b1b 100644 --- a/test/lisp/help-mode-tests.el +++ b/test/lisp/help-mode-tests.el @@ -72,14 +72,19 @@ Lisp concepts such as car, cdr, cons cell and list.") #'info))))) (ert-deftest help-mode-tests-xref-button () - (with-temp-buffer - (insert "See also the function ‘interactive’.") - (string-match help-xref-symbol-regexp (buffer-string)) - (help-xref-button 8 'help-function) - (should-not (button-at 22)) - (should-not (button-at 35)) - (let ((button (button-at 30))) - (should (eq (button-type button) 'help-function))))) + (let* ((fmt "See also the function ‘%s’.") + ;; 1+ translates string index to buffer position. + (beg (1+ (string-search "%" fmt)))) + (with-temp-buffer + (dolist (fn '(interactive \` = + - * / %)) + (erase-buffer) + (insert (format fmt fn)) + (goto-char (point-min)) + (re-search-forward help-xref-symbol-regexp) + (help-xref-button 8 'help-function) + (should-not (button-at (1- beg))) + (should-not (button-at (+ beg (length (symbol-name fn))))) + (should (eq (button-type (button-at beg)) 'help-function)))))) (ert-deftest help-mode-tests-insert-xref-button () (with-temp-buffer diff --git a/test/lisp/help-tests.el b/test/lisp/help-tests.el index 835d9fe7949..8034764741c 100644 --- a/test/lisp/help-tests.el +++ b/test/lisp/help-tests.el @@ -95,7 +95,7 @@ key binding --- ------- -C-g abort-recursive-edit +C-g abort-minibuffers TAB minibuffer-complete C-j minibuffer-complete-and-exit RET minibuffer-complete-and-exit @@ -122,7 +122,7 @@ M-s next-matching-history-element (ert-deftest help-tests-substitute-command-keys/keymap-change () (with-substitute-command-keys-test - (test "\\<minibuffer-local-must-match-map>\\[abort-recursive-edit]" "C-g") + (test "\\<minibuffer-local-must-match-map>\\[abort-recursive-edit]" "C-]") (test "\\<emacs-lisp-mode-map>\\[eval-defun]" "C-M-x"))) (defvar help-tests-remap-map diff --git a/test/lisp/net/nsm-tests.el b/test/lisp/net/nsm-tests.el index 88c30c20395..ff453319b37 100644 --- a/test/lisp/net/nsm-tests.el +++ b/test/lisp/net/nsm-tests.el @@ -49,15 +49,17 @@ (should (eq nil (nsm-should-check "127.0.0.1"))) (should (eq nil (nsm-should-check "localhost")))))) -(defun nsm-ipv6-is-available () +;; This will need updating when IANA assign more IPv6 global ranges. +(defun ipv6-is-available () (and (featurep 'make-network-process '(:family ipv6)) (cl-rassoc-if (lambda (elt) - (eq 9 (length elt))) + (and (eq 9 (length elt)) + (= (logand (aref elt 0) #xe000) #x2000))) (network-interface-list)))) (ert-deftest nsm-check-local-subnet-ipv6 () - (skip-unless (nsm-ipv6-is-available)) + (skip-unless (ipv6-is-available)) (let ((local-ip '[123 456 789 11 172 26 128 160 0]) (mask '[255 255 255 255 255 255 255 0 0]) diff --git a/test/lisp/net/socks-tests.el b/test/lisp/net/socks-tests.el new file mode 100644 index 00000000000..b378ed2964e --- /dev/null +++ b/test/lisp/net/socks-tests.el @@ -0,0 +1,103 @@ +;;; socks-tests.el --- tests for SOCKS -*- coding: utf-8; lexical-binding: t; -*- + +;; Copyright (C) 2021 Free Software Foundation, Inc. + +;; This file is part of GNU Emacs. + +;; GNU Emacs is free software: you can redistribute it and/or modify +;; it under the terms of the GNU General Public License as published by +;; the Free Software Foundation, either version 3 of the License, or +;; (at your option) any later version. + +;; GNU Emacs is distributed in the hope that it will be useful, +;; but WITHOUT ANY WARRANTY; without even the implied warranty of +;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +;; GNU General Public License for more details. + +;; You should have received a copy of the GNU General Public License +;; along with GNU Emacs. If not, see <https://www.gnu.org/licenses/>. + +;;; Commentary: + +;;; Code: + +(require 'socks) +(require 'url-http) + +(defvar socks-tests-canned-server-port nil) + +(defun socks-tests-canned-server-create (verbatim patterns) + "Create a fake SOCKS server and return the process. + +`VERBATIM' and `PATTERNS' are dotted alists containing responses. +Requests are tried in order. On failure, an error is raised." + (let* ((buf (generate-new-buffer "*canned-socks-server*")) + (filt (lambda (proc line) + (let ((resp (or (assoc-default line verbatim + (lambda (k s) ; s is line + (string= (concat k) s))) + (assoc-default line patterns + (lambda (p s) + (string-match-p p s)))))) + (unless resp + (error "Unknown request: %s" line)) + (let ((print-escape-control-characters t)) + (princ (format "<- %s\n" (prin1-to-string line)) buf) + (princ (format "-> %s\n" (prin1-to-string resp)) buf)) + (process-send-string proc (concat resp))))) + (srv (make-network-process :server 1 + :buffer buf + :filter filt + :name "server" + :family 'ipv4 + :host 'local + :service socks-tests-canned-server-port))) + (set-process-query-on-exit-flag srv nil) + (princ (format "[%s] Listening on localhost:10080\n" srv) buf) + srv)) + +;; Add ([5 3 0 1 2] . [5 2]) to the `verbatim' list below to validate +;; against curl 7.71 with the following options: +;; $ curl --verbose -U foo:bar --proxy socks5h://127.0.0.1:10080 example.com +;; +;; If later implementing version 4a, try these: +;; [4 1 0 80 0 0 0 1 0 ?e ?x ?a ?m ?p ?l ?e ?. ?c ?o ?m 0] . [0 90 0 0 0 0 0 0] +;; $ curl --verbose --proxy socks4a://127.0.0.1:10080 example.com + +(ert-deftest socks-tests-auth-filter-url-http () + "Verify correct handling of SOCKS5 user/pass authentication." + (let* ((socks-server '("server" "127.0.0.1" 10080 5)) + (socks-username "foo") + (socks-password "bar") + (url-gateway-method 'socks) + (url (url-generic-parse-url "http://example.com")) + (verbatim '(([5 2 0 2] . [5 2]) + ([1 3 ?f ?o ?o 3 ?b ?a ?r] . [1 0]) + ([5 1 0 3 11 ?e ?x ?a ?m ?p ?l ?e ?. ?c ?o ?m 0 80] + . [5 0 0 1 0 0 0 0 0 0]))) + (patterns + `(("^GET /" . ,(concat "HTTP/1.1 200 OK\r\n" + "Content-Type: text/plain; charset=UTF-8\r\n" + "Content-Length: 13\r\n\r\n" + "Hello World!\n")))) + (socks-tests-canned-server-port 10080) + (server (socks-tests-canned-server-create verbatim patterns)) + (tries 10) + ;; + done + ;; + (cb (lambda (&rest _r) + (goto-char (point-min)) + (should (search-forward "Hello World" nil t)) + (setq done t))) + (buf (url-http url cb '(nil)))) + (ert-info ("Connect to HTTP endpoint over SOCKS5 with USER/PASS method") + (while (and (not done) (< 0 (cl-decf tries))) ; cl-lib via url-http + (sleep-for 0.1))) + (should done) + (delete-process server) + (kill-buffer (process-buffer server)) + (kill-buffer buf) + (ignore url-gateway-method))) + +;;; socks-tests.el ends here diff --git a/test/lisp/net/tramp-tests.el b/test/lisp/net/tramp-tests.el index e1cb9939f29..ef0968a3385 100644 --- a/test/lisp/net/tramp-tests.el +++ b/test/lisp/net/tramp-tests.el @@ -78,6 +78,8 @@ ;; Needed for Emacs 27. (defvar process-file-return-signal-string) (defvar shell-command-dont-erase-buffer) +;; Needed for Emacs 28. +(defvar dired-copy-dereference) ;; Beautify batch mode. (when noninteractive @@ -98,7 +100,6 @@ '("mock" (tramp-login-program "sh") (tramp-login-args (("-i"))) - (tramp-direct-async-args (("-c"))) (tramp-remote-shell "/bin/sh") (tramp-remote-shell-args ("-c")) (tramp-connection-timeout 10))) @@ -2438,7 +2439,7 @@ This checks also `file-name-as-directory', `file-name-directory', ;; We must check the last line. There could be ;; other messages from the progress reporter. (should - (string-match + (string-match-p (if (and (null noninteractive) (or (eq visit t) (null visit) (stringp visit))) (format "^Wrote %s\n\\'" (regexp-quote tmp-name)) @@ -2833,6 +2834,7 @@ This tests also `file-directory-p' and `file-accessible-directory-p'." (ert-deftest tramp-test15-copy-directory () "Check `copy-directory'." (skip-unless (tramp--test-enabled)) + (skip-unless (or (tramp--test-emacs26-p) (not (tramp--test-rclone-p)))) (dolist (quoted (if (tramp--test-expensive-test) '(nil t) '(nil))) (let* ((tmp-name1 (tramp--test-make-temp-name nil quoted)) @@ -3067,9 +3069,7 @@ This tests also `file-directory-p' and `file-accessible-directory-p'." (regexp-opt (directory-files tmp-name1)) (length (directory-files tmp-name1))))))) - ;; Check error case. We do not check for the error type, - ;; because ls-lisp returns `file-error', and native Tramp - ;; returns `file-missing'. + ;; Check error case. (delete-directory tmp-name1 'recursive) (with-temp-buffer (should-error @@ -3188,6 +3188,59 @@ This tests also `file-directory-p' and `file-accessible-directory-p'." (ignore-errors (delete-directory tmp-name1 'recursive)) (ignore-errors (delete-directory tmp-name2 'recursive)))))) +;; The following test is inspired by Bug#45691. +(ert-deftest tramp-test17-insert-directory-one-file () + "Check `insert-directory' inside directory listing." + (skip-unless (tramp--test-enabled)) + + (dolist (quoted (if (tramp--test-expensive-test) '(nil t) '(nil))) + (let* ((tmp-name1 + (expand-file-name (tramp--test-make-temp-name nil quoted))) + (tmp-name2 (expand-file-name "foo" tmp-name1)) + (tmp-name3 (expand-file-name "bar" tmp-name1)) + (dired-copy-preserve-time t) + (dired-recursive-copies 'top) + dired-copy-dereference + buffer) + (unwind-protect + (progn + (make-directory tmp-name1) + (write-region "foo" nil tmp-name2) + (should (file-directory-p tmp-name1)) + (should (file-exists-p tmp-name2)) + + ;; Check, that `insert-directory' works properly. + (with-current-buffer + (setq buffer (dired-noselect tmp-name1 "--dired -al")) + (read-only-mode -1) + (goto-char (point-min)) + (while (not (or (eobp) + (string-equal + (dired-get-filename 'localp 'no-error) + (file-name-nondirectory tmp-name2)))) + (forward-line 1)) + (should-not (eobp)) + (copy-file tmp-name2 tmp-name3) + (insert-directory + (file-name-nondirectory tmp-name3) "--dired -al -d") + ;; Point shall still be the recent file. + (should + (string-equal + (dired-get-filename 'localp 'no-error) + (file-name-nondirectory tmp-name2))) + (should-not (re-search-forward "dired" nil t)) + ;; The copied file has been inserted the line before. + (forward-line -1) + (should + (string-equal + (dired-get-filename 'localp 'no-error) + (file-name-nondirectory tmp-name3)))) + (kill-buffer buffer)) + + ;; Cleanup. + (ignore-errors (kill-buffer buffer)) + (ignore-errors (delete-directory tmp-name1 'recursive)))))) + ;; Method "smb" supports `make-symbolic-link' only if the remote host ;; has CIFS capabilities. tramp-adb.el, tramp-gvfs.el and ;; tramp-rclone.el do not support symbolic links at all. @@ -3561,8 +3614,8 @@ This tests also `file-executable-p', `file-writable-p' and `set-file-modes'." `(condition-case err (progn ,@body) (file-error - (unless (string-match "^error with add-name-to-file" - (error-message-string err)) + (unless (string-match-p "^error with add-name-to-file" + (error-message-string err)) (signal (car err) (cdr err)))))) (ert-deftest tramp-test21-file-links () @@ -4337,7 +4390,7 @@ This tests also `make-symbolic-link', `file-truename' and `add-name-to-file'." ;; there's an indication for a signal describing string. (let ((process-file-return-signal-string t)) (should - (string-match + (string-match-p "Interrupt\\|Signal 2" (process-file (if (tramp--test-adb-p) "/system/bin/sh" "/bin/sh") @@ -4405,7 +4458,7 @@ This tests also `make-symbolic-link', `file-truename' and `add-name-to-file'." (with-timeout (10 (tramp--test-timeout-handler)) (while (< (- (point-max) (point-min)) (length "foo")) (while (accept-process-output proc 0 nil t)))) - (should (string-match "foo" (buffer-string)))) + (should (string-match-p "foo" (buffer-string)))) ;; Cleanup. (ignore-errors (delete-process proc))) @@ -4424,7 +4477,7 @@ This tests also `make-symbolic-link', `file-truename' and `add-name-to-file'." (with-timeout (10 (tramp--test-timeout-handler)) (while (< (- (point-max) (point-min)) (length "foo")) (while (accept-process-output proc 0 nil t)))) - (should (string-match "foo" (buffer-string)))) + (should (string-match-p "foo" (buffer-string)))) ;; Cleanup. (ignore-errors @@ -4446,7 +4499,7 @@ This tests also `make-symbolic-link', `file-truename' and `add-name-to-file'." (with-timeout (10 (tramp--test-timeout-handler)) (while (< (- (point-max) (point-min)) (length "foo")) (while (accept-process-output proc 0 nil t)))) - (should (string-match "foo" (buffer-string)))) + (should (string-match-p "foo" (buffer-string)))) ;; Cleanup. (ignore-errors (delete-process proc))) @@ -4488,8 +4541,6 @@ If UNSTABLE is non-nil, the test is tagged as `:unstable'." (cons '(nil "direct-async-process" t) tramp-connection-properties))) (skip-unless (tramp-direct-async-process-p)) - ;; For whatever reason, it doesn't cooperate with the "mock" method. - (skip-unless (not (tramp--test-mock-p))) ;; We do expect an established connection already, ;; `file-truename' does it by side-effect. Suppress ;; `tramp--test-enabled', in order to keep the connection. @@ -4535,7 +4586,7 @@ If UNSTABLE is non-nil, the test is tagged as `:unstable'." (with-timeout (10 (tramp--test-timeout-handler)) (while (< (- (point-max) (point-min)) (length "foo")) (while (accept-process-output proc 0 nil t)))) - (should (string-match "foo" (buffer-string)))) + (should (string-match-p "foo" (buffer-string)))) ;; Cleanup. (ignore-errors (delete-process proc))) @@ -4556,7 +4607,7 @@ If UNSTABLE is non-nil, the test is tagged as `:unstable'." (with-timeout (10 (tramp--test-timeout-handler)) (while (< (- (point-max) (point-min)) (length "foo")) (while (accept-process-output proc 0 nil t)))) - (should (string-match "foo" (buffer-string)))) + (should (string-match-p "foo" (buffer-string)))) ;; Cleanup. (ignore-errors @@ -4580,9 +4631,9 @@ If UNSTABLE is non-nil, the test is tagged as `:unstable'." (process-send-eof proc) ;; Read output. (with-timeout (10 (tramp--test-timeout-handler)) - (while (not (string-match "foo" (buffer-string))) + (while (not (string-match-p "foo" (buffer-string))) (while (accept-process-output proc 0 nil t)))) - (should (string-match "foo" (buffer-string)))) + (should (string-match-p "foo" (buffer-string)))) ;; Cleanup. (ignore-errors (delete-process proc))) @@ -4607,7 +4658,7 @@ If UNSTABLE is non-nil, the test is tagged as `:unstable'." (with-timeout (10 (tramp--test-timeout-handler)) (while (accept-process-output proc 0 nil t))) ;; On some MS Windows systems, it returns "unknown signal". - (should (string-match "unknown signal\\|killed" (buffer-string)))) + (should (string-match-p "unknown signal\\|killed" (buffer-string)))) ;; Cleanup. (ignore-errors (delete-process proc))) @@ -4631,7 +4682,7 @@ If UNSTABLE is non-nil, the test is tagged as `:unstable'." (delete-process proc) (with-current-buffer stderr (should - (string-match + (string-match-p "cat:.* No such file or directory" (buffer-string))))) ;; Cleanup. @@ -4658,7 +4709,7 @@ If UNSTABLE is non-nil, the test is tagged as `:unstable'." (with-temp-buffer (insert-file-contents tmpfile) (should - (string-match + (string-match-p "cat:.* No such file or directory" (buffer-string))))) ;; Cleanup. @@ -4801,7 +4852,7 @@ INPUT, if non-nil, is a string sent to the process." (should (string-equal ;; tramp-adb.el echoes, so we must add the string. - (if (tramp--test-adb-p) + (if (and (tramp--test-adb-p) (not (tramp-direct-async-process-p))) (format "%s\n%s\n" (file-name-nondirectory tmp-name) @@ -4992,7 +5043,7 @@ INPUT, if non-nil, is a string sent to the process." (cons (concat envvar "=foo") process-environment))) ;; Default value. (should - (string-match + (string-match-p "foo" (funcall this-shell-command-to-string @@ -5003,13 +5054,13 @@ INPUT, if non-nil, is a string sent to the process." (cons (concat envvar "=") process-environment))) ;; Value is null. (should - (string-match + (string-match-p "bla" (funcall this-shell-command-to-string (format "echo \"${%s:-bla}\"" envvar)))) ;; Variable is set. (should - (string-match + (string-match-p (regexp-quote envvar) (funcall this-shell-command-to-string "set")))) @@ -5021,7 +5072,7 @@ INPUT, if non-nil, is a string sent to the process." (cons (concat envvar "=foo") tramp-remote-process-environment))) ;; Set the initial value, we want to unset below. (should - (string-match + (string-match-p "foo" (funcall this-shell-command-to-string @@ -5029,14 +5080,14 @@ INPUT, if non-nil, is a string sent to the process." (let ((process-environment (cons envvar process-environment))) ;; Variable is unset. (should - (string-match + (string-match-p "bla" (funcall this-shell-command-to-string (format "echo \"${%s:-bla}\"" envvar)))) ;; Variable is unset. (should-not - (string-match + (string-match-p (regexp-quote envvar) ;; We must remove PS1, the output is truncated otherwise. (funcall @@ -5074,7 +5125,7 @@ Use direct async.") (format "%s=%d" envvar port) tramp-remote-process-environment))) (should - (string-match + (string-match-p (number-to-string port) (shell-command-to-string (format "echo $%s" envvar)))))) @@ -5202,7 +5253,7 @@ Use direct async.") (with-timeout (10) (while (accept-process-output (get-buffer-process (current-buffer)) nil nil t))) - (should (string-match "^foo$" (buffer-string))))) + (should (string-match-p "^foo$" (buffer-string))))) ;; Cleanup. (put 'explicit-shell-file-name 'permanent-local nil) @@ -5337,25 +5388,27 @@ Use direct async.") (tramp-remote-process-environment tramp-remote-process-environment) (inhibit-message t) (vc-handled-backends - (with-parsed-tramp-file-name tramp-test-temporary-file-directory nil - (cond - ((tramp-find-executable - v vc-git-program (tramp-get-remote-path v)) - '(Git)) - ((tramp-find-executable - v vc-hg-program (tramp-get-remote-path v)) - '(Hg)) - ((tramp-find-executable - v vc-bzr-program (tramp-get-remote-path v)) - (setq tramp-remote-process-environment - (cons (format "BZR_HOME=%s" - (file-remote-p tmp-name1 'localname)) - tramp-remote-process-environment)) - ;; We must force a reconnect, in order to activate $BZR_HOME. - (tramp-cleanup-connection - tramp-test-vec 'keep-debug 'keep-password) - '(Bzr)) - (t nil)))) + (cond + ((tramp-find-executable + tramp-test-vec vc-git-program + (tramp-get-remote-path tramp-test-vec)) + '(Git)) + ((tramp-find-executable + tramp-test-vec vc-hg-program + (tramp-get-remote-path tramp-test-vec)) + '(Hg)) + ((tramp-find-executable + tramp-test-vec vc-bzr-program + (tramp-get-remote-path tramp-test-vec)) + (setq tramp-remote-process-environment + (cons (format "BZR_HOME=%s" + (file-remote-p tmp-name1 'localname)) + tramp-remote-process-environment)) + ;; We must force a reconnect, in order to activate $BZR_HOME. + (tramp-cleanup-connection + tramp-test-vec 'keep-debug 'keep-password) + '(Bzr)) + (t nil))) ;; Suppress nasty messages. (inhibit-message t)) (skip-unless vc-handled-backends) @@ -5681,7 +5734,7 @@ This does not support some special file names." "Check, whether an FTP-like method is used. This does not support globbing characters in file names (yet)." ;; Globbing characters are ??, ?* and ?\[. - (string-match + (string-match-p "ftp$" (file-remote-p tramp-test-temporary-file-directory 'method))) (defun tramp--test-gvfs-p (&optional method) @@ -5695,18 +5748,18 @@ If optional METHOD is given, it is checked first." "Check, whether the remote host runs HP-UX. Several special characters do not work properly there." ;; We must refill the cache. `file-truename' does it. - (with-parsed-tramp-file-name - (file-truename tramp-test-temporary-file-directory) nil - (string-match "^HP-UX" (tramp-get-connection-property v "uname" "")))) + (file-truename tramp-test-temporary-file-directory) nil + (string-match-p + "^HP-UX" (tramp-get-connection-property tramp-test-vec "uname" ""))) (defun tramp--test-ksh-p () "Check, whether the remote shell is ksh. ksh93 makes some strange conversions of non-latin characters into a $'' syntax." ;; We must refill the cache. `file-truename' does it. - (with-parsed-tramp-file-name - (file-truename tramp-test-temporary-file-directory) nil - (string-match "ksh$" (tramp-get-connection-property v "remote-shell" "")))) + (file-truename tramp-test-temporary-file-directory) nil + (string-match-p + "ksh$" (tramp-get-connection-property tramp-test-vec "remote-shell" ""))) (defun tramp--test-mock-p () "Check, whether the mock method is used. @@ -5758,7 +5811,7 @@ This does not support special characters." "Check, whether the locale host runs MS Windows, and ps{cp,ftp} is used. This does not support utf8 based file transfer." (and (eq system-type 'windows-nt) - (string-match + (string-match-p (regexp-opt '("pscp" "psftp")) (file-remote-p tramp-test-temporary-file-directory 'method)))) @@ -6021,6 +6074,7 @@ This requires restrictions of file name syntax." (skip-unless (tramp--test-enabled)) (skip-unless (not (tramp--test-rsync-p))) (skip-unless (not (tramp--test-windows-nt-and-pscp-psftp-p))) + (skip-unless (or (tramp--test-emacs26-p) (not (tramp--test-rclone-p)))) (tramp--test-special-characters)) @@ -6032,6 +6086,8 @@ Use the `stat' command." (skip-unless (tramp--test-sh-p)) (skip-unless (not (tramp--test-rsync-p))) (skip-unless (not (tramp--test-windows-nt-and-pscp-psftp-p))) + (skip-unless (or (tramp--test-emacs26-p) (not (tramp--test-rclone-p)))) + ;; We cannot use `tramp-test-vec', because this fails during compilation. (with-parsed-tramp-file-name tramp-test-temporary-file-directory nil (skip-unless (tramp-get-remote-stat v))) @@ -6050,6 +6106,8 @@ Use the `perl' command." (skip-unless (tramp--test-sh-p)) (skip-unless (not (tramp--test-rsync-p))) (skip-unless (not (tramp--test-windows-nt-and-pscp-psftp-p))) + (skip-unless (or (tramp--test-emacs26-p) (not (tramp--test-rclone-p)))) + ;; We cannot use `tramp-test-vec', because this fails during compilation. (with-parsed-tramp-file-name tramp-test-temporary-file-directory nil (skip-unless (tramp-get-remote-perl v))) @@ -6072,6 +6130,7 @@ Use the `ls' command." (skip-unless (not (tramp--test-rsync-p))) (skip-unless (not (tramp--test-windows-nt-and-batch-p))) (skip-unless (not (tramp--test-windows-nt-and-pscp-psftp-p))) + (skip-unless (or (tramp--test-emacs26-p) (not (tramp--test-rclone-p)))) (let ((tramp-connection-properties (append @@ -6140,6 +6199,7 @@ Use the `ls' command." (skip-unless (not (tramp--test-windows-nt-and-pscp-psftp-p))) (skip-unless (not (tramp--test-ksh-p))) (skip-unless (not (tramp--test-crypt-p))) + (skip-unless (or (tramp--test-emacs26-p) (not (tramp--test-rclone-p)))) (tramp--test-utf8)) @@ -6155,6 +6215,8 @@ Use the `stat' command." (skip-unless (not (tramp--test-windows-nt-and-pscp-psftp-p))) (skip-unless (not (tramp--test-ksh-p))) (skip-unless (not (tramp--test-crypt-p))) + (skip-unless (or (tramp--test-emacs26-p) (not (tramp--test-rclone-p)))) + ;; We cannot use `tramp-test-vec', because this fails during compilation. (with-parsed-tramp-file-name tramp-test-temporary-file-directory nil (skip-unless (tramp-get-remote-stat v))) @@ -6177,6 +6239,8 @@ Use the `perl' command." (skip-unless (not (tramp--test-windows-nt-and-pscp-psftp-p))) (skip-unless (not (tramp--test-ksh-p))) (skip-unless (not (tramp--test-crypt-p))) + (skip-unless (or (tramp--test-emacs26-p) (not (tramp--test-rclone-p)))) + ;; We cannot use `tramp-test-vec', because this fails during compilation. (with-parsed-tramp-file-name tramp-test-temporary-file-directory nil (skip-unless (tramp-get-remote-perl v))) @@ -6202,6 +6266,7 @@ Use the `ls' command." (skip-unless (not (tramp--test-windows-nt-and-pscp-psftp-p))) (skip-unless (not (tramp--test-ksh-p))) (skip-unless (not (tramp--test-crypt-p))) + (skip-unless (or (tramp--test-emacs26-p) (not (tramp--test-rclone-p)))) (let ((tramp-connection-properties (append @@ -6490,7 +6555,7 @@ process sentinels. They shall not disturb each other." (message \"Tramp loaded: %%s\" (and (file-remote-p %S) t)))" tramp-test-temporary-file-directory))) (should - (string-match + (string-match-p "Tramp loaded: t[\n\r]+" (shell-command-to-string (format @@ -6521,7 +6586,7 @@ process sentinels. They shall not disturb each other." ;; Tramp doesn't load when `tramp-mode' is nil. (dolist (tm '(t nil)) (should - (string-match + (string-match-p (format "Tramp loaded: nil[\n\r]+Tramp loaded: nil[\n\r]+Tramp loaded: %s[\n\r]+" tm) @@ -6547,7 +6612,7 @@ process sentinels. They shall not disturb each other." tramp-test-temporary-file-directory temporary-file-directory))) (should-not - (string-match + (string-match-p "Recursive load" (shell-command-to-string (format @@ -6572,7 +6637,7 @@ process sentinels. They shall not disturb each other." (load-path (cons \"/foo:bar:\" load-path))) \ (tramp-cleanup-all-connections))")) (should - (string-match + (string-match-p (format "Loading %s" (regexp-quote @@ -6619,11 +6684,11 @@ Since it unloads Tramp, it shall be the last test to run." (lambda (x) (and (or (and (boundp x) (null (local-variable-if-set-p x))) (and (functionp x) (null (autoloadp (symbol-function x))))) - (string-match "^tramp" (symbol-name x)) + (string-match-p "^tramp" (symbol-name x)) ;; `tramp-completion-mode' is autoloaded in Emacs < 28.1. (not (eq 'tramp-completion-mode x)) - (not (string-match "^tramp\\(-archive\\)?--?test" (symbol-name x))) - (not (string-match "unload-hook$" (symbol-name x))) + (not (string-match-p "^tramp\\(-archive\\)?--?test" (symbol-name x))) + (not (string-match-p "unload-hook$" (symbol-name x))) (ert-fail (format "`%s' still bound" x))))) ;; The defstruct `tramp-file-name' and all its internal functions ;; shall be purged. @@ -6631,15 +6696,15 @@ Since it unloads Tramp, it shall be the last test to run." (mapatoms (lambda (x) (and (functionp x) - (string-match "tramp-file-name" (symbol-name x)) + (string-match-p "tramp-file-name" (symbol-name x)) (ert-fail (format "Structure function `%s' still exists" x))))) ;; There shouldn't be left a hook function containing a Tramp ;; function. We do not regard the Tramp unload hooks. (mapatoms (lambda (x) (and (boundp x) - (string-match "-\\(hook\\|function\\)s?$" (symbol-name x)) - (not (string-match "unload-hook$" (symbol-name x))) + (string-match-p "-\\(hook\\|function\\)s?$" (symbol-name x)) + (not (string-match-p "unload-hook$" (symbol-name x))) (consp (symbol-value x)) (ignore-errors (all-completions "tramp" (symbol-value x))) (ert-fail (format "Hook `%s' still contains Tramp function" x)))))) diff --git a/test/lisp/progmodes/tcl-tests.el b/test/lisp/progmodes/tcl-tests.el index 8ff85470ece..cf1ed2896e4 100644 --- a/test/lisp/progmodes/tcl-tests.el +++ b/test/lisp/progmodes/tcl-tests.el @@ -50,14 +50,14 @@ (insert "proc notinthis {} {\n # nothing\n}\n\n") (should-not (add-log-current-defun)))) -(ert-deftest tcl-mode-function-name () +(ert-deftest tcl-mode-function-name-2 () (with-temp-buffer (tcl-mode) (insert "proc simple {} {\n # nothing\n}") (backward-char 3) (should (equal "simple" (add-log-current-defun))))) -(ert-deftest tcl-mode-function-name () +(ert-deftest tcl-mode-function-name-3 () (with-temp-buffer (tcl-mode) (insert "proc inthis {} {\n # nothing\n") @@ -72,6 +72,16 @@ (indent-region (point-min) (point-max)) (should (equal (buffer-string) text))))) +;; From bug#44834 +(ert-deftest tcl-mode-namespace-indent-2 () + :expected-result :failed + (with-temp-buffer + (tcl-mode) + (let ((text "namespace eval Foo {\n proc foo {} {}\n\n proc bar {}{}}\n")) + (insert text) + (indent-region (point-min) (point-max)) + (should (equal (buffer-string) text))))) + (provide 'tcl-tests) ;;; tcl-tests.el ends here diff --git a/test/lisp/subr-tests.el b/test/lisp/subr-tests.el index 245a4a7c3af..843981fe8e8 100644 --- a/test/lisp/subr-tests.el +++ b/test/lisp/subr-tests.el @@ -87,6 +87,17 @@ ;; Returns the symbol. (should (eq (define-prefix-command 'foo-bar) 'foo-bar))) +(ert-deftest subr-test-local-key-binding () + (with-temp-buffer + (emacs-lisp-mode) + (should (keymapp (local-key-binding [menu-bar]))) + (should-not (local-key-binding [f12])))) + +(ert-deftest subr-test-global-key-binding () + (should (eq (global-key-binding [f1]) 'help-command)) + (should (eq (global-key-binding "x") 'self-insert-command)) + (should-not (global-key-binding [f12]))) + ;;;; Mode hooks. @@ -433,6 +444,15 @@ See https://debbugs.gnu.org/cgi/bugreport.cgi?bug=19350." (should (equal (flatten-tree '(1 ("foo" "bar") 2)) '(1 "foo" "bar" 2)))) +(ert-deftest subr--tests-letrec () + ;; Test that simple cases of `letrec' get optimized back to `let*'. + (should (equal (macroexpand '(letrec ((subr-tests-var1 1) + (subr-tests-var2 subr-tests-var1)) + (+ subr-tests-var1 subr-tests-var2))) + '(let* ((subr-tests-var1 1) + (subr-tests-var2 subr-tests-var1)) + (+ subr-tests-var1 subr-tests-var2))))) + (defvar subr-tests--hook nil) (ert-deftest subr-tests-add-hook-depth () diff --git a/test/lisp/textmodes/fill-tests.el b/test/lisp/textmodes/fill-tests.el index f2c63a93d3e..21efe620999 100644 --- a/test/lisp/textmodes/fill-tests.el +++ b/test/lisp/textmodes/fill-tests.el @@ -44,6 +44,37 @@ (fill-paragraph) (should (string= (buffer-string) "Abc\nd efg\n(h ijk).")))) +(ert-deftest fill-test-unbreakable-paragraph () + (with-temp-buffer + (let ((string "aaa = baaaaaaaaaaaaaaaaaaaaaaaaaaaa\n")) + (insert string) + (goto-char (point-min)) + (search-forward "b") + (let* ((pos (point)) + (beg (line-beginning-position)) + (end (line-end-position)) + (fill-prefix (make-string (- pos beg) ?\s)) + ;; `fill-column' is too small to accomodate the current line + (fill-column (- end beg 10))) + (fill-region-as-paragraph beg end nil nil pos)) + (should (equal (buffer-string) string))))) + +(ert-deftest fill-test-breakable-paragraph () + (with-temp-buffer + (let ((string "aaa = baaaaaaaa aaaaaaaaaa aaaaaaaaaa\n")) + (insert string) + (goto-char (point-min)) + (search-forward "b") + (let* ((pos (point)) + (beg (line-beginning-position)) + (end (line-end-position)) + (fill-prefix (make-string (- pos beg) ?\s)) + ;; `fill-column' is too small to accomodate the current line + (fill-column (- end beg 10))) + (fill-region-as-paragraph beg end nil nil pos)) + (should (equal + (buffer-string) + "aaa = baaaaaaaa aaaaaaaaaa\n aaaaaaaaaa\n"))))) (provide 'fill-tests) |