emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* [PATCH] Fix two false failures in org's test suite
@ 2017-08-08 22:37 Galen Menzel
  2017-08-10 10:16 ` Nicolas Goaziou
  0 siblings, 1 reply; 4+ messages in thread
From: Galen Menzel @ 2017-08-08 22:37 UTC (permalink / raw)
  To: emacs-orgmode

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

Hi all,

A clean clone of org-mode turns up two test failures for me 
(test-org/deadline-close-p and test-org/refile-get-targets), which I 
believe are false failures. The attached (tiny) patch addresses them 
both.

test-org/deadline-close-p fails due to a time zone difference. The test 
assumes that a current time of '(22353 6425 905205 644000) corresponds 
to 2016-06-03 Fri 01:43, but in my timezone it corresponds to 2016-06-02 
Thu 22:43.

test-org/refile-get-targets fails because on macOS /tmp is a symlink to 
/private/tmp, and refile-get-targets resolves symlinks, but the test 
does not.

Best,

Galen

[-- Attachment #2: 0001-test-org.el-Fix-two-false-test-failures.patch --]
[-- Type: text/plain, Size: 1628 bytes --]

From 8839e982b2177bd740ef3a88f6a999a30fd62698 Mon Sep 17 00:00:00 2001
From: Galen Menzel <galen.menzel@utexas.edu>
Date: Tue, 8 Aug 2017 14:31:39 -0700
Subject: [PATCH] test-org.el: Fix two false test failures

* testing/lisp/test-org.el (test-org/deadline-close-p): Fix false
failures due to time-zone differences.
(test-org/refile-get-targets): Fix false failures when test temp-file
path contains a symlink.

TINYCHANGE
---
 testing/lisp/test-org.el | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/testing/lisp/test-org.el b/testing/lisp/test-org.el
index 372bf69c3..f2eda045f 100644
--- a/testing/lisp/test-org.el
+++ b/testing/lisp/test-org.el
@@ -375,7 +375,9 @@
   "Test `org-deadline-close-p' specifications."
   ;; Pretend that the current time is 2016-06-03 Fri 01:43
   (cl-letf (((symbol-function 'current-time)
-	     (lambda () '(22353 6425 905205 644000))))
+	     (lambda ()
+	       (apply #'encode-time
+		      (org-parse-time-string "2016-06-03 Fri 01:43")))))
     ;; Timestamps are close if they are within `ndays' of lead time.
     (org-test-with-temp-text "* Heading"
       (should (org-deadline-close-p "2016-06-03 Fri" 0))
@@ -5478,7 +5480,7 @@ Paragraph<point>"
   ;; full file name.
   (should
    (org-test-with-temp-text-in-file "* H1"
-     (let* ((filename (buffer-file-name))
+     (let* ((filename (file-truename (buffer-file-name)))
 	    (org-refile-use-outline-path 'full-file-path)
 	    (org-refile-targets `(((,filename) :level . 1))))
        (member filename (mapcar #'car (org-refile-get-targets))))))
-- 
2.14.0


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] Fix two false failures in org's test suite
  2017-08-08 22:37 [PATCH] Fix two false failures in org's test suite Galen Menzel
@ 2017-08-10 10:16 ` Nicolas Goaziou
  2017-08-10 17:58   ` Galen Menzel
  0 siblings, 1 reply; 4+ messages in thread
From: Nicolas Goaziou @ 2017-08-10 10:16 UTC (permalink / raw)
  To: Galen Menzel; +Cc: emacs-orgmode

Hello,

"Galen Menzel" <galen.menzel@utexas.edu> writes:

> * testing/lisp/test-org.el (test-org/deadline-close-p): Fix false
> failures due to time-zone differences.
> (test-org/refile-get-targets): Fix false failures when test temp-file
> path contains a symlink.

Thank you.

> -	     (lambda () '(22353 6425 905205 644000))))
> +	     (lambda ()
> +	       (apply #'encode-time
> +		      (org-parse-time-string "2016-06-03 Fri 01:43")))))

Shouldn't this be 

  (org-parse-time-string "..." nil t)

to force UTC?

Regards,

-- 
Nicolas Goaziou

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] Fix two false failures in org's test suite
  2017-08-10 10:16 ` Nicolas Goaziou
@ 2017-08-10 17:58   ` Galen Menzel
  2017-08-10 20:46     ` Nicolas Goaziou
  0 siblings, 1 reply; 4+ messages in thread
From: Galen Menzel @ 2017-08-10 17:58 UTC (permalink / raw)
  To: Nicolas Goaziou; +Cc: emacs-orgmode

Hi Nicolas,

On 10 Aug 2017, at 3:16, Nicolas Goaziou wrote:

>> -	     (lambda () '(22353 6425 905205 644000))))
>> +	     (lambda ()
>> +	       (apply #'encode-time
>> +		      (org-parse-time-string "2016-06-03 Fri 01:43")))))
>
> Shouldn't this be
>
>   (org-parse-time-string "..." nil t)
>
> to force UTC?

I don't believe so.

org-deadline-close-p interprets its timestamp-string argument as being 
in the local time zone (i.e., the call to encode-time that results from 
calling org-deadline-close-p always has a nil zone argument). Since we 
are using "2016-06-03 Fri 01:43" as the ersatz current time to check if 
deadlines are close, then "2016-06-03 Fri 01:43" should be in the local 
time zone as well.

As I would expect, forcing UTC here makes the test fail on my machine.

Best,

Galen

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] Fix two false failures in org's test suite
  2017-08-10 17:58   ` Galen Menzel
@ 2017-08-10 20:46     ` Nicolas Goaziou
  0 siblings, 0 replies; 4+ messages in thread
From: Nicolas Goaziou @ 2017-08-10 20:46 UTC (permalink / raw)
  To: Galen Menzel; +Cc: emacs-orgmode

Hello,

"Galen Menzel" <galen.menzel@utexas.edu> writes:

> org-deadline-close-p interprets its timestamp-string argument as being
> in the local time zone (i.e., the call to encode-time that results
> from calling org-deadline-close-p always has a nil zone argument).
> Since we are using "2016-06-03 Fri 01:43" as the ersatz current time
> to check if deadlines are close, then "2016-06-03 Fri 01:43" should be
> in the local time zone as well.
>
> As I would expect, forcing UTC here makes the test fail on my machine.

OK! Applied. Thank you.

Regards,

-- 
Nicolas Goaziou

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2017-08-10 20:46 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-08-08 22:37 [PATCH] Fix two false failures in org's test suite Galen Menzel
2017-08-10 10:16 ` Nicolas Goaziou
2017-08-10 17:58   ` Galen Menzel
2017-08-10 20:46     ` Nicolas Goaziou

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).