From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Michael Albinus Newsgroups: gmane.emacs.devel Subject: Re: master d0c77a1: Remove some assumptions about timestamp format Date: Tue, 25 Sep 2018 12:09:53 +0200 Message-ID: <87bm8lanwu.fsf@gmx.de> References: <20180925021527.10418.61555@vcs0.savannah.gnu.org> <20180925021528.9A119204E8@vcs0.savannah.gnu.org> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Trace: blaine.gmane.org 1537870152 19069 195.159.176.226 (25 Sep 2018 10:09:12 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Tue, 25 Sep 2018 10:09:12 +0000 (UTC) User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.0.50 (gnu/linux) Cc: Paul Eggert To: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Tue Sep 25 12:09:08 2018 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1g4kHD-0004sL-Pr for ged-emacs-devel@m.gmane.org; Tue, 25 Sep 2018 12:09:08 +0200 Original-Received: from localhost ([::1]:51989 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1g4kJK-0007pH-Al for ged-emacs-devel@m.gmane.org; Tue, 25 Sep 2018 06:11:18 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:35755) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1g4kII-0007lE-TP for emacs-devel@gnu.org; Tue, 25 Sep 2018 06:10:22 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1g4kID-0003Wh-47 for emacs-devel@gnu.org; Tue, 25 Sep 2018 06:10:14 -0400 Original-Received: from mout.gmx.net ([212.227.15.18]:47919) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1g4kIC-0003Tz-R6 for emacs-devel@gnu.org; Tue, 25 Sep 2018 06:10:09 -0400 Original-Received: from detlef.gmx.de ([178.20.95.78]) by mail.gmx.com (mrgmx001 [212.227.17.190]) with ESMTPSA (Nemesis) id 0M5uLh-1fpprn41zl-00xuSX; Tue, 25 Sep 2018 12:09:55 +0200 In-Reply-To: <20180925021528.9A119204E8@vcs0.savannah.gnu.org> (Paul Eggert's message of "Mon, 24 Sep 2018 22:15:28 -0400 (EDT)") X-Provags-ID: V03:K1:xxIBpQQzqc15EuWmzMuKJaF8kT3w2eBV8VkcGbGwuFtrZlLp6Fl 2QRlBQDrIQxBJfrD7a5q7qHH/S6VU+u5SCWb9rG/Jes7zfbRMe+Bdy8i+JbTkE94vZUlI0h a9QxSRdpWz3m001AXwWOLoU27Hs3LnPWXO0/mHWR9XYB5RNBa0ULf9r6neH4VuIPFUtJp99 tclVrlODlIU6XQwJ1i94w== X-UI-Out-Filterresults: notjunk:1;V01:K0:5m8XXFOcwdI=:PEfT7jq/dtAdSl6CWO2DWH BmKeJDsx7QJGnGRH2eZi/Lwe2VFzASeFD9vTQdU0V/FAcTgfoDNRo988tXkMbX+2LM8EXa7P7 0D+KAGluwYyyThlEA6RRHk+wkTrwk2BwkEJnWf4CqnklmsZIAHO9VrTULU2sAtRCECVwWOP9N xyAFvTw4TR7qZ0gicGEL4P1GJe/dYLL5yfj/dYNyj1xrcomoLr2fJxZJXcykiL0Z49R3QEq8o 7uH2aNcBI71/o6RO4SOT/sRDQFxqyck2n9JqY3glJunbGjlMiEipHIU5dPKlUs3AkrWFRybBQ u7Rpb6bnxlUdx1prfTkFen+vWhW2RlRhha4jOva2MAqrdhQpi5usYeWhpt0fUr98gTrdgIq56 gGDP7K4OAy4fbTWRefElwmB3RqaRQng9X8UT2zPZOgQx8msoOyC2uUtkX93KYA/6RnjB6RavD /hELesCjHQfsQ8OdusshUkMtdOIEryDD79OnJ5pyBiIMpUrLtorGLiy8fBrSwzq/aXjGDSJLW BrBEBwJhUtaH+gqn8d7REuPYNydd8iMQhW0q8uiYVI2rb2ZHU0UAXGrvQG9X+iQ/HI2vF2IPI gXXSkO3wCXdiToYzsc7wrr4F3aGp6AEkrkcDDmn9Jv3zoTeulAe+3CjHp+q0/1dkt60Pt0/ji rDDlxSIwOlsG0uL2fh0VGahyvyc0EVf7u7dhPVJFUTzhyIEOrjJsYmG5PtzoXWfsuqJUUAfEM vQf8FXw/cG9tz/TA8Kt0fl1rQlVAJzgNECWUVdN9YhMEfhKB7/Hs3+AIxJLujbLbVbgTpwFx X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 212.227.15.18 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.org gmane.emacs.devel:230053 Archived-At: eggert@cs.ucla.edu (Paul Eggert) writes: Hi Paul, > Remove some assumptions about timestamp format >=20=20=20=20=20 > These changes remove some assumptions of Lisp code on timestamp > format. Although we=E2=80=99re not going to change the default forma= t any > time soon, I went looking for code that was too intimate about > details of timestamp format and removed assumptions where this was > easy to do with current Emacs primitives. > * test/lisp/calendar/parse-time-tests.el (parse-time-tests): > * test/lisp/emacs-lisp/timer-tests.el (timer-test-multiple-of-time): > * test/lisp/net/tramp-tests.el: > (tramp-test19-directory-files-and-attributes) > (tramp-test22-file-times, tramp-test23-visited-file-modtime): > Don=E2=80=99t assume detailed format of returned Lisp timestamps. > diff --git a/test/lisp/net/tramp-tests.el b/test/lisp/net/tramp-tests.el > index 55884f3..7901355 100644 > --- a/test/lisp/net/tramp-tests.el > +++ b/test/lisp/net/tramp-tests.el > @@ -2882,16 +2882,16 @@ This tests also `file-readable-p', `file-regular-= p' and > ;; able to return the date correctly. They say "don't know". > (dolist (elt attr) > (unless > - (equal > - (nth > - 5 (file-attributes (expand-file-name (car elt) tmp-name2))) > - '(0 0)) > + (zerop > + (float-time > + (nth 5 (file-attributes > + (expand-file-name (car elt) tmp-name2))))) > (should > (equal (file-attributes (expand-file-name (car elt) tmp-name2)) > (cdr elt))))) > (setq attr (directory-files-and-attributes tmp-name2 'full)) > (dolist (elt attr) > - (unless (equal (nth 5 (file-attributes (car elt))) '(0 0)) > + (unless (zerop (float-time (nth 5 (file-attributes (car elt))))) > (should > (equal (file-attributes (car elt)) (cdr elt))))) > (setq attr (directory-files-and-attributes tmp-name2 nil "^b")) > @@ -3215,14 +3215,14 @@ This tests also `make-symbolic-link', `file-truen= ame' and `add-name-to-file'." > (write-region "foo" nil tmp-name1) > (should (file-exists-p tmp-name1)) > (should (consp (nth 5 (file-attributes tmp-name1)))) > - ;; '(0 0) means don't know, and will be replaced by > - ;; `current-time'. Therefore, we use '(0 1). We skip the > + ;; A zero timestamp means don't know, and will be replaced by > + ;; `current-time'. Therefore, use timestamp 1. Skip the > ;; test, if the remote handler is not able to set the > ;; correct time. > (skip-unless (set-file-times tmp-name1 (seconds-to-time 1))) > ;; Dumb remote shells without perl(1) or stat(1) are not > ;; able to return the date correctly. They say "don't know". > - (unless (equal (nth 5 (file-attributes tmp-name1)) '(0 0)) > + (unless (zerop (float-time (nth 5 (file-attributes tmp-name1)))) > (should > (equal (nth 5 (file-attributes tmp-name1)) (seconds-to-time 1))) > (write-region "bla" nil tmp-name2) > @@ -3250,9 +3250,9 @@ This tests also `make-symbolic-link', `file-truenam= e' and `add-name-to-file'." > (with-temp-buffer > (insert-file-contents tmp-name) > (should (verify-visited-file-modtime)) > - (set-visited-file-modtime '(0 1)) > + (set-visited-file-modtime (seconds-to-time 1)) > (should (verify-visited-file-modtime)) > - (should (equal (visited-file-modtime) '(0 1 0 0))))) > + (should (=3D 1 (float-time (visited-file-modtime)))))) >=20=20 > ;; Cleanup. > (ignore-errors (delete-file tmp-name)))))) In the different tramp*.el files, '(0 0) is explicitly quoted as "don't know value". This is there for ages. If you want to change this in the tests, it shall be changed in tramp*.el as well. Maybe it would be even worth an own constant? Something like (defconst time-dont-know (seconds-to-time 0) "A time value indicating an unknown time.") If you like, it could even have the value 0 instead of (seconds-to-time 0). But this would also introduce "some assumptions of Lisp code on timestamp format" - what you try to avoid. Best regards, Michael.