branch: externals/org
commit c81c844d13c6069f5bd289253de753debcfdc405
Author: Ihor Radchenko <[email protected]>
Commit: Ihor Radchenko <[email protected]>

    test-org/at-timestamp-p: Do not fail on 2025-01-31
    
    * testing/lisp/test-org.el (test-org/org-timestamp-change): Run test
    on specific date.  On day 31 of the month, incrementing/decrementing
    month may fail because Org is forced to adjust the date for months
    that do not have day 31.
---
 testing/lisp/test-org.el | 73 ++++++++++++++++++++++++------------------------
 1 file changed, 37 insertions(+), 36 deletions(-)

diff --git a/testing/lisp/test-org.el b/testing/lisp/test-org.el
index 28087893e3..f885645406 100644
--- a/testing/lisp/test-org.el
+++ b/testing/lisp/test-org.el
@@ -9278,42 +9278,43 @@ CLOSED: %s
 
 (ert-deftest test-org/org-timestamp-change ()
   "Test `org-timestamp-change' specifications."
-  (let ((now (current-time)) now-ts point)
-    (message "Testing with timestamps <%s> and <%s>"
-             (format-time-string (car org-timestamp-formats) now)
-             (format-time-string (cdr org-timestamp-formats) now))
-    ;; loop over regular timestamp formats and weekday-less timestamp
-    ;; formats
-    (dolist (org-timestamp-formats
-             (list org-timestamp-formats
-                   (cons (replace-regexp-in-string
-                          " %a" "" (car org-timestamp-formats))
-                         (replace-regexp-in-string
-                           " %a" "" (cdr org-timestamp-formats)))))
-      ;; loop over timestamps that do not and do contain time
-      (dolist (format (list (car org-timestamp-formats)
-                            (cdr org-timestamp-formats)))
-        (setq now-ts
-              (concat "<" (format-time-string format now) ">"))
-        (org-test-with-temp-text now-ts
-          (forward-char 1)
-          (while (not (eq (char-after) ?>))
-            (skip-syntax-forward "-")
-            ;; change the timestamp unit at point one down, two up,
-            ;; one down, which should give us the original timestamp
-            ;; again.  However, point can move backward during that
-            ;; operation, so take care of that.  *Not* using
-            ;; `save-excursion', which fails to restore point since
-            ;; the timestamp gets completely replaced.
-            (setq point (point))
-            (org-timestamp-change -1 nil nil nil)
-            (org-timestamp-change  2 nil nil nil)
-            (org-timestamp-change -1 nil nil nil)
-            (goto-char point)
-            (should (string=
-                     (buffer-substring (point-min) (point-max))
-                     now-ts))
-            (forward-char 1)))))))
+  (org-test-at-time "2026-01-15"
+    (let ((now (current-time)) now-ts point)
+      (message "Testing with timestamps <%s> and <%s>"
+               (format-time-string (car org-timestamp-formats) now)
+               (format-time-string (cdr org-timestamp-formats) now))
+      ;; loop over regular timestamp formats and weekday-less timestamp
+      ;; formats
+      (dolist (org-timestamp-formats
+               (list org-timestamp-formats
+                     (cons (replace-regexp-in-string
+                            " %a" "" (car org-timestamp-formats))
+                           (replace-regexp-in-string
+                            " %a" "" (cdr org-timestamp-formats)))))
+        ;; loop over timestamps that do not and do contain time
+        (dolist (format (list (car org-timestamp-formats)
+                              (cdr org-timestamp-formats)))
+          (setq now-ts
+                (concat "<" (format-time-string format now) ">"))
+          (org-test-with-temp-text now-ts
+            (forward-char 1)
+            (while (not (eq (char-after) ?>))
+              (skip-syntax-forward "-")
+              ;; change the timestamp unit at point one down, two up,
+              ;; one down, which should give us the original timestamp
+              ;; again.  However, point can move backward during that
+              ;; operation, so take care of that.  *Not* using
+              ;; `save-excursion', which fails to restore point since
+              ;; the timestamp gets completely replaced.
+              (setq point (point))
+              (org-timestamp-change -1 nil nil nil)
+              (org-timestamp-change  2 nil nil nil)
+              (org-timestamp-change -1 nil nil nil)
+              (goto-char point)
+              (should (string=
+                       (buffer-substring (point-min) (point-max))
+                       now-ts))
+              (forward-char 1))))))))
 
 (ert-deftest test-org/timestamp ()
   "Test `org-timestamp' specifications."

Reply via email to