emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Ruijie Yu via "General discussions about Org-mode." <emacs-orgmode@gnu.org>
To: Ihor Radchenko <yantar92@posteo.net>
Cc: Axel Kielhorn <org-mode@axelkielhorn.de>, emacs-orgmode@gnu.org
Subject: Re: [DRAFT PATCH v5] Decouple LANG= and testing (was: Test failure due to LANG)
Date: Tue, 25 Apr 2023 16:02:38 +0800	[thread overview]
Message-ID: <sdvfs8os6es.fsf@netyu.xyz> (raw)
In-Reply-To: <874jp64oxr.fsf@localhost>

[-- Attachment #1: Type: text/plain, Size: 1175 bytes --]


Ihor Radchenko <yantar92@posteo.net> writes:

> (let ((org-time-stamp-formats '("%Y-%m-%d" . "%Y-%m-%d %H:%M")))
>      (org-element-timestamp-interpreter timestamp nil))

Thanks for the pointer.  I have made this into a macro and redid my
changes accordingly.  Please also let me know if more work should be
dedicated to avoid code duplication in tests (I see a lot of duplication
in the portions I touched in testing/lisp/test-org.el).

What currently still fails unexpectedly:

zh_CN.UTF-8:
    test-org-clock/clocktable/lang
    - This test only fails in batch mode, as I mentioned up-thread.  I
      might try to convert this into a test that expects failure
      depending on whether Emacs is in batch mode.
    test-org-colview/columns-width
    - This patch did not attempt to fix it.  I posted a diff file under
      v2 (not included in this patch), but that didn't work either.

ja_JA.UTF-8:
    test-org-colview/columns-width
    - See above.

fr_FR.UTF-8:
    test-org-clok/org-clock-timestamps-change
    - This is tracked in the other thread I created, and won't be fixed
      by this patch.

en_US.UTF-8 and de_DE.UTF-8:
    No unexpected test failures.


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-DRAFT-Fix-dependence-on-locale-in-org-testing-facili.patch --]
[-- Type: text/x-patch, Size: 33280 bytes --]

From d17e33802b0e53af131a2ab3f44d9ee3ecfb2a59 Mon Sep 17 00:00:00 2001
From: Ruijie Yu <ruijie@netyu.xyz>
Date: Sat, 22 Apr 2023 20:36:18 +0800
Subject: [PATCH] [DRAFT] Fix dependence on locale in org testing facilities

* testing/org-test.el org-test-day-of-weeks-seconds: add values of
seconds that yield different days of week (by trial-and-error).
org-test-day-of-weeks-abbrev: add a vector of abbreviated DoW
names for testing.
org-test-day-of-weeks-full: add a vector of full DoW names for
testing.

* testing/lisp/test-org-clock.el
(test-org-clock/clock-drawer-dwim): make use of the pre-generated
DoW names in the testing to remove assumptions on LANG=C.
(test-org-clock/org-clock-timestamps-change): renamed from
test-org-clok/org-clock-timestamps-change; used DoW pre-generated
names.

* testing/lisp/test-org.el (org-test-with-result):
(org-test-without-dow): add two macros to combat the 40-time
repetition of "do not add day-of-week, do something, and return
buffer string".
(test-org/clone-with-time-shift): (test-org/add-planning-info):
(test-org/deadline): (test-org/schedule): rewrite the
day-of-week-removal portion to avoid generating day-of-week names
altogether, using the new macro `org-test-without-dow'.
---
 testing/lisp/test-org-clock.el |  64 ++---
 testing/lisp/test-org.el       | 415 +++++++++++++++------------------
 testing/org-test.el            |  25 ++
 3 files changed, 250 insertions(+), 254 deletions(-)

diff --git a/testing/lisp/test-org-clock.el b/testing/lisp/test-org-clock.el
index 7d8123e1f..d4beb76e0 100644
--- a/testing/lisp/test-org-clock.el
+++ b/testing/lisp/test-org-clock.el
@@ -89,29 +89,34 @@ the buffer."
     ;; Remove clocktable.
     (delete-region (point) (search-forward "#+END:\n"))))
 
-(ert-deftest test-org-clok/org-clock-timestamps-change ()
+(ert-deftest test-org-clock/org-clock-timestamps-change ()
   "Test `org-clock-timestamps-change' specifications."
-  (should
-   (equal
-    "CLOCK: [2023-02-19 Sun 21:30]--[2023-02-19 Sun 23:35] =>  2:05"
-    (org-test-with-temp-text
-        "CLOCK: [2023-02-19 Sun 2<point>2:30]--[2023-02-20 Mon 00:35] =>  2:05"
-      (org-clock-timestamps-change 'down 1)
-      (buffer-string))))
-  (should
-   (equal
-    "CLOCK: [2023-02-20 Mon 00:00]--[2023-02-20 Mon 00:40] =>  0:40"
-    (org-test-with-temp-text
-        "CLOCK: [2023-02-19 Sun 23:<point>55]--[2023-02-20 Mon 00:35] =>  0:40"
-      (org-clock-timestamps-change 'up 1)
-      (buffer-string))))
-  (should
-   (equal
-    "CLOCK: [2023-02-20 Mon 00:30]--[2023-02-20 Mon 01:35] =>  1:05"
-    (org-test-with-temp-text
-        "CLOCK: [2023-02-19 Sun 2<point>3:30]--[2023-02-20 Mon 00:35] =>  1:05"
-      (org-clock-timestamps-change 'up 1)
-      (buffer-string)))))
+  (let ((sun (aref org-test-day-of-weeks-abbrev 0))
+        (mon (aref org-test-day-of-weeks-abbrev 1)))
+    (should
+     (equal
+      (format "CLOCK: [2023-02-19 %s 21:30]--[2023-02-19 %s 23:35] =>  2:05"
+              sun sun)
+      (org-test-with-temp-text
+          "CLOCK: [2023-02-19 Sun 2<point>2:30]--[2023-02-20 Mon 00:35] =>  2:05"
+        (org-clock-timestamps-change 'down 1)
+        (buffer-string))))
+    (should
+     (equal
+      (format "CLOCK: [2023-02-20 %s 00:00]--[2023-02-20 %s 00:40] =>  0:40"
+              mon mon)
+      (org-test-with-temp-text
+          "CLOCK: [2023-02-19 Sun 23:<point>55]--[2023-02-20 Mon 00:35] =>  0:40"
+        (org-clock-timestamps-change 'up 1)
+        (buffer-string))))
+    (should
+     (equal
+      (format "CLOCK: [2023-02-20 %s 00:30]--[2023-02-20 %s 01:35] =>  1:05"
+              mon mon)
+      (org-test-with-temp-text
+          "CLOCK: [2023-02-19 Sun 2<point>3:30]--[2023-02-20 Mon 00:35] =>  1:05"
+        (org-clock-timestamps-change 'up 1)
+        (buffer-string))))))
 
 \f
 ;;; Clock drawer
@@ -299,19 +304,20 @@ the buffer."
 
 (ert-deftest test-org-clock/clock-drawer-dwim ()
   "Test DWIM update of days for clocks in logbook drawers."
-  (should (equal "* Foo
+  (let ((thu (aref org-test-day-of-weeks-abbrev 4)))
+    (should (equal (format "* Foo
 :LOGBOOK:
-CLOCK: [2022-11-03 Thu 06:00]--[2022-11-03 Thu 06:01] =>  0:01
+CLOCK: [2022-11-03 %s 06:00]--[2022-11-03 %s 06:01] =>  0:01
 :END:
-"
-         (org-test-with-temp-text
-             "* Foo
+" thu thu)
+                   (org-test-with-temp-text
+                       "* Foo
 :LOGBOOK:
 <point>CLOCK: [2022-11-03 ??? 06:00]--[2022-11-03 ??? 06:01] =>  0:01
 :END:
 "
-           (org-ctrl-c-ctrl-c)
-           (buffer-string)))))
+                     (org-ctrl-c-ctrl-c)
+                     (buffer-string))))))
 
 \f
 ;;; Clocktable
diff --git a/testing/lisp/test-org.el b/testing/lisp/test-org.el
index d7c801fe5..e5581f140 100644
--- a/testing/lisp/test-org.el
+++ b/testing/lisp/test-org.el
@@ -43,6 +43,40 @@
              ,@body)
              (setenv "TZ" ,tz-saved)))))
 
+(defmacro org-test-with-result (result &rest body)
+  "Evaluate BODY, and return buffer content based on RESULT.
+RESULT is an sexp, and is processed according to the following
+rules.
+
+If RESULT is the quoted symbol `buffer', return buffer string.
+
+If RESULT is the quoted symbol `buffer-no-properties', return
+buffer string with no properties.
+
+If RESULT is a positive integer, return the RESULT-th line of the
+buffer.
+
+Otherwise, evaluate RESULT as an sexp and return its result."
+  (declare (indent 1))
+  `(progn ,@body
+          ,(pcase result
+             (''buffer-no-properties
+              '(buffer-substring-no-properties
+                (point-min) (point-max)))
+             (''buffer '(buffer-string))
+             ((and (pred numberp) (pred cl-plusp))
+              `(buffer-substring (line-beginning-position ,result)
+                                 (line-end-position ,result)))
+             (_ result))))
+
+(defmacro org-test-without-dow (result &rest body)
+  "Eval BODY skipping day-of-week in timestamps.
+See `org-test-with-result' for RESULT and the return value."
+  (declare (indent 1))
+  `(let ((org-time-stamp-formats '("%Y-%m-%d" . "%Y-%m-%d %H:%M")))
+     ;; ,(macroexpand-1 `(org-test-with-result ,result ,@body))
+     (org-test-with-result ,result ,@body)))
+
 \f
 ;;; Comments
 
@@ -2013,11 +2047,9 @@ CLOCK: [2022-09-17 sam. 11:00]--[2022-09-17 sam. 11:46] =>  0:46"
 * H1\n<2015-06-21>
 * H1\n<2015-06-23>
 "
-	  (org-test-with-temp-text "* H1\n<2015-06-21 Sun>"
-	    (org-clone-subtree-with-time-shift 1 "+2d")
-	    (replace-regexp-in-string
-	     "\\( [.A-Za-z]+\\)\\( \\+[0-9][hdmwy]\\)?>" "" (buffer-string)
-	     nil nil 1))))
+          (org-test-with-temp-text "* H1\n<2015-06-21>"
+            (org-test-without-dow 'buffer
+              (org-clone-subtree-with-time-shift 1 "+2d")))))
   ;; Clone repeating once.
   (should
    (equal "\
@@ -2025,11 +2057,9 @@ CLOCK: [2022-09-17 sam. 11:00]--[2022-09-17 sam. 11:46] =>  0:46"
 * H1\n<2015-06-23>
 * H1\n<2015-06-25 +1w>
 "
-	  (org-test-with-temp-text "* H1\n<2015-06-21 Sun +1w>"
-	    (org-clone-subtree-with-time-shift 1 "+2d")
-	    (replace-regexp-in-string
-	     "\\( [.A-Za-z]+\\)\\( \\+[0-9][hdmwy]\\)?>" "" (buffer-string)
-	     nil nil 1))))
+          (org-test-with-temp-text "* H1\n<2015-06-21 +1w>"
+            (org-test-without-dow 'buffer
+              (org-clone-subtree-with-time-shift 1 "+2d")))))
   ;; Clone repeating once in backward.
   (should
    (equal "\
@@ -2037,58 +2067,49 @@ CLOCK: [2022-09-17 sam. 11:00]--[2022-09-17 sam. 11:46] =>  0:46"
 * H1\n<2015-06-19>
 * H1\n<2015-06-17 +1w>
 "
-	  (org-test-with-temp-text "* H1\n<2015-06-21 Sun +1w>"
-	    (org-clone-subtree-with-time-shift 1 "-2d")
-	    (replace-regexp-in-string
-	     "\\( [.A-Za-z]+\\)\\( \\+[0-9][hdmwy]\\)?>" "" (buffer-string)
-	     nil nil 1))))
+          (org-test-with-temp-text "* H1\n<2015-06-21 +1w>"
+            (org-test-without-dow 'buffer
+              (org-clone-subtree-with-time-shift 1 "-2d")))))
   ;; Clone non-repeating zero times.
   (should
    (equal "\
 * H1\n<2015-06-21>
 "
-	  (org-test-with-temp-text "* H1\n<2015-06-21 Sun>"
-	    (org-clone-subtree-with-time-shift 0 "+2d")
-	    (replace-regexp-in-string
-	     "\\( [.A-Za-z]+\\)\\( \\+[0-9][hdmwy]\\)?>" "" (buffer-string)
-	     nil nil 1))))
+          (org-test-with-temp-text "* H1\n<2015-06-21>"
+            (org-test-without-dow 'buffer
+              (org-clone-subtree-with-time-shift 0 "+2d")))))
   ;; Clone repeating "zero" times.
   (should
    (equal "\
 * H1\n<2015-06-21>
 * H1\n<2015-06-23 +1w>
 "
-	  (org-test-with-temp-text "* H1\n<2015-06-21 Sun +1w>"
-	    (org-clone-subtree-with-time-shift 0 "+2d")
-	    (replace-regexp-in-string
-	     "\\( [.A-Za-z]+\\)\\( \\+[0-9][hdmwy]\\)?>" "" (buffer-string)
-	     nil nil 1))))
+          (org-test-with-temp-text "* H1\n<2015-06-21 +1w>"
+            (org-test-without-dow 'buffer
+              (org-clone-subtree-with-time-shift 0 "+2d")))))
   ;; Clone with blank SHIFT argument.
   (should
    (string-prefix-p
     "* H <2012-03-29"
     (org-test-with-temp-text "* H <2012-03-29 Thu><point>"
-      (org-clone-subtree-with-time-shift 1 "")
-      (buffer-substring-no-properties (line-beginning-position 2)
-				      (line-end-position 2)))))
+      (org-test-without-dow 2
+        (org-clone-subtree-with-time-shift 1 "")))))
   ;; Find time stamps before point.  If SHIFT is not specified, ask
   ;; for a time shift.
   (should
    (string-prefix-p
     "* H <2012-03-30"
     (org-test-with-temp-text "* H <2012-03-29 Thu><point>"
-      (org-clone-subtree-with-time-shift 1 "+1d")
-      (buffer-substring-no-properties (line-beginning-position 2)
-				      (line-end-position 2)))))
+      (org-test-without-dow 2
+        (org-clone-subtree-with-time-shift 1 "+1d")))))
   (should
    (string-prefix-p
     "* H <2014-03-05"
     (org-test-with-temp-text "* H <2014-03-04 Tue><point>"
       (cl-letf (((symbol-function 'read-from-minibuffer)
-		 (lambda (&rest _args) "+1d")))
-	(org-clone-subtree-with-time-shift 1))
-      (buffer-substring-no-properties (line-beginning-position 2)
-				      (line-end-position 2)))))
+                 (lambda (&rest _args) "+1d")))
+        (org-test-without-dow 2
+          (org-clone-subtree-with-time-shift 1))))))
   ;; Hour shift.
   (should
    (equal "\
@@ -2096,23 +2117,17 @@ CLOCK: [2022-09-17 sam. 11:00]--[2022-09-17 sam. 11:46] =>  0:46"
 * H1\n<2015-06-21 23:00>
 * H1\n<2015-06-22 02:00>
 "
-          (org-test-with-temp-text "* H1\n<2015-06-21 Sun 20:00>"
-            (org-clone-subtree-with-time-shift 2 "+3h")
-            (replace-regexp-in-string
-             "\\( [.A-Za-z]+\\)\\( [0-9][0-9]:[0-9][0-9]\\)?>" ""
-             (buffer-substring-no-properties (point-min) (point-max))
-             nil nil 1))))
+          (org-test-with-temp-text "* H1\n<2015-06-21 20:00>"
+            (org-test-without-dow 'buffer
+              (org-clone-subtree-with-time-shift 2 "+3h")))))
   (should
    (equal "\
 * H1\n<2015-06-21 20:00>
 * H1\n<2015-06-21 18:00>
 "
-          (org-test-with-temp-text "* H1\n<2015-06-21 Sun 20:00>"
-            (org-clone-subtree-with-time-shift 1 "-2h")
-            (replace-regexp-in-string
-             "\\( [.A-Za-z]+\\)\\( [0-9][0-9]:[0-9][0-9]\\)?>" ""
-             (buffer-substring-no-properties (point-min) (point-max))
-             nil nil 1)))))
+          (org-test-with-temp-text "* H1\n<2015-06-21 20:00>"
+            (org-test-without-dow 'buffer
+              (org-clone-subtree-with-time-shift 1 "-2h"))))))
 
 \f
 ;;; Fixed-Width Areas
@@ -5626,21 +5641,17 @@ Text.
   ;; Create deadline when `org-adapt-indentation' is non-nil.
   (should
    (equal "* H\n  DEADLINE: <2015-06-25>\nParagraph"
-	  (org-test-with-temp-text "* H\nParagraph<point>"
-	    (let ((org-adapt-indentation t))
-	      (org-add-planning-info 'deadline "<2015-06-25 Thu>"))
-	    (replace-regexp-in-string
-	     "\\( [.A-Za-z]+\\)>" "" (buffer-string)
-	     nil nil 1))))
+          (org-test-with-temp-text "* H\nParagraph<point>"
+            (let ((org-adapt-indentation t))
+              (org-test-without-dow 'buffer
+                (org-add-planning-info 'deadline "<2015-06-25 Thu>"))))))
   ;; Create deadline when `org-adapt-indentation' is nil.
   (should
    (equal "* H\nDEADLINE: <2015-06-25>\nParagraph"
 	  (org-test-with-temp-text "* H\nParagraph<point>"
 	    (let ((org-adapt-indentation nil))
-	      (org-add-planning-info 'deadline "<2015-06-25 Thu>"))
-	    (replace-regexp-in-string
-	     "\\( [.A-Za-z]+\\)>" "" (buffer-string)
-	     nil nil 1))))
+	      (org-test-without-dow 'buffer
+                (org-add-planning-info 'deadline "<2015-06-25 Thu>"))))))
   ;; Update deadline when `org-adapt-indentation' is non-nil.
   (should
    (equal "* H\n  DEADLINE: <2015-06-25>\nParagraph"
@@ -5649,10 +5660,8 @@ Text.
   DEADLINE: <2015-06-24 Wed>
 Paragraph<point>"
 	    (let ((org-adapt-indentation t))
-	      (org-add-planning-info 'deadline "<2015-06-25 Thu>"))
-	    (replace-regexp-in-string
-	     "\\( [.A-Za-z]+\\)>" "" (buffer-string)
-	     nil nil 1))))
+	      (org-test-without-dow 'buffer
+                (org-add-planning-info 'deadline "<2015-06-25 Thu>"))))))
   ;; Update deadline when `org-adapt-indentation' is nil.
   (should
    (equal "* H\nDEADLINE: <2015-06-25>\nParagraph"
@@ -5661,28 +5670,22 @@ Paragraph<point>"
 DEADLINE: <2015-06-24 Wed>
 Paragraph<point>"
 	    (let ((org-adapt-indentation nil))
-	      (org-add-planning-info 'deadline "<2015-06-25 Thu>"))
-	    (replace-regexp-in-string
-	     "\\( [.A-Za-z]+\\)>" "" (buffer-string)
-	     nil nil 1))))
+	      (org-test-without-dow 'buffer
+                (org-add-planning-info 'deadline "<2015-06-25 Thu>"))))))
   ;; Schedule when `org-adapt-indentation' is non-nil.
   (should
    (equal "* H\n  SCHEDULED: <2015-06-25>\nParagraph"
 	  (org-test-with-temp-text "* H\nParagraph<point>"
 	    (let ((org-adapt-indentation t))
-	      (org-add-planning-info 'scheduled "<2015-06-25 Thu>"))
-	    (replace-regexp-in-string
-	     "\\( [.A-Za-z]+\\)>" "" (buffer-string)
-	     nil nil 1))))
+	      (org-test-without-dow 'buffer
+                (org-add-planning-info 'scheduled "<2015-06-25 Thu>"))))))
   ;; Schedule when `org-adapt-indentation' is nil.
   (should
    (equal "* H\nSCHEDULED: <2015-06-25>\nParagraph"
 	  (org-test-with-temp-text "* H\nParagraph<point>"
 	    (let ((org-adapt-indentation nil))
-	      (org-add-planning-info 'scheduled "<2015-06-25 Thu>"))
-	    (replace-regexp-in-string
-	     "\\( [.A-Za-z]+\\)>" "" (buffer-string)
-	     nil nil 1))))
+	      (org-test-without-dow 'buffer
+                (org-add-planning-info 'scheduled "<2015-06-25 Thu>"))))))
   ;; Add deadline when scheduled.
   (should
    (equal "\
@@ -5691,13 +5694,11 @@ Paragraph<point>"
 Paragraph"
 	  (org-test-with-temp-text "\
 * H
-  SCHEDULED: <2015-06-24 Wed>
+  SCHEDULED: <2015-06-24>
 Paragraph<point>"
 	    (let ((org-adapt-indentation t))
-	      (org-add-planning-info 'deadline "<2015-06-25 Thu>"))
-	    (replace-regexp-in-string
-	     "\\( [.A-Za-z]+\\)>" "" (buffer-string)
-	     nil nil 1))))
+	      (org-test-without-dow 'buffer
+                (org-add-planning-info 'deadline "<2015-06-25 Thu>"))))))
   ;; Remove middle entry.
   (should
    (equal "\
@@ -5706,13 +5707,11 @@ Paragraph<point>"
 Paragraph"
 	  (org-test-with-temp-text "\
 * H
-  CLOSED: [2015-06-24 Wed] DEADLINE: <2015-06-25 Thu> SCHEDULED: <2015-06-24 Wed>
+  CLOSED: [2015-06-24] DEADLINE: <2015-06-25 Thu> SCHEDULED: <2015-06-24>
 Paragraph<point>"
 	    (let ((org-adapt-indentation t))
-	      (org-add-planning-info nil nil 'deadline))
-	    (replace-regexp-in-string
-	     "\\( [.A-Za-z]+\\)[]>]" "" (buffer-string)
-	     nil nil 1))))
+	      (org-test-without-dow 'buffer
+                (org-add-planning-info nil nil 'deadline))))))
   ;; Remove last entry and then middle entry (order should not
   ;; matter).
   (should
@@ -5722,25 +5721,21 @@ Paragraph<point>"
 Paragraph"
 	  (org-test-with-temp-text "\
 * H
-  CLOSED: [2015-06-24 Wed] DEADLINE: <2015-06-25 Thu> SCHEDULED: <2015-06-24 Wed>
+  CLOSED: [2015-06-24] DEADLINE: <2015-06-25 Thu> SCHEDULED: <2015-06-24 Wed>
 Paragraph<point>"
 	    (let ((org-adapt-indentation t))
-	      (org-add-planning-info nil nil 'scheduled 'deadline))
-	    (replace-regexp-in-string
-	     "\\( [.A-Za-z]+\\)[]>]" "" (buffer-string)
-	     nil nil 1))))
+	      (org-test-without-dow 'buffer
+                (org-add-planning-info nil nil 'scheduled 'deadline))))))
   ;; Remove closed when `org-adapt-indentation' is non-nil.
   (should
    (equal "* H\n  DEADLINE: <2015-06-25>\nParagraph"
 	  (org-test-with-temp-text "\
 * H
-  CLOSED: [2015-06-25 Thu] DEADLINE: <2015-06-25 Thu>
+  CLOSED: [2015-06-25 Thu] DEADLINE: <2015-06-25>
 Paragraph<point>"
 	    (let ((org-adapt-indentation t))
-	      (org-add-planning-info nil nil 'closed))
-	    (replace-regexp-in-string
-	     "\\( [.A-Za-z]+\\)>" "" (buffer-string)
-	     nil nil 1))))
+	      (org-test-without-dow 'buffer
+                (org-add-planning-info nil nil 'closed))))))
   (should
    (equal "* H\n  Paragraph"
 	  (org-test-with-temp-text "\
@@ -5748,22 +5743,18 @@ Paragraph<point>"
   CLOSED: [2015-06-25 Thu]
   Paragraph<point>"
 	    (let ((org-adapt-indentation t))
-	      (org-add-planning-info nil nil 'closed))
-	    (replace-regexp-in-string
-	     "\\( [.A-Za-z]+\\)>" "" (buffer-string)
-	     nil nil 1))))
+	      (org-test-without-dow 'buffer
+                (org-add-planning-info nil nil 'closed))))))
   ;; Remove closed when `org-adapt-indentation' is nil.
   (should
    (equal "* H\nDEADLINE: <2015-06-25>\nParagraph"
 	  (org-test-with-temp-text "\
 * H
-CLOSED: [2015-06-25 Thu] DEADLINE: <2015-06-25 Thu>
+CLOSED: [2015-06-25 Thu] DEADLINE: <2015-06-25>
 Paragraph<point>"
 	    (let ((org-adapt-indentation nil))
-	      (org-add-planning-info nil nil 'closed))
-	    (replace-regexp-in-string
-	     "\\( [.A-Za-z]+\\)>" "" (buffer-string)
-	     nil nil 1))))
+	      (org-test-without-dow 'buffer
+                (org-add-planning-info nil nil 'closed))))))
   (should
    (equal "* H\nParagraph"
 	  (org-test-with-temp-text "\
@@ -5771,10 +5762,8 @@ Paragraph<point>"
   CLOSED: [2015-06-25 Thu]
 Paragraph<point>"
 	    (let ((org-adapt-indentation nil))
-	      (org-add-planning-info nil nil 'closed))
-	    (replace-regexp-in-string
-	     "\\( [.A-Za-z]+\\)>" "" (buffer-string)
-	     nil nil 1))))
+	      (org-test-without-dow 'buffer
+                (org-add-planning-info nil nil 'closed))))))
   ;; Remove closed entry and delete empty line.
   (should
    (equal "\
@@ -5785,10 +5774,8 @@ Paragraph"
   CLOSED: [2015-06-24 Wed]
 Paragraph<point>"
 	    (let ((org-adapt-indentation t))
-	      (org-add-planning-info nil nil 'closed))
-	    (replace-regexp-in-string
-	     "\\( [.A-Za-z]+\\)>" "" (buffer-string)
-	     nil nil 1))))
+	      (org-test-without-dow 'buffer
+                (org-add-planning-info nil nil 'closed))))))
   ;; Remove one entry and update another.
   (should
    (equal "* H\n  DEADLINE: <2015-06-25>\nParagraph"
@@ -5797,10 +5784,8 @@ Paragraph<point>"
   SCHEDULED: <2015-06-23 Tue> DEADLINE: <2015-06-24 Wed>
 Paragraph<point>"
 	    (let ((org-adapt-indentation t))
-	      (org-add-planning-info 'deadline "<2015-06-25 Thu>" 'scheduled))
-	    (replace-regexp-in-string
-	     "\\( [.A-Za-z]+\\)>" "" (buffer-string)
-	     nil nil 1)))))
+	      (org-test-without-dow 'buffer
+                (org-add-planning-info 'deadline "<2015-06-25 Thu>" 'scheduled)))))))
 
 (ert-deftest test-org/deadline ()
   "Test `org-deadline' specifications."
@@ -5810,19 +5795,15 @@ Paragraph<point>"
 	  (org-test-with-temp-text "* H"
 	    (let ((org-adapt-indentation nil)
 		  (org-last-inserted-timestamp nil))
-	      (org-deadline nil "<2012-03-29 Tue>"))
-	    (replace-regexp-in-string
-	     "\\( [.A-Za-z]+\\)>" "" (buffer-string)
-	     nil nil 1))))
+	      (org-test-without-dow 'buffer
+                (org-deadline nil "<2012-03-29 Tue>"))))))
   (should
    (equal "* H\nDEADLINE: <2014-03-04>"
 	  (org-test-with-temp-text "* H\nDEADLINE: <2012-03-29>"
 	    (let ((org-adapt-indentation nil)
 		  (org-last-inserted-timestamp nil))
-	      (org-deadline nil "<2014-03-04 Thu>"))
-	    (replace-regexp-in-string
-	     "\\( [.A-Za-z]+\\)>" "" (buffer-string)
-	     nil nil 1))))
+	      (org-test-without-dow 'buffer
+                (org-deadline nil "<2014-03-04 Thu>"))))))
   ;; Accept delta time, e.g., "+2d".
   (should
    (equal "* H\nDEADLINE: <2015-03-04>"
@@ -5830,44 +5811,39 @@ Paragraph<point>"
 	    (org-test-with-temp-text "* H"
 	      (let ((org-adapt-indentation nil)
 		    (org-last-inserted-timestamp nil))
-		(org-deadline nil "+1y"))
-	      (replace-regexp-in-string
-	       "\\( [.A-Za-z]+\\)>" "" (buffer-string) nil nil 1)))))
+		(org-test-without-dow 'buffer
+                  (org-deadline nil "+1y")))))))
   ;; Preserve repeater.
   (should
    (equal "* H\nDEADLINE: <2012-03-29 +2y>"
 	  (org-test-with-temp-text "* H"
 	    (let ((org-adapt-indentation nil)
 		  (org-last-inserted-timestamp nil))
-	      (org-deadline nil "<2012-03-29 Tue +2y>"))
-	    (replace-regexp-in-string
-	     "\\( [.A-Za-z]+\\) " "" (buffer-string) nil nil 1))))
+	      (org-test-without-dow 'buffer
+                (org-deadline nil "<2012-03-29 Tue +2y>"))))))
   ;; Preserve warning period.
   (should
    (equal "* H\nDEADLINE: <2021-07-20 -1d>"
 	  (org-test-with-temp-text "* H"
 	    (let ((org-adapt-indentation nil)
 		  (org-last-inserted-timestamp nil))
-	      (org-deadline nil "<2021-07-20 Tue -1d>"))
-	    (replace-regexp-in-string
-	     "\\( [.A-Za-z]+\\) " "" (buffer-string) nil nil 1))))
+	      (org-test-without-dow 'buffer
+                (org-deadline nil "<2021-07-20 Tue -1d>"))))))
   (should
    (equal "* H\nDEADLINE: <2021-07-20 +1m -3d>"
 	  (org-test-with-temp-text "* H"
 	    (let ((org-adapt-indentation nil)
 		  (org-last-inserted-timestamp nil))
-	      (org-deadline nil "<2021-07-20 Tue +1m -3d>"))
-	    (replace-regexp-in-string
-	     "\\( [.A-Za-z]+\\) " "" (buffer-string) nil nil 1))))
+	      (org-test-without-dow 'buffer
+                (org-deadline nil "<2021-07-20 Tue +1m -3d>"))))))
   ;; Remove CLOSED keyword, if any.
   (should
    (equal "* H\nDEADLINE: <2012-03-29>"
 	  (org-test-with-temp-text "* H\nCLOSED: [2017-01-25 Wed]"
 	    (let ((org-adapt-indentation nil)
 		  (org-last-inserted-timestamp nil))
-	      (org-deadline nil "<2012-03-29 Tue>"))
-	    (replace-regexp-in-string
-	     "\\( [.A-Za-z]+\\)>" "" (buffer-string) nil nil 1))))
+	      (org-test-without-dow 'buffer
+                (org-deadline nil "<2012-03-29 Tue>"))))))
   ;; With C-u argument, remove DEADLINE keyword.
   (should
    (equal "* H\n"
@@ -5912,12 +5888,11 @@ Paragraph<point>"
 	    (let ((org-adapt-indentation nil)
 		  (org-last-inserted-timestamp nil)
 		  (org-loop-over-headlines-in-active-region t))
-	      (transient-mark-mode 1)
+              (transient-mark-mode 1)
 	      (push-mark (point) t t)
 	      (goto-char (point-max))
-	      (org-deadline nil "2012-03-29"))
-	    (replace-regexp-in-string
-	     "\\( [.A-Za-z]+\\)>" "" (buffer-string) nil nil 1))))
+              (org-test-without-dow 'buffer
+	        (org-deadline nil "2012-03-29"))))))
   (should-not
    (equal "* H1\nDEADLINE: <2012-03-29>\n* H2\nDEADLINE: <2012-03-29>"
 	  (org-test-with-temp-text "* H1\n* H2"
@@ -5927,130 +5902,120 @@ Paragraph<point>"
 	      (transient-mark-mode 1)
 	      (push-mark (point) t t)
 	      (goto-char (point-max))
-	      (org-deadline nil "2012-03-29"))
-	    (replace-regexp-in-string
-	     "\\( [.A-Za-z]+\\)>" "" (buffer-string) nil nil 1)))))
+	      (org-test-without-dow 'buffer
+                (org-deadline nil "2012-03-29")))))))
 
 (ert-deftest test-org/schedule ()
   "Test `org-schedule' specifications."
   ;; Insert a new value or replace existing one.
   (should
    (equal "* H\nSCHEDULED: <2012-03-29>"
-	  (org-test-with-temp-text "* H"
-	    (let ((org-adapt-indentation nil)
-		  (org-last-inserted-timestamp nil))
-	      (org-schedule nil "<2012-03-29 Tue>"))
-	    (replace-regexp-in-string
-	     "\\( [.A-Za-z]+\\)>" "" (buffer-string)
-	     nil nil 1))))
+          (org-test-with-temp-text "* H"
+            (let ((org-adapt-indentation nil)
+                  (org-last-inserted-timestamp nil))
+              (org-test-without-dow 'buffer
+                (org-schedule nil "<2012-03-29 Tue>"))))))
   (should
    (equal "* H\nSCHEDULED: <2014-03-04>"
-	  (org-test-with-temp-text "* H\nSCHEDULED: <2012-03-29>"
-	    (let ((org-adapt-indentation nil)
-		  (org-last-inserted-timestamp nil))
-	      (org-schedule nil "<2014-03-04 Thu>"))
-	    (replace-regexp-in-string
-	     "\\( [.A-Za-z]+\\)>" "" (buffer-string)
-	     nil nil 1))))
+          (org-test-with-temp-text "* H\nSCHEDULED: <2012-03-29>"
+            (let ((org-adapt-indentation nil)
+                  (org-last-inserted-timestamp nil))
+              (org-test-without-dow 'buffer
+                (org-schedule nil "<2014-03-04 Thu>"))))))
   ;; Accept delta time, e.g., "+2d".
   (should
    (equal "* H\nSCHEDULED: <2015-03-04>"
-	  (org-test-at-time "2014-03-04"
-	    (org-test-with-temp-text "* H"
-	      (let ((org-adapt-indentation nil)
-		    (org-last-inserted-timestamp nil))
-		(org-schedule nil "+1y"))
-	      (replace-regexp-in-string
-	       "\\( [.A-Za-z]+\\)>" "" (buffer-string) nil nil 1)))))
+          (org-test-at-time "2014-03-04"
+            (org-test-with-temp-text "* H"
+              (let ((org-adapt-indentation nil)
+                    (org-last-inserted-timestamp nil))
+                (org-test-without-dow 'buffer
+                  (org-schedule nil "+1y")))))))
   ;; Preserve repeater.
   (should
    (equal "* H\nSCHEDULED: <2012-03-29 +2y>"
-	  (org-test-with-temp-text "* H"
-	    (let ((org-adapt-indentation nil)
-		  (org-last-inserted-timestamp nil))
-	      (org-schedule nil "<2012-03-29 Tue +2y>"))
-	    (replace-regexp-in-string
-	     "\\( [.A-Za-z]+\\) " "" (buffer-string) nil nil 1))))
+          (org-test-with-temp-text "* H"
+            (let ((org-adapt-indentation nil)
+                  (org-last-inserted-timestamp nil))
+              (org-test-without-dow 'buffer
+                (org-schedule nil "<2012-03-29 Tue +2y>"))))))
   ;; Remove CLOSED keyword, if any.
   (should
    (equal "* H\nSCHEDULED: <2012-03-29>"
-	  (org-test-with-temp-text "* H\nCLOSED: [2017-01-25 Wed]"
-	    (let ((org-adapt-indentation nil)
-		  (org-last-inserted-timestamp nil))
-	      (org-schedule nil "<2012-03-29 Tue>"))
-	    (replace-regexp-in-string
-	     "\\( [.A-Za-z]+\\)>" "" (buffer-string) nil nil 1))))
+          (org-test-with-temp-text "* H\nCLOSED: [2017-01-25 Wed]"
+            (let ((org-adapt-indentation nil)
+                  (org-last-inserted-timestamp nil))
+              (org-test-without-dow 'buffer
+                (org-schedule nil "<2012-03-29 Tue>"))))))
   ;; With C-u argument, remove SCHEDULED keyword.
   (should
    (equal "* H\n"
-	  (org-test-with-temp-text "* H\nSCHEDULED: <2012-03-29>"
-	    (let ((org-adapt-indentation nil)
-		  (org-last-inserted-timestamp nil))
-	      (org-schedule '(4)))
-	    (buffer-string))))
+          (org-test-with-temp-text "* H\nSCHEDULED: <2012-03-29>"
+            (let ((org-adapt-indentation nil)
+                  (org-last-inserted-timestamp nil))
+              (org-schedule '(4)))
+            (buffer-string))))
   (should
    (equal "* H"
-	  (org-test-with-temp-text "* H"
-	    (let ((org-adapt-indentation nil)
-		  (org-last-inserted-timestamp nil))
-	      (org-schedule '(4)))
-	    (buffer-string))))
+          (org-test-with-temp-text "* H"
+            (let ((org-adapt-indentation nil)
+                  (org-last-inserted-timestamp nil))
+              (org-schedule '(4)))
+            (buffer-string))))
   ;; With C-u C-u argument, prompt for a delay cookie.
   (should
    (equal "* H\nSCHEDULED: <2012-03-29 -705d>"
-	  (cl-letf (((symbol-function 'org-read-date)
-		     (lambda (&rest _args)
-		       (org-time-string-to-time "2014-03-04"))))
-	    (org-test-with-temp-text "* H\nSCHEDULED: <2012-03-29>"
-	      (let ((org-adapt-indentation nil)
-		    (org-last-inserted-timestamp nil))
-		(org-schedule '(16)))
-	      (buffer-string)))))
+          (cl-letf (((symbol-function 'org-read-date)
+                     (lambda (&rest _args)
+                       (org-time-string-to-time "2014-03-04"))))
+            (org-test-with-temp-text "* H\nSCHEDULED: <2012-03-29>"
+              (let ((org-adapt-indentation nil)
+                    (org-last-inserted-timestamp nil))
+                (org-schedule '(16)))
+              (buffer-string)))))
   (should-error
    (cl-letf (((symbol-function 'org-read-date)
-	      (lambda (&rest _args)
-		(org-time-string-to-time "2014-03-04"))))
+              (lambda (&rest _args)
+                (org-time-string-to-time "2014-03-04"))))
      (org-test-with-temp-text "* H"
        (let ((org-adapt-indentation nil)
-	     (org-last-inserted-timestamp nil))
-	 (org-schedule '(16)))
+             (org-last-inserted-timestamp nil))
+         (org-schedule '(16)))
        (buffer-string))))
   ;; When a region is active and
   ;; `org-loop-over-headlines-in-active-region' is non-nil, insert the
   ;; same value in all headlines in region.
   (should
    (equal "* H1\nSCHEDULED: <2012-03-29>\n* H2\nSCHEDULED: <2012-03-29>"
-	  (org-test-with-temp-text "* H1\n* H2"
-	    (let ((org-adapt-indentation nil)
-		  (org-last-inserted-timestamp nil)
-		  (org-loop-over-headlines-in-active-region t))
-	      (transient-mark-mode 1)
-	      (push-mark (point) t t)
-	      (goto-char (point-max))
-	      (org-schedule nil "2012-03-29"))
-	    (replace-regexp-in-string
-	     "\\( [.A-Za-z]+\\)>" "" (buffer-string) nil nil 1))))
+          (org-test-with-temp-text "* H1\n* H2"
+            (let ((org-adapt-indentation nil)
+                  (org-last-inserted-timestamp nil)
+                  (org-loop-over-headlines-in-active-region t))
+              (transient-mark-mode 1)
+              (push-mark (point) t t)
+              (goto-char (point-max))
+              (org-test-without-dow 'buffer
+                (org-schedule nil "2012-03-29"))))))
   (should-not
    (equal "* H1\nSCHEDULED: <2012-03-29>\n* H2\nSCHEDULED: <2012-03-29>"
-	  (org-test-with-temp-text "* H1\n* H2"
-	    (let ((org-adapt-indentation nil)
-		  (org-last-inserted-timestamp nil)
-		  (org-loop-over-headlines-in-active-region nil))
-	      (transient-mark-mode 1)
-	      (push-mark (point) t t)
-	      (goto-char (point-max))
-	      (org-schedule nil "2012-03-29"))
-	    (replace-regexp-in-string
-	     "\\( [.A-Za-z]+\\)>" "" (buffer-string) nil nil 1))))
+          (org-test-with-temp-text "* H1\n* H2"
+            (let ((org-adapt-indentation nil)
+                  (org-last-inserted-timestamp nil)
+                  (org-loop-over-headlines-in-active-region nil))
+              (transient-mark-mode 1)
+              (push-mark (point) t t)
+              (goto-char (point-max))
+              (org-test-without-dow 'buffer
+                (org-schedule nil "2012-03-29"))))))
   (should
    ;; check if a repeater survives re-scheduling.
-   (string-match-p
-    "\\* H\nSCHEDULED: <2017-02-01 [.A-Za-z]* \\+\\+7d>\n"
+   (equal
+    "* H\nSCHEDULED: <2017-02-01 ++7d>\n"
     (org-test-with-temp-text "* H\nSCHEDULED: <2017-01-19 ++7d>\n"
-			     (let ((org-adapt-indentation nil)
-				   (org-last-inserted-timestamp nil))
-			       (org-schedule nil "2017-02-01"))
-			     (buffer-string)))))
+      (let ((org-adapt-indentation nil)
+            (org-last-inserted-timestamp nil))
+        (org-test-without-dow 'buffer
+          (org-schedule nil "2017-02-01")))))))
 
 \f
 ;;; Property API
diff --git a/testing/org-test.el b/testing/org-test.el
index 22ac60670..ced281e23 100644
--- a/testing/org-test.el
+++ b/testing/org-test.el
@@ -547,6 +547,31 @@ TIME can be a non-nil Lisp time value, or a string specifying a date and time."
        ,@body)
      (nreverse messages)))
 
+(defconst org-test-day-of-weeks-seconds
+  [121223891                            ; Sun
+   30000000                             ; Mon
+   2222222                              ; Tue
+   500000                               ; Wed
+   1000                                 ; Thu
+   89173                                ; Fri
+   666666666]                           ; Sat
+  "Epoch seconds for generating days of week strings.
+Starts at Sunday, ends at Saturday.")
+
+(defconst org-test-day-of-weeks-abbrev
+  (apply #'vector
+         (seq-map (apply-partially #'format-time-string "%a")
+                  org-test-day-of-weeks-seconds))
+  "Vector of abbreviated names of days of week.
+See `org-test-day-of-weeks-seconds'.")
+
+(defconst org-test-day-of-weeks-full
+  (apply #'vector
+         (seq-map (apply-partially #'format-time-string "%A")
+                  org-test-day-of-weeks-seconds))
+  "Vector of full names for days of week.
+See `org-test-day-of-weeks-seconds'.")
+
 (provide 'org-test)
 
 ;;; org-test.el ends here
-- 
2.40.0


[-- Attachment #3: Type: text/plain, Size: 299 bytes --]


To summarize, the remaining goal of this patchset is to fix
`test-org-colview/columns-width', and to optionally expect-failure on
`test-org-clock/clocktable/lang'.

-- 
Best,


RY

[Please note that this mail might go to spam due to some
misconfiguration in my mail server -- still investigating.]

  reply	other threads:[~2023-04-25  8:39 UTC|newest]

Thread overview: 34+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-04-22  7:11 Test failure due to LANG Axel Kielhorn
2023-04-22  9:51 ` Ruijie Yu via General discussions about Org-mode.
2023-04-22 10:15   ` Ruijie Yu via General discussions about Org-mode.
2023-04-22 12:37     ` Ruijie Yu via General discussions about Org-mode.
2023-04-22 13:01       ` [DRAFT PATCH v2] Decouple LANG= and testing (was: Test failure due to LANG) Ruijie Yu via General discussions about Org-mode.
2023-04-22 13:51         ` Ruijie Yu via General discussions about Org-mode.
2023-04-23 10:54           ` Ihor Radchenko
     [not found]             ` <sdvjzy2rhne.fsf@netyu.xyz>
2023-04-23 11:19               ` Ihor Radchenko
2023-04-23 14:30                 ` Ruijie Yu via General discussions about Org-mode.
2023-04-23 15:03                   ` Ihor Radchenko
2023-04-23 15:15                     ` Ruijie Yu via General discussions about Org-mode.
2023-04-25 10:11                       ` Ihor Radchenko
2023-04-25 15:14                         ` Ruijie Yu via General discussions about Org-mode.
2023-04-22 14:50         ` Axel Kielhorn
2023-04-22 15:03           ` Ruijie Yu via General discussions about Org-mode.
2023-04-23  1:47             ` [DRAFT PATCH v3] " Ruijie Yu via General discussions about Org-mode.
2023-04-23  5:36               ` Axel Kielhorn
2023-04-23  6:46                 ` [DRAFT PATCH v4] " Ruijie Yu via General discussions about Org-mode.
2023-04-23 11:17                   ` Ihor Radchenko
2023-04-23 13:57                     ` Ruijie Yu via General discussions about Org-mode.
2023-04-23 15:07                       ` Ihor Radchenko
2023-04-25  8:02                         ` Ruijie Yu via General discussions about Org-mode. [this message]
2023-04-25 15:19                           ` [DRAFT PATCH v6] " Ruijie Yu via General discussions about Org-mode.
2023-04-26  9:05                             ` Ihor Radchenko
2023-04-26  8:44                           ` [DRAFT PATCH v5] " Ihor Radchenko
2023-07-17  8:58                             ` Ihor Radchenko
2023-04-22 14:28       ` Test failure due to LANG Axel Kielhorn
2023-04-22 12:35 ` Ihor Radchenko
2023-04-22 13:00   ` Ruijie Yu via General discussions about Org-mode.
2023-04-22 14:21   ` Max Nikulin
2023-04-22 14:35     ` Ihor Radchenko
2023-04-22 14:40     ` Axel Kielhorn
2023-04-22 16:14       ` Max Nikulin
2023-04-22 14:36   ` Axel Kielhorn

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.orgmode.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=sdvfs8os6es.fsf@netyu.xyz \
    --to=emacs-orgmode@gnu.org \
    --cc=org-mode@axelkielhorn.de \
    --cc=ruijie@netyu.xyz \
    --cc=yantar92@posteo.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).