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 gJdAIN6RR2ROewAASxT56A (envelope-from ) for ; Tue, 25 Apr 2023 10:39:58 +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 mN0KIN6RR2SC7QAAauVa8A (envelope-from ) for ; Tue, 25 Apr 2023 10:39:58 +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 BA14217852 for ; Tue, 25 Apr 2023 10:39:57 +0200 (CEST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1prECR-0008Fd-4A; Tue, 25 Apr 2023 04:38:59 -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 1prECP-0008FM-MP for emacs-orgmode@gnu.org; Tue, 25 Apr 2023 04:38:57 -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 1prECL-0006ie-QA for emacs-orgmode@gnu.org; Tue, 25 Apr 2023 04:38:57 -0400 Received: from fw.net.yu.netyu.xyz ( [222.248.4.98]) by netyu.xyz (OpenSMTPD) with ESMTPSA id 584b382f (TLSv1.3:TLS_AES_256_GCM_SHA384:256:NO); Tue, 25 Apr 2023 08:38:49 +0000 (UTC) References: <32E3D56A-9DDF-4D70-BBA6-2DB71919EC98@axelkielhorn.de> <37BA8B13-A49D-41A4-B752-4ED9540D5799@axelkielhorn.de> <871qkau9t6.fsf@localhost> <874jp64oxr.fsf@localhost> User-agent: mu4e 1.9.22; emacs 30.0.50 To: Ihor Radchenko Cc: Axel Kielhorn , 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 In-reply-to: <874jp64oxr.fsf@localhost> 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=1682411998; a=rsa-sha256; cv=none; b=o+6DNTJNtDftzpQ62KoGhIrg0rOMYGN18aUoG96gNnddD0hUUeNu5iJWzv8GccdI/PsBS1 eNRjNMlITtxTBEB9yj/4kqgN92IOtsSjCraQwDDu4eCjT/romgfxsnBgE5TRZuD9yAt/WQ nEFIYjrxKLvEqr0vqNmF5Zvu5GPrDz3A6LUQa58q7uEF1yGqc6OQrYDX5IxZAKC6sLd9LY 5YsPusOOXWHJKb61g3uIwnrYtYKwsx0DXtRfBI4CfoqrT1f8oHVX3qkPO2Twp9lAqe3AcE X8fGCWoroZSTT2TVvkFCAafKhFPBwUYgFTwdCZCEcVy2ayY5NHbn1h75f9WgsA== 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=1682411998; 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=kp4267hpLAkdmaBvRtVxe2aqTId5bTZCGd4DP6eSPTQ=; b=MIQCTbKmc37z5f8liCsboWiCwm5VGndG9jnS0ffeCU5tGmgrXpecq0LMwPV9KRzCV0lO6Q 3MfuNKxo21M1eITMVtDr9M648iQxozK8I0FCbhVOmuWvb2q8EhHXyhKwjXcjLn2pKf8Mr3 IvldRoK9iDW3aDxJ9hMMJv7de9tFQ5fPOdXq55I2cpb82H2VdF6D7ypl+uhVK3KpHPRknK eqtxtN+QjFmBLp6j2SnFHDxTCxhF3iqUHEzyYMz1OGsxw4r+/3MOLZfUbSuxqjqzbhbxHM rQ1M9BrVoSrMXy3SKZjhZrZC0m2u2/zKCapAopzoJJqm3BkojzqWcbjkLifVzA== 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: BA14217852 X-TUID: epUFdUj8OETX --=-=-= Content-Type: text/plain Ihor Radchenko 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. --=-=-= Content-Type: text/x-patch Content-Disposition: attachment; filename=0001-DRAFT-Fix-dependence-on-locale-in-org-testing-facili.patch >From d17e33802b0e53af131a2ab3f44d9ee3ecfb2a59 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-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 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..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))) + ;;; 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>" - (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>" - (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>" (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")))))) ;;; 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" - (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" + (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" (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" (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" 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-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" (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" (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" Paragraph" (org-test-with-temp-text "\ * H - SCHEDULED: <2015-06-24 Wed> + SCHEDULED: <2015-06-24> 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-without-dow 'buffer + (org-add-planning-info 'deadline "<2015-06-25 Thu>")))))) ;; Remove middle entry. (should (equal "\ @@ -5706,13 +5707,11 @@ Paragraph" 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" (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" 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" (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" (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" CLOSED: [2015-06-25 Thu] 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-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" (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" CLOSED: [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-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" (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" SCHEDULED: <2015-06-23 Tue> DEADLINE: <2015-06-24 Wed> 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-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" (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" (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" (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" (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"))))))) ;;; 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 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.] --=-=-=--