aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorStephen Gildea2021-10-22 08:38:17 -0700
committerStephen Gildea2021-10-22 08:39:05 -0700
commitefde024361456b97277120b29d663d79ea5b287c (patch)
tree1d979ce363f41efc1cf221629287aef1b2317550 /test
parent06c944cff1a8a348b9c01a92891bd12576c0896d (diff)
downloademacs-efde024361456b97277120b29d663d79ea5b287c.tar.gz
emacs-efde024361456b97277120b29d663d79ea5b287c.zip
time-stamp-tests: improvements to test macros
test/lisp/time-stamp-tests.el: Update macro declarations. (formatz-generate-tests): Don't nconc onto a constant list. Tests now run 12% faster in batch mode.
Diffstat (limited to 'test')
-rw-r--r--test/lisp/time-stamp-tests.el13
1 files changed, 8 insertions, 5 deletions
diff --git a/test/lisp/time-stamp-tests.el b/test/lisp/time-stamp-tests.el
index 0449704b418..fa9edcbd407 100644
--- a/test/lisp/time-stamp-tests.el
+++ b/test/lisp/time-stamp-tests.el
@@ -26,7 +26,7 @@
26 26
27(defmacro with-time-stamp-test-env (&rest body) 27(defmacro with-time-stamp-test-env (&rest body)
28 "Evaluate BODY with some standard time-stamp test variables bound." 28 "Evaluate BODY with some standard time-stamp test variables bound."
29 (declare (indent defun)) 29 (declare (indent 0) (debug t))
30 `(let ((user-login-name "test-logname") 30 `(let ((user-login-name "test-logname")
31 (user-full-name "100%d Tester") ;verify "%" passed unchanged 31 (user-full-name "100%d Tester") ;verify "%" passed unchanged
32 (buffer-file-name "/emacs/test/time-stamped-file") 32 (buffer-file-name "/emacs/test/time-stamped-file")
@@ -46,7 +46,7 @@
46 46
47(defmacro with-time-stamp-test-time (reference-time &rest body) 47(defmacro with-time-stamp-test-time (reference-time &rest body)
48 "Force any contained time-stamp call to use time REFERENCE-TIME." 48 "Force any contained time-stamp call to use time REFERENCE-TIME."
49 (declare (indent defun)) 49 (declare (indent 1) (debug t))
50 `(cl-letf* 50 `(cl-letf*
51 ((orig-time-stamp-string-fn (symbol-function 'time-stamp-string)) 51 ((orig-time-stamp-string-fn (symbol-function 'time-stamp-string))
52 ((symbol-function 'time-stamp-string) 52 ((symbol-function 'time-stamp-string)
@@ -56,13 +56,14 @@
56 56
57(defmacro with-time-stamp-system-name (name &rest body) 57(defmacro with-time-stamp-system-name (name &rest body)
58 "Force (system-name) to return NAME while evaluating BODY." 58 "Force (system-name) to return NAME while evaluating BODY."
59 (declare (indent defun)) 59 (declare (indent 1) (debug t))
60 `(cl-letf (((symbol-function 'system-name) 60 `(cl-letf (((symbol-function 'system-name)
61 (lambda () ,name))) 61 (lambda () ,name)))
62 ,@body)) 62 ,@body))
63 63
64(defmacro time-stamp-should-warn (form) 64(defmacro time-stamp-should-warn (form)
65 "Similar to `should' but verifies that a format warning is generated." 65 "Similar to `should' but verifies that a format warning is generated."
66 (declare (debug t))
66 `(let ((warning-count 0)) 67 `(let ((warning-count 0))
67 (cl-letf (((symbol-function 'time-stamp-conv-warn) 68 (cl-letf (((symbol-function 'time-stamp-conv-warn)
68 (lambda (_old _new) 69 (lambda (_old _new)
@@ -761,6 +762,7 @@ and is used for testing."
761 "Formats ZONE and compares it to EXPECT. 762 "Formats ZONE and compares it to EXPECT.
762Uses the free variables `form-string' and `pattern-mod'. 763Uses the free variables `form-string' and `pattern-mod'.
763The functions in `pattern-mod' are composed left to right." 764The functions in `pattern-mod' are composed left to right."
765 (declare (debug t))
764 `(let ((result ,expect)) 766 `(let ((result ,expect))
765 (dolist (fn pattern-mod) 767 (dolist (fn pattern-mod)
766 (setq result (funcall fn result))) 768 (setq result (funcall fn result)))
@@ -895,10 +897,11 @@ BIG-MOD is the result for offset +100 hours and modifiers for the other
895expected results for hours greater than 99 with a whole number of minutes. 897expected results for hours greater than 99 with a whole number of minutes.
896SECBIG-MOD is the result for offset +100 hours 30 seconds and modifiers for 898SECBIG-MOD is the result for offset +100 hours 30 seconds and modifiers for
897the other expected results for hours greater than 99 with non-zero seconds." 899the other expected results for hours greater than 99 with non-zero seconds."
898 (declare (indent 1)) 900 (declare (indent 1) (debug (&rest sexp)))
899 ;; Generate a form to create a list of tests to define. When this 901 ;; Generate a form to create a list of tests to define. When this
900 ;; macro is called, the form is evaluated, thus defining the tests. 902 ;; macro is called, the form is evaluated, thus defining the tests.
901 (let ((ert-test-list '(list))) 903 ;; We will modify this list, so start with a list consed at runtime.
904 (let ((ert-test-list (list 'list)))
902 (dolist (form-string form-strings ert-test-list) 905 (dolist (form-string form-strings ert-test-list)
903 (nconc 906 (nconc
904 ert-test-list 907 ert-test-list