all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: "Basil L. Contovounesios" <contovob@tcd.ie>
To: 45819@debbugs.gnu.org
Cc: stephen gildea <stepheng+emacs@gildea.com>
Subject: bug#45819: 28.0.50; time-stamp-tests failures
Date: Tue, 12 Jan 2021 17:11:26 +0000	[thread overview]
Message-ID: <878s8ynkqp.fsf@tcd.ie> (raw)
In-Reply-To: <87im82nlht.fsf@tcd.ie> (Basil L. Contovounesios's message of "Tue, 12 Jan 2021 16:55:10 +0000")

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

"Basil L. Contovounesios" <contovob@tcd.ie> writes:

> I've been seeing the attached failures in time-stamp-format-am-pm,
> time-stamp-format-ignored-modifiers, and time-stamp-format-string-width
> for a while now.
>
> My guess is that all three are failing because AM/PM format is not
> supported in my locale, and so '%p' returns an empty string, as per
> (info "(libc) Formatting Calendar Time").
>
> Should the tests be changed to just also handle an empty/blank string,

Perhaps something like the attached?

Thanks,

-- 
Basil


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-Fix-time-stamp-tests-for-non-AM-PM-locales.patch --]
[-- Type: text/x-diff, Size: 4383 bytes --]

From 39ef99ab39f7421cb515b41a9e8c5999ded1d5c8 Mon Sep 17 00:00:00 2001
From: "Basil L. Contovounesios" <contovob@tcd.ie>
Date: Tue, 12 Jan 2021 17:08:27 +0000
Subject: [PATCH] Fix time-stamp-tests for non-AM/PM locales

* test/lisp/time-stamp-tests.el (with-time-stamp-test-env): Add
Edebug spec.
(time-stamp-format-am-pm, time-stamp-format-ignored-modifiers)
(time-stamp-format-string-width): Handle locales which don't support
AM/PM formats and return an empty string instead (bug#45819).
---
 test/lisp/time-stamp-tests.el | 32 ++++++++++++++++++--------------
 1 file changed, 18 insertions(+), 14 deletions(-)

diff --git a/test/lisp/time-stamp-tests.el b/test/lisp/time-stamp-tests.el
index 81488c3df1..c0c5e6dae5 100644
--- a/test/lisp/time-stamp-tests.el
+++ b/test/lisp/time-stamp-tests.el
@@ -26,7 +26,7 @@
 
 (defmacro with-time-stamp-test-env (&rest body)
   "Evaluate BODY with some standard time-stamp test variables bound."
-  (declare (indent defun))
+  (declare (debug (body)) (indent defun))
   `(let ((user-login-name "test-logname")
          (user-full-name "100%d Tester") ;verify "%" passed unchanged
          (buffer-file-name "/emacs/test/time-stamped-file")
@@ -481,16 +481,17 @@ time-stamp-format-year-4digit
     (should (equal (time-stamp-string "%Y" ref-time1) "2006"))))
 
 (ert-deftest time-stamp-format-am-pm ()
-  "Test time-stamp formats for AM and PM strings."
+  "Test time-stamp formats for AM and PM strings.
+Note that `%P' returns an empty string in some locales."
   (with-time-stamp-test-env
     ;; implemented and documented since 1997
-    (should (equal (time-stamp-string "%#p" ref-time1) "pm"))
-    (should (equal (time-stamp-string "%#p" ref-time3) "am"))
-    (should (equal (time-stamp-string "%P" ref-time1) "PM"))
-    (should (equal (time-stamp-string "%P" ref-time3) "AM"))
+    (should (member (time-stamp-string "%#p" ref-time1) '("" "pm")))
+    (should (member (time-stamp-string "%#p" ref-time3) '("" "am")))
+    (should (member (time-stamp-string "%P" ref-time1) '("" "PM")))
+    (should (member (time-stamp-string "%P" ref-time3) '("" "AM")))
     ;; warned 1997-2019, changed in 2019
-    (should (equal (time-stamp-string "%p" ref-time1) "PM"))
-    (should (equal (time-stamp-string "%p" ref-time3) "AM"))))
+    (should (member (time-stamp-string "%p" ref-time1) '("" "PM")))
+    (should (member (time-stamp-string "%p" ref-time3) '("" "AM")))))
 
 (ert-deftest time-stamp-format-day-number-in-week ()
   "Test time-stamp formats for day number in week."
@@ -565,10 +566,12 @@ time-stamp-format-non-date-conversions
       (should (equal (time-stamp-string "%q" ref-time1) "sysname-no-dots")))))
 
 (ert-deftest time-stamp-format-ignored-modifiers ()
-  "Test additional args allowed (but ignored) to allow for future expansion."
+  "Test additional args allowed (but ignored) to allow for future expansion.
+Note that `%P' returns an empty string in some locales."
   (with-time-stamp-test-env
     ;; allowed modifiers
-    (should (equal (time-stamp-string "%.,@-+_ ^(stuff)P" ref-time3) "AM"))
+    (should (member (time-stamp-string "%.,@-+_ ^(stuff)P" ref-time3)
+                    '("  " "AM")))
     ;; not all punctuation is allowed
     (should-not (equal (time-stamp-string "%&P" ref-time3) "AM"))))
 
@@ -578,13 +581,14 @@ time-stamp-format-non-conversions
     (should (equal (time-stamp-string "No percent" ref-time1) "No percent"))))
 
 (ert-deftest time-stamp-format-string-width ()
-  "Test time-stamp string width modifiers."
+  "Test time-stamp string width modifiers.
+Note that `%P' returns an empty string in some locales."
   (with-time-stamp-test-env
     ;; strings truncate on the right or are blank-padded on the left
     (should (equal (time-stamp-string "%0P" ref-time3) ""))
-    (should (equal (time-stamp-string "%1P" ref-time3) "A"))
-    (should (equal (time-stamp-string "%2P" ref-time3) "AM"))
-    (should (equal (time-stamp-string "%3P" ref-time3) " AM"))
+    (should (member (time-stamp-string "%1P" ref-time3) '(" " "A")))
+    (should (member (time-stamp-string "%2P" ref-time3) '("  " "AM")))
+    (should (member (time-stamp-string "%3P" ref-time3) '("   " " AM")))
     (should (equal (time-stamp-string "%0%" ref-time3) ""))
     (should (equal (time-stamp-string "%1%" ref-time3) "%"))
     (should (equal (time-stamp-string "%2%" ref-time3) " %"))
-- 
2.29.2


  reply	other threads:[~2021-01-12 17:11 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-01-12 16:55 bug#45819: 28.0.50; time-stamp-tests failures Basil L. Contovounesios
2021-01-12 17:11 ` Basil L. Contovounesios [this message]
2021-01-18 22:52 ` Basil L. Contovounesios

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

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

  git send-email \
    --in-reply-to=878s8ynkqp.fsf@tcd.ie \
    --to=contovob@tcd.ie \
    --cc=45819@debbugs.gnu.org \
    --cc=stepheng+emacs@gildea.com \
    /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 external index

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

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.