From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp12.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms9.migadu.com with LMTPS id AOBFEbPZRGR0FAEASxT56A (envelope-from ) for ; Sun, 23 Apr 2023 09:09:39 +0200 Received: from aspmx1.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp12.migadu.com with LMTPS id MHUXEbPZRGRpJwAAauVa8A (envelope-from ) for ; Sun, 23 Apr 2023 09:09:39 +0200 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id B76782A22A for ; Sun, 23 Apr 2023 09:09:38 +0200 (CEST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pqTq4-0008WO-EO; Sun, 23 Apr 2023 03:08:49 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pqTq2-0008WD-TA for emacs-orgmode@gnu.org; Sun, 23 Apr 2023 03:08:46 -0400 Received: from netyu.xyz ([152.44.41.246] helo=mail.netyu.xyz) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pqTpz-0004Yd-IL for emacs-orgmode@gnu.org; Sun, 23 Apr 2023 03:08:46 -0400 Received: from fw.net.yu.netyu.xyz ( [222.248.4.98]) by netyu.xyz (OpenSMTPD) with ESMTPSA id 92fe41a2 (TLSv1.3:TLS_AES_256_GCM_SHA384:256:NO); Sun, 23 Apr 2023 07:08:35 +0000 (UTC) References: <32E3D56A-9DDF-4D70-BBA6-2DB71919EC98@axelkielhorn.de> <37BA8B13-A49D-41A4-B752-4ED9540D5799@axelkielhorn.de> User-agent: mu4e 1.9.22; emacs 30.0.50 To: Axel Kielhorn Cc: emacs-orgmode@gnu.org Subject: Re: [DRAFT PATCH v4] Decouple LANG= and testing (was: Test failure due to LANG) Date: Sun, 23 Apr 2023 14:46:22 +0800 In-reply-to: <37BA8B13-A49D-41A4-B752-4ED9540D5799@axelkielhorn.de> Message-ID: MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Received-SPF: pass client-ip=152.44.41.246; envelope-from=ruijie@netyu.xyz; helo=mail.netyu.xyz X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: emacs-orgmode@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-to: Ruijie Yu From: Ruijie Yu via "General discussions about Org-mode." Errors-To: emacs-orgmode-bounces+larch=yhetil.org@gnu.org Sender: emacs-orgmode-bounces+larch=yhetil.org@gnu.org X-Migadu-Flow: FLOW_IN X-Migadu-Country: US ARC-Seal: i=1; s=key1; d=yhetil.org; t=1682233779; a=rsa-sha256; cv=none; b=DBVzteiICi4FtnYQhrGqBKFAefyKlrkrVQSD/OF2QVAyFbwcCiQAetpkrUgHiebKw/UJp2 jTVbOKEwGR3nJ4E9dfwYTUXHhmpQiY/r4dsDjHXemm+lhcxqRsXqo35TFaNmpUkEgvf4CG 7WjCCQLUi9W5KciCocVTgaiiqGQs+9wAmSAvwijmiLSpG57gI5+7GSVuMM2PV+ZKrN6Y1d smRUzw27bnMVal4YBTiqiHBRzQ9DcVs9dtnj/hWmvzaUMWfuMTn25ZwLeM7Iei1FXerdS3 KRypmnjEY8IHGfHWEcqYUEE3I7hnF70pKLeOuicOJeqA06CYdRQz2vZPLZ3YhQ== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=none; dmarc=pass (policy=none) header.from=gnu.org; spf=pass (aspmx1.migadu.com: domain of "emacs-orgmode-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="emacs-orgmode-bounces+larch=yhetil.org@gnu.org" ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1682233779; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type:in-reply-to:in-reply-to: references:references:list-id:list-help:list-unsubscribe: list-subscribe:list-post; bh=2+0yggBNVOYGbs8m9GFgIrFVULWvvg72WI2o491IedQ=; b=Pd2uSHMbm18NuirDYc+ibYr/8b+NULd1PCXNbsvVFbSAMBkSr6rEPTiyHxqwAJr4czGrSw JUTXeAruJuwhLfIvcZoRB7opqkRpYlQtGchbMnWJtDyPDK3kFlJxtqzYIRpoTaCAIQKYh3 siNk6pMq63Xh66amTyxYDy3GZLTzqnizG5l1Pb/knI8QJf3/B/p06RM9FZ1nw+lqaza0rS colOUTplZY2k7Y7L+FOInXWKAuySKLmJMhPcAIC7Znx31crIlEYgTosC9LiKW0IYhhQJKX DK2BEUj5WCgk4Z2082qyEPXeim0gy00KF6jAIY6OmYWh4oP92qn0XuFKd3iOjA== X-Migadu-Scanner: scn1.migadu.com Authentication-Results: aspmx1.migadu.com; dkim=none; dmarc=pass (policy=none) header.from=gnu.org; spf=pass (aspmx1.migadu.com: domain of "emacs-orgmode-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="emacs-orgmode-bounces+larch=yhetil.org@gnu.org" X-Migadu-Spam-Score: -2.01 X-Spam-Score: -2.01 X-Migadu-Queue-Id: B76782A22A X-TUID: 9qbCc3L1coAQ --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Axel Kielhorn writes: >> Am 23.04.2023 um 03:47 schrieb Ruijie Yu via General discussions about O= rg-mode. : >>=20 >>=20 >> Ruijie Yu via "General discussions about Org-mode." writes: >>=20 >>> Axel Kielhorn writes: >>>=20 >>>> With this patch I get: >>>> FAILED test-org-clock/clock-drawer-dwim arrayp >>>> FAILED test-org-clok/org-clock-timestamps-change arrayp >>>>=20 >>>> Axel >>>=20 >>> Thanks for testing. Will take a look tomorrow. >>=20 >> Apparently `seq-map' does not preserve the type of its input. This >> patch be good then? >>=20 >> <0001-DRAFT-Fix-dependence-on-locale-in-org-testing-facili.patch> > > This works for me, thanks. > > Axel Thank you for confirming that it works. The following is an update of my progress trying to fix all issues I found when I tested against different $LANG values. I was able to iron out most of the errors found in my testing on zh_CN.UTF-8. The amount of unexpected failures went down from 8 to 2. I also noticed that new errors are introduced in LANG=3Dfr_FR.UTF-8 (was 1, now 5), so I will take a look at that for the next iteration. Something very troublesome for me is `test-org-clock/clocktable/lang' on zh_CN.UTF-8. What I noticed is that when I run this test in batch mode (one of the two methods below), it fails: $ LANG=3Dzh_CN.UTF-8 make test $ LANG=3Dzh_CN.UTF-8 emacs -Q -nw -batch \ -L lisp -L testing/lisp \ -l ert \ -l testing/org-test.el \ -l testing/lisp/test-org-clock.el \ -f ert-run-tests-batch-and-exit Whereas when I run it interactively, it succeeds: $ LANG=3Dzh_CN.UTF-8 emacs -Q -nw \ -L lisp -L testing/lisp \ -l ert \ -l testing/org-test.el \ -l testing/lisp/test-org-clock.el M-x ert-i test-org-clock/clocktable/lang RET Not sure what to make of it just yet. The other failure I got in zh_CN.UTF-8 is `test-org-colview/columns-width', as I mentioned somewhere up-thread. It is caused by this s-exp: (format "%-5.5s |" "1234=E2=80=A6") which returns "1234=E2=80=A6 |" when locale is en_US.UTF-8 or fr_FR.UTF-8, = and "1234 |" when locale is zh_CN.UTF-8 or ja_JA.UTF-8. I think it might be due to the "perceived width" of the ellipsis, or something? Anyways, this is enough progress for now. Here is the 4th iteration. Note the very big rx regexp, where I asked in another thread whether my understanding of a timestamp is complete. Thanks. --=-=-= Content-Type: text/x-patch Content-Disposition: attachment; filename=0001-DRAFT-Fix-dependence-on-locale-in-org-testing-facili.patch >From d8525132d3f90623a6e8c732bd2a580ba23a2156 Mon Sep 17 00:00:00 2001 From: Ruijie Yu 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.el org-test-timestamp-regexp: make a comprehensive timestamp regexp for testing. (test-org/clone-with-time-shift): (test-org/add-planning-info): (test-org/deadline): (test-org/schedule): replace the regexps which try to match the DoW string in a timestamp into using `org-test-timestamp-regexp'. --- testing/lisp/test-org-clock.el | 62 +++++---- testing/lisp/test-org.el | 231 +++++++++++++++++---------------- testing/org-test.el | 25 ++++ 3 files changed, 177 insertions(+), 141 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 22: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: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 23: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 22: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: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 23:30]--[2023-02-20 Mon 00:35] => 1:05" + (org-clock-timestamps-change 'up 1) + (buffer-string)))))) ;;; 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: 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)))))) ;;; Clocktable diff --git a/testing/lisp/test-org.el b/testing/lisp/test-org.el index d7c801fe5..cc06322f3 100644 --- a/testing/lisp/test-org.el +++ b/testing/lisp/test-org.el @@ -29,6 +29,65 @@ (require 'org-refile) (require 'org-agenda) + +;;; Regexps + +(defconst org-test-timestamp-regexp + (rx (any ?\< ?\[) ; < or [ + (group-n 200 ; YEAR-MONTH-DATE + (group-n 100 (= 4 digit)) ?- + (group-n 101 (= 2 digit)) ?- + (group-n 102 (= 2 digit))) + (group-n 210 ; SPC DOW + " " (group-n 110 bow (+ letter) eow)) + (opt ; SPC HOUR:MINUTE + (group-n 221 + " " + (group-n 220 + (group-n 120 (= 2 digit)) ?: + (group-n 121 (= 2 digit))))) + (opt ; repeater: +{1,2}AMOUNTunit + (group-n 232 + " " + (group-n 231 + (group-n 132 (** 1 2 ?+)) + (group-n 230 + (group-n 130 (+ digit)) + (group-n 131 (any "hdmwy")))))) + (opt ; warning period: -AMOUNTunit + (group-n 242 + " " + (group-n 241 + ?- + (group-n 240 + (group-n 140 (+ digit)) + (group-n 141 (any "hdmwy")))))) + (any ?\> ?\])) + "A (hopefully) comprehensive timestamp regexp. +Each individual component is contained in a group, described below. + +- 100: year +- 101: month +- 102: day-of-month +- 110: day-of-week +- 120: hour (if available) +- 121: minute (if available) +- 130: the repeater amount (if available) +- 131: the repeater unit (if available) +- 132: the repeater \"+\" or \"++\" (if available) +- 140: the warning period amount (if available) +- 141: the warning period unit (if available) +- 200: full year-month-date portion +- 210: day-of-week including preceding space +- 220: full time (hour:minute) portion +- 221: full time portion including preceding space +- 230: repeater amount + unit +- 231: repeater, with preceding \"+\" or \"++\" +- 232: repeater, with preceding \" +\" or \" ++\" +- 240: warning period amount + unit +- 241: warning period with \"-\" +- 242: warning period with \" -\"") + ;;; Helpers @@ -43,6 +102,13 @@ ,@body) (setenv "TZ" ,tz-saved))))) +(defun org-test-drop-dow-from-timestamp () + "Drop dow from timestamps for testing within a buffer. +Return the buffer string." + (replace-regexp-in-string + org-test-timestamp-regexp "" + (buffer-string) nil nil 210)) + ;;; Comments @@ -2015,9 +2081,7 @@ CLOCK: [2022-09-17 sam. 11:00]--[2022-09-17 sam. 11:46] => 0:46" " (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-drop-dow-from-timestamp)))) ;; Clone repeating once. (should (equal "\ @@ -2027,9 +2091,7 @@ CLOCK: [2022-09-17 sam. 11:00]--[2022-09-17 sam. 11:46] => 0:46" " (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-drop-dow-from-timestamp)))) ;; Clone repeating once in backward. (should (equal "\ @@ -2039,9 +2101,7 @@ CLOCK: [2022-09-17 sam. 11:00]--[2022-09-17 sam. 11:46] => 0:46" " (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-drop-dow-from-timestamp)))) ;; Clone non-repeating zero times. (should (equal "\ @@ -2049,9 +2109,7 @@ CLOCK: [2022-09-17 sam. 11:00]--[2022-09-17 sam. 11:46] => 0:46" " (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-drop-dow-from-timestamp)))) ;; Clone repeating "zero" times. (should (equal "\ @@ -2060,9 +2118,7 @@ CLOCK: [2022-09-17 sam. 11:00]--[2022-09-17 sam. 11:46] => 0:46" " (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-drop-dow-from-timestamp)))) ;; Clone with blank SHIFT argument. (should (string-prefix-p @@ -2098,10 +2154,7 @@ CLOCK: [2022-09-17 sam. 11:00]--[2022-09-17 sam. 11:46] => 0:46" " (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-drop-dow-from-timestamp)))) (should (equal "\ * H1\n<2015-06-21 20:00> @@ -2109,10 +2162,7 @@ CLOCK: [2022-09-17 sam. 11:00]--[2022-09-17 sam. 11:46] => 0:46" " (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-drop-dow-from-timestamp))))) ;;; Fixed-Width Areas @@ -5629,18 +5679,14 @@ Text. (org-test-with-temp-text "* H\nParagraph" (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-drop-dow-from-timestamp)))) ;; Create deadline when `org-adapt-indentation' is nil. (should (equal "* H\nDEADLINE: <2015-06-25>\nParagraph" (org-test-with-temp-text "* H\nParagraph" (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-drop-dow-from-timestamp)))) ;; Update deadline when `org-adapt-indentation' is non-nil. (should (equal "* H\n DEADLINE: <2015-06-25>\nParagraph" @@ -5650,9 +5696,7 @@ Text. Paragraph" (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-drop-dow-from-timestamp)))) ;; Update deadline when `org-adapt-indentation' is nil. (should (equal "* H\nDEADLINE: <2015-06-25>\nParagraph" @@ -5662,27 +5706,21 @@ DEADLINE: <2015-06-24 Wed> Paragraph" (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-drop-dow-from-timestamp)))) ;; Schedule when `org-adapt-indentation' is non-nil. (should (equal "* H\n SCHEDULED: <2015-06-25>\nParagraph" (org-test-with-temp-text "* H\nParagraph" (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-drop-dow-from-timestamp)))) ;; Schedule when `org-adapt-indentation' is nil. (should (equal "* H\nSCHEDULED: <2015-06-25>\nParagraph" (org-test-with-temp-text "* H\nParagraph" (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-drop-dow-from-timestamp)))) ;; Add deadline when scheduled. (should (equal "\ @@ -5695,9 +5733,7 @@ Paragraph" Paragraph" (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-drop-dow-from-timestamp)))) ;; Remove middle entry. (should (equal "\ @@ -5710,9 +5746,7 @@ Paragraph" Paragraph" (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-drop-dow-from-timestamp)))) ;; Remove last entry and then middle entry (order should not ;; matter). (should @@ -5726,9 +5760,7 @@ Paragraph" Paragraph" (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-drop-dow-from-timestamp)))) ;; Remove closed when `org-adapt-indentation' is non-nil. (should (equal "* H\n DEADLINE: <2015-06-25>\nParagraph" @@ -5738,9 +5770,7 @@ Paragraph" Paragraph" (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-drop-dow-from-timestamp)))) (should (equal "* H\n Paragraph" (org-test-with-temp-text "\ @@ -5749,9 +5779,7 @@ Paragraph" Paragraph" (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-drop-dow-from-timestamp)))) ;; Remove closed when `org-adapt-indentation' is nil. (should (equal "* H\nDEADLINE: <2015-06-25>\nParagraph" @@ -5761,9 +5789,7 @@ CLOSED: [2015-06-25 Thu] DEADLINE: <2015-06-25 Thu> Paragraph" (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-drop-dow-from-timestamp)))) (should (equal "* H\nParagraph" (org-test-with-temp-text "\ @@ -5772,9 +5798,7 @@ Paragraph" Paragraph" (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-drop-dow-from-timestamp)))) ;; Remove closed entry and delete empty line. (should (equal "\ @@ -5786,9 +5810,7 @@ Paragraph" Paragraph" (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-drop-dow-from-timestamp)))) ;; Remove one entry and update another. (should (equal "* H\n DEADLINE: <2015-06-25>\nParagraph" @@ -5798,9 +5820,7 @@ Paragraph" Paragraph" (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-drop-dow-from-timestamp))))) (ert-deftest test-org/deadline () "Test `org-deadline' specifications." @@ -5811,18 +5831,14 @@ Paragraph" (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-drop-dow-from-timestamp)))) (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-drop-dow-from-timestamp)))) ;; Accept delta time, e.g., "+2d". (should (equal "* H\nDEADLINE: <2015-03-04>" @@ -5831,8 +5847,7 @@ Paragraph" (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-drop-dow-from-timestamp))))) ;; Preserve repeater. (should (equal "* H\nDEADLINE: <2012-03-29 +2y>" @@ -5840,8 +5855,7 @@ Paragraph" (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-drop-dow-from-timestamp)))) ;; Preserve warning period. (should (equal "* H\nDEADLINE: <2021-07-20 -1d>" @@ -5849,16 +5863,14 @@ Paragraph" (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-drop-dow-from-timestamp)))) (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-drop-dow-from-timestamp)))) ;; Remove CLOSED keyword, if any. (should (equal "* H\nDEADLINE: <2012-03-29>" @@ -5866,8 +5878,7 @@ Paragraph" (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-drop-dow-from-timestamp)))) ;; With C-u argument, remove DEADLINE keyword. (should (equal "* H\n" @@ -5916,8 +5927,7 @@ Paragraph" (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-drop-dow-from-timestamp)))) (should-not (equal "* H1\nDEADLINE: <2012-03-29>\n* H2\nDEADLINE: <2012-03-29>" (org-test-with-temp-text "* H1\n* H2" @@ -5928,8 +5938,7 @@ Paragraph" (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-drop-dow-from-timestamp))))) (ert-deftest test-org/schedule () "Test `org-schedule' specifications." @@ -5940,18 +5949,14 @@ Paragraph" (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-drop-dow-from-timestamp)))) (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-drop-dow-from-timestamp)))) ;; Accept delta time, e.g., "+2d". (should (equal "* H\nSCHEDULED: <2015-03-04>" @@ -5960,8 +5965,7 @@ Paragraph" (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-drop-dow-from-timestamp))))) ;; Preserve repeater. (should (equal "* H\nSCHEDULED: <2012-03-29 +2y>" @@ -5969,8 +5973,7 @@ Paragraph" (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-drop-dow-from-timestamp)))) ;; Remove CLOSED keyword, if any. (should (equal "* H\nSCHEDULED: <2012-03-29>" @@ -5978,8 +5981,7 @@ Paragraph" (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-drop-dow-from-timestamp)))) ;; With C-u argument, remove SCHEDULED keyword. (should (equal "* H\n" @@ -6028,8 +6030,7 @@ Paragraph" (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-drop-dow-from-timestamp)))) (should-not (equal "* H1\nSCHEDULED: <2012-03-29>\n* H2\nSCHEDULED: <2012-03-29>" (org-test-with-temp-text "* H1\n* H2" @@ -6040,17 +6041,21 @@ Paragraph" (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)))) - (should - ;; check if a repeater survives re-scheduling. - (string-match-p - "\\* H\nSCHEDULED: <2017-02-01 [.A-Za-z]* \\+\\+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))))) + (org-test-drop-dow-from-timestamp)))) + ;; check if a repeater survives re-scheduling. + (save-match-data + (let* ((org-adapt-indentation nil) + (org-last-inserted-timestamp nil) + (s (org-test-with-temp-text + "* H\nSCHEDULED: <2017-01-19 ++7d>\n" + (org-schedule nil "2017-02-01") + (buffer-string)))) + (should + (string-match + (rx "* H\nSCHEDULED: " (regexp org-test-timestamp-regexp) ?\n) + s)) + (should (equal "2017-02-01" (match-string 200 s))) + (should (equal "++7d" (match-string 231 s)))))) ;;; 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 --=-=-= Content-Type: text/plain -- Best, RY [Please note that this mail might go to spam due to some misconfiguration in my mail server -- still investigating.] --=-=-=--