aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorStephen Gildea2025-12-03 19:49:28 -0800
committerStephen Gildea2025-12-03 23:44:45 -0800
commit7f04e046fb74cda0109e1be9aee790f093fbf003 (patch)
treea29f6d1411f082f36627e72825046069c7188a60 /test
parent335f1a11f072ee05e2ea52ea08bf7df6a42e3e50 (diff)
downloademacs-7f04e046fb74cda0109e1be9aee790f093fbf003.tar.gz
emacs-7f04e046fb74cda0109e1be9aee790f093fbf003.zip
; time-stamp: factor out two small, internal utilities
* lisp/time-stamp.el (time-stamp--message, time-stamp--system-name): New utility functions. (time-stamp, time-stamp-once, time-stamp-string-preprocess): Call the new functions.
Diffstat (limited to 'test')
-rw-r--r--test/lisp/time-stamp-tests.el24
1 files changed, 11 insertions, 13 deletions
diff --git a/test/lisp/time-stamp-tests.el b/test/lisp/time-stamp-tests.el
index 20385fe336b..fe77f102ea2 100644
--- a/test/lisp/time-stamp-tests.el
+++ b/test/lisp/time-stamp-tests.el
@@ -40,14 +40,9 @@
40 (lambda (old-format _new &optional _newer) 40 (lambda (old-format _new &optional _newer)
41 (ert-fail 41 (ert-fail
42 (format "Unexpected format warning for '%s'" old-format)))) 42 (format "Unexpected format warning for '%s'" old-format))))
43 ((symbol-function 'message) 43 ((symbol-function 'time-stamp--message)
44 (lambda (format-string &rest args) 44 (lambda (msg)
45 (ert-fail (format "Unexpected message: %s" 45 (ert-fail (format "Unexpected message: %s" msg)))))
46 (apply #'format format-string args)))))
47 ((symbol-function 'sit-for)
48 (lambda (&rest _args)
49 ;; do not wait during tests
50 )))
51 ;; Not all reference times are used in all tests; 46 ;; Not all reference times are used in all tests;
52 ;; suppress the byte compiler's "unused" warning. 47 ;; suppress the byte compiler's "unused" warning.
53 (list ref-time1 ref-time2 ref-time3) 48 (list ref-time1 ref-time2 ref-time3)
@@ -65,10 +60,13 @@
65 ,@body))) 60 ,@body)))
66 61
67(defmacro with-time-stamp-system-name (name &rest body) 62(defmacro with-time-stamp-system-name (name &rest body)
68 "Force function `system-name' to return NAME while evaluating BODY." 63 "Force `time-stamp--system-name' to return NAME while evaluating BODY."
69 (declare (indent 1) (debug t)) 64 (declare (indent 1) (debug t))
70 `(cl-letf (((symbol-function 'system-name) 65 `(cl-letf (((symbol-function 'time-stamp--system-name)
71 (lambda () ,name))) 66 (lambda (type)
67 (if (and (eq type :short) (string-match "\\." ,name))
68 (substring ,name 0 (match-beginning 0))
69 ,name))))
72 ,@body)) 70 ,@body))
73 71
74 72
@@ -92,10 +90,10 @@
92 (should ,form))) 90 (should ,form)))
93 91
94(defmacro time-stamp-should-message (variable &rest body) 92(defmacro time-stamp-should-message (variable &rest body)
95 "Output a message about VARIABLE if `message' is not called by BODY." 93 "Fail test about VARIABLE if BODY does not call `time-stamp--message'."
96 (declare (indent 1) (debug t)) 94 (declare (indent 1) (debug t))
97 `(time-stamp-test--count-function-calls 95 `(time-stamp-test--count-function-calls
98 message (format "variable %s" ',variable) 96 time-stamp--message (format "variable %s" ',variable)
99 ,@body)) 97 ,@body))
100 98
101;;; Tests: 99;;; Tests: