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: Axel Kielhorn <org-mode@axelkielhorn.de>
Cc: emacs-orgmode@gnu.org
Subject: Re: [DRAFT PATCH v3] Decouple LANG= and testing (was: Test failure due to LANG)
Date: Sun, 23 Apr 2023 09:47:35 +0800	[thread overview]
Message-ID: <sdvh6t7tlmw.fsf@netyu.xyz> (raw)
In-Reply-To: <sdvy1mkt0vw.fsf@netyu.xyz>

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


Ruijie Yu via "General discussions about Org-mode." <emacs-orgmode@gnu.org> writes:

> Axel Kielhorn <org-mode@axelkielhorn.de> writes:
>
>> With this patch I get:
>>    FAILED  test-org-clock/clock-drawer-dwim  arrayp
>>    FAILED  test-org-clok/org-clock-timestamps-change  arrayp
>>
>> Axel
>
> Thanks for testing.  Will take a look tomorrow.

Apparently `seq-map' does not preserve the type of its input.  This
patch be good then?


[-- 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: 5276 bytes --]

From 7621108e377c71cf083389e7bdb6f9d76cd07461 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-clok/org-clock-timestamps-change):
(test-org-clock/clock-drawer-dwim): make use of the pre-generated
DoW names in the testing to remove assumptions on LANG=C.
---
 testing/lisp/test-org-clock.el | 62 +++++++++++++++++++---------------
 testing/org-test.el            | 25 ++++++++++++++
 2 files changed, 59 insertions(+), 28 deletions(-)

diff --git a/testing/lisp/test-org-clock.el b/testing/lisp/test-org-clock.el
index 7d8123e1f..4d9306619 100644
--- a/testing/lisp/test-org-clock.el
+++ b/testing/lisp/test-org-clock.el
@@ -91,27 +91,32 @@ the buffer."
 
 (ert-deftest test-org-clok/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/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: 134 bytes --]


-- 
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-23  1:52 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             ` Ruijie Yu via General discussions about Org-mode. [this message]
2023-04-23  5:36               ` [DRAFT PATCH v3] " 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                         ` [DRAFT PATCH v5] " Ruijie Yu via General discussions about Org-mode.
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=sdvh6t7tlmw.fsf@netyu.xyz \
    --to=emacs-orgmode@gnu.org \
    --cc=org-mode@axelkielhorn.de \
    --cc=ruijie@netyu.xyz \
    /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).