diff options
| author | Po Lu | 2021-12-06 17:24:28 +0800 |
|---|---|---|
| committer | Po Lu | 2021-12-06 17:24:28 +0800 |
| commit | 9eba6b966e330a38bdc3fef5e36b8a2904e72785 (patch) | |
| tree | 4018079e38cd5eb22c33b497cf777784b7647b8e /test | |
| parent | 7314c12e64ef5b185e3fd52d8dc1111eb730bdad (diff) | |
| parent | c1145c31adf143460911dd87b408d35ea88a1a92 (diff) | |
| download | emacs-9eba6b966e330a38bdc3fef5e36b8a2904e72785.tar.gz emacs-9eba6b966e330a38bdc3fef5e36b8a2904e72785.zip | |
Merge remote-tracking branch 'origin/master' into feature/pgtk
Diffstat (limited to 'test')
| -rw-r--r-- | test/Makefile.in | 2 | ||||
| -rw-r--r-- | test/lisp/autorevert-tests.el | 6 | ||||
| -rw-r--r-- | test/lisp/calendar/time-date-tests.el | 17 | ||||
| -rw-r--r-- | test/lisp/net/tramp-tests.el | 2 | ||||
| -rw-r--r-- | test/lisp/vc/vc-git-tests.el | 67 | ||||
| -rw-r--r-- | test/manual/cedet/cedet-utests.el | 4 | ||||
| -rw-r--r-- | test/src/timefns-tests.el | 12 |
7 files changed, 94 insertions, 16 deletions
diff --git a/test/Makefile.in b/test/Makefile.in index 51696d7faaf..f2c49584e7f 100644 --- a/test/Makefile.in +++ b/test/Makefile.in | |||
| @@ -368,7 +368,7 @@ maintainer-clean: distclean bootstrap-clean | |||
| 368 | .PHONY: check-declare | 368 | .PHONY: check-declare |
| 369 | 369 | ||
| 370 | check-declare: | 370 | check-declare: |
| 371 | $(emacs) -l check-declare \ | 371 | $(emacs) --batch -l check-declare \ |
| 372 | --eval '(check-declare-directory "$(srcdir)")' | 372 | --eval '(check-declare-directory "$(srcdir)")' |
| 373 | 373 | ||
| 374 | .PHONY: subdirs subdir-targets generate-test-jobs | 374 | .PHONY: subdirs subdir-targets generate-test-jobs |
diff --git a/test/lisp/autorevert-tests.el b/test/lisp/autorevert-tests.el index b9d45324cb7..b31f0a9afc4 100644 --- a/test/lisp/autorevert-tests.el +++ b/test/lisp/autorevert-tests.el | |||
| @@ -127,7 +127,7 @@ This expects `auto-revert--messages' to be bound by | |||
| 127 | `ert-with-message-capture' before calling." | 127 | `ert-with-message-capture' before calling." |
| 128 | ;; Remote files do not cooperate well with timers. So we count ourselves. | 128 | ;; Remote files do not cooperate well with timers. So we count ourselves. |
| 129 | (let ((ct (current-time))) | 129 | (let ((ct (current-time))) |
| 130 | (while (and (< (float-time (time-subtract (current-time) ct)) | 130 | (while (and (< (float-time (time-subtract nil ct)) |
| 131 | (auto-revert--timeout)) | 131 | (auto-revert--timeout)) |
| 132 | (null (string-match | 132 | (null (string-match |
| 133 | (format-message | 133 | (format-message |
| @@ -167,7 +167,7 @@ This expects `auto-revert--messages' to be bound by | |||
| 167 | 167 | ||
| 168 | (defun auto-revert-tests--write-file (text file time-delta &optional append) | 168 | (defun auto-revert-tests--write-file (text file time-delta &optional append) |
| 169 | (write-region text nil file append 'no-message) | 169 | (write-region text nil file append 'no-message) |
| 170 | (set-file-times file (time-subtract (current-time) time-delta))) | 170 | (set-file-times file (time-subtract nil time-delta))) |
| 171 | 171 | ||
| 172 | (ert-deftest auto-revert-test00-auto-revert-mode () | 172 | (ert-deftest auto-revert-test00-auto-revert-mode () |
| 173 | "Check autorevert for a file." | 173 | "Check autorevert for a file." |
| @@ -453,7 +453,7 @@ This expects `auto-revert--messages' to be bound by | |||
| 453 | (defun auto-revert-test--wait-for (pred max-wait) | 453 | (defun auto-revert-test--wait-for (pred max-wait) |
| 454 | "Wait until PRED is true, or MAX-WAIT seconds elapsed." | 454 | "Wait until PRED is true, or MAX-WAIT seconds elapsed." |
| 455 | (let ((ct (current-time))) | 455 | (let ((ct (current-time))) |
| 456 | (while (and (< (float-time (time-subtract (current-time) ct)) max-wait) | 456 | (while (and (< (float-time (time-subtract nil ct)) max-wait) |
| 457 | (not (funcall pred))) | 457 | (not (funcall pred))) |
| 458 | (read-event nil nil 0.1)))) | 458 | (read-event nil nil 0.1)))) |
| 459 | 459 | ||
diff --git a/test/lisp/calendar/time-date-tests.el b/test/lisp/calendar/time-date-tests.el index d5269804ad2..ed842e34fd6 100644 --- a/test/lisp/calendar/time-date-tests.el +++ b/test/lisp/calendar/time-date-tests.el | |||
| @@ -55,13 +55,13 @@ | |||
| 55 | (should (date-leap-year-p 2004))) | 55 | (should (date-leap-year-p 2004))) |
| 56 | 56 | ||
| 57 | (ert-deftest test-days-to-time () | 57 | (ert-deftest test-days-to-time () |
| 58 | (should (equal (days-to-time 0) '(0 0))) | 58 | (should (time-equal-p (days-to-time 0) '(0 0))) |
| 59 | (should (equal (days-to-time 1) '(1 20864))) | 59 | (should (time-equal-p (days-to-time 1) '(1 20864))) |
| 60 | (should (equal (days-to-time 999) '(1317 2688))) | 60 | (should (time-equal-p (days-to-time 999) '(1317 2688))) |
| 61 | (should (equal (days-to-time 0.0) '(0 0 0 0))) | 61 | (should (time-equal-p (days-to-time 0.0) '(0 0 0 0))) |
| 62 | (should (equal (days-to-time 0.5) '(0 43200 0 0))) | 62 | (should (time-equal-p (days-to-time 0.5) '(0 43200 0 0))) |
| 63 | (should (equal (days-to-time 1.0) '(1 20864 0 0))) | 63 | (should (time-equal-p (days-to-time 1.0) '(1 20864 0 0))) |
| 64 | (should (equal (days-to-time 999.0) '(1317 2688 0 0)))) | 64 | (should (time-equal-p (days-to-time 999.0) '(1317 2688 0 0)))) |
| 65 | 65 | ||
| 66 | (ert-deftest test-seconds-to-string () | 66 | (ert-deftest test-seconds-to-string () |
| 67 | (should (equal (seconds-to-string 0) "0s")) | 67 | (should (equal (seconds-to-string 0) "0s")) |
| @@ -170,7 +170,8 @@ | |||
| 170 | 170 | ||
| 171 | (ert-deftest test-time-since () | 171 | (ert-deftest test-time-since () |
| 172 | (should (time-equal-p 0 (time-since nil))) | 172 | (should (time-equal-p 0 (time-since nil))) |
| 173 | (should (= (cadr (time-since (time-subtract (current-time) 1))) 1))) | 173 | (should (time-equal-p 1 (time-convert (time-since (time-subtract nil 1)) |
| 174 | 'integer)))) | ||
| 174 | 175 | ||
| 175 | (ert-deftest test-time-decoded-period () | 176 | (ert-deftest test-time-decoded-period () |
| 176 | (should (equal (decoded-time-period '(nil nil 1 nil nil nil nil nil nil)) | 177 | (should (equal (decoded-time-period '(nil nil 1 nil nil nil nil nil nil)) |
diff --git a/test/lisp/net/tramp-tests.el b/test/lisp/net/tramp-tests.el index 47fa18eb806..c047f666dae 100644 --- a/test/lisp/net/tramp-tests.el +++ b/test/lisp/net/tramp-tests.el | |||
| @@ -241,7 +241,7 @@ is greater than 10. | |||
| 241 | (progn ,@body) | 241 | (progn ,@body) |
| 242 | (tramp--test-message | 242 | (tramp--test-message |
| 243 | "%s %f sec" | 243 | "%s %f sec" |
| 244 | ,message (float-time (time-subtract (current-time) start)))))) | 244 | ,message (float-time (time-subtract nil start)))))) |
| 245 | 245 | ||
| 246 | ;; `always' is introduced with Emacs 28.1. | 246 | ;; `always' is introduced with Emacs 28.1. |
| 247 | (defalias 'tramp--test-always | 247 | (defalias 'tramp--test-always |
diff --git a/test/lisp/vc/vc-git-tests.el b/test/lisp/vc/vc-git-tests.el new file mode 100644 index 00000000000..997ab3c4b5c --- /dev/null +++ b/test/lisp/vc/vc-git-tests.el | |||
| @@ -0,0 +1,67 @@ | |||
| 1 | ;;; vc-git-tests.el --- tests for vc/vc-git.el -*- lexical-binding:t -*- | ||
| 2 | |||
| 3 | ;; Copyright (C) 2016-2021 Free Software Foundation, Inc. | ||
| 4 | |||
| 5 | ;; Author: Justin Schell <justinmschell@gmail.com> | ||
| 6 | ;; Maintainer: emacs-devel@gnu.org | ||
| 7 | |||
| 8 | ;; This file is part of GNU Emacs. | ||
| 9 | |||
| 10 | ;; GNU Emacs is free software: you can redistribute it and/or modify | ||
| 11 | ;; it under the terms of the GNU General Public License as published by | ||
| 12 | ;; the Free Software Foundation, either version 3 of the License, or | ||
| 13 | ;; (at your option) any later version. | ||
| 14 | |||
| 15 | ;; GNU Emacs is distributed in the hope that it will be useful, | ||
| 16 | ;; but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 17 | ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 18 | ;; GNU General Public License for more details. | ||
| 19 | |||
| 20 | ;; You should have received a copy of the GNU General Public License | ||
| 21 | ;; along with GNU Emacs. If not, see <https://www.gnu.org/licenses/>. | ||
| 22 | |||
| 23 | ;;; Commentary: | ||
| 24 | |||
| 25 | ;;; Code: | ||
| 26 | |||
| 27 | (require 'vc-git) | ||
| 28 | |||
| 29 | (ert-deftest vc-git-test-program-version-general () | ||
| 30 | (vc-git-test--run-program-version-test | ||
| 31 | "git version 2.30.1.0" | ||
| 32 | "2.30.1.0")) | ||
| 33 | |||
| 34 | (ert-deftest vc-git-test-program-version-windows () | ||
| 35 | (vc-git-test--run-program-version-test | ||
| 36 | "git version 2.30.1.1.windows.1" | ||
| 37 | "2.30.1.1")) | ||
| 38 | |||
| 39 | (ert-deftest vc-git-test-program-version-apple () | ||
| 40 | (vc-git-test--run-program-version-test | ||
| 41 | "git version 2.30.1.2 (Apple Git-130)" | ||
| 42 | "2.30.1.2")) | ||
| 43 | |||
| 44 | (ert-deftest vc-git-test-program-version-other () | ||
| 45 | (vc-git-test--run-program-version-test | ||
| 46 | "git version 2.30.1.3.foo.bar" | ||
| 47 | "2.30.1.3")) | ||
| 48 | |||
| 49 | (ert-deftest vc-git-test-program-version-invalid-leading-string () | ||
| 50 | (vc-git-test--run-program-version-test | ||
| 51 | "git version foo.bar.2.30.1.4" | ||
| 52 | "0")) | ||
| 53 | |||
| 54 | (ert-deftest vc-git-test-program-version-invalid-leading-dot () | ||
| 55 | (vc-git-test--run-program-version-test | ||
| 56 | "git version .2.30.1.5" | ||
| 57 | "0")) | ||
| 58 | |||
| 59 | (defun vc-git-test--run-program-version-test | ||
| 60 | (mock-version-string expected-output) | ||
| 61 | (cl-letf* (((symbol-function 'vc-git--run-command-string) | ||
| 62 | (lambda (_file _args) mock-version-string)) | ||
| 63 | (vc-git--program-version nil) | ||
| 64 | (actual-output (vc-git--program-version))) | ||
| 65 | (should (equal actual-output expected-output)))) | ||
| 66 | |||
| 67 | ;;; vc-git-tests.el ends here | ||
diff --git a/test/manual/cedet/cedet-utests.el b/test/manual/cedet/cedet-utests.el index d68b5b8c090..af6b4defb3c 100644 --- a/test/manual/cedet/cedet-utests.el +++ b/test/manual/cedet/cedet-utests.el | |||
| @@ -252,9 +252,7 @@ Optional argument TITLE is the title of this testing session." | |||
| 252 | (defun cedet-utest-elapsed-time (start end) | 252 | (defun cedet-utest-elapsed-time (start end) |
| 253 | "Copied from elp.el. Was elp-elapsed-time. | 253 | "Copied from elp.el. Was elp-elapsed-time. |
| 254 | Argument START and END bound the time being calculated." | 254 | Argument START and END bound the time being calculated." |
| 255 | (+ (* (- (car end) (car start)) 65536.0) | 255 | (float-time (time-subtract start end))) |
| 256 | (- (car (cdr end)) (car (cdr start))) | ||
| 257 | (/ (- (car (cdr (cdr end))) (car (cdr (cdr start)))) 1000000.0))) | ||
| 258 | 256 | ||
| 259 | (defun cedet-utest-log-shutdown (title &optional _errorcondition) | 257 | (defun cedet-utest-log-shutdown (title &optional _errorcondition) |
| 260 | "Shut-down a larger test suite. | 258 | "Shut-down a larger test suite. |
diff --git a/test/src/timefns-tests.el b/test/src/timefns-tests.el index bba9b3fcd8c..f801478a9a1 100644 --- a/test/src/timefns-tests.el +++ b/test/src/timefns-tests.el | |||
| @@ -242,4 +242,16 @@ a fixed place on the right and are padded on the left." | |||
| 242 | (should (= xdiv (float-time (time-convert xdiv t)))))) | 242 | (should (= xdiv (float-time (time-convert xdiv t)))))) |
| 243 | (setq x (* x 2))))) | 243 | (setq x (* x 2))))) |
| 244 | 244 | ||
| 245 | (ert-deftest time-convert-forms () | ||
| 246 | ;; These computations involve numbers that should have exact | ||
| 247 | ;; representations on any Emacs platform. | ||
| 248 | (dolist (time '(-86400 -1 0 1 86400)) | ||
| 249 | (dolist (delta '(0 0.0 0.25 3.25 1000 1000.25)) | ||
| 250 | (let ((time+ (+ time delta)) | ||
| 251 | (time- (- time delta))) | ||
| 252 | (dolist (form '(nil t list 4 1000 1000000 1000000000)) | ||
| 253 | (should (time-equal-p time (time-convert time form))) | ||
| 254 | (should (time-equal-p time- (time-convert time- form))) | ||
| 255 | (should (time-equal-p time+ (time-convert time+ form)))))))) | ||
| 256 | |||
| 245 | ;;; timefns-tests.el ends here | 257 | ;;; timefns-tests.el ends here |