diff options
author | Michael Albinus <michael.albinus@gmx.de> | 2018-09-29 15:33:48 +0200 |
---|---|---|
committer | Michael Albinus <michael.albinus@gmx.de> | 2018-09-29 15:33:48 +0200 |
commit | ce0da8a427467a2a5e5636f4d69eb56b56b0925e (patch) | |
tree | 5de46dcce14f9a61af05f7ac7b658e877eab7d30 /test | |
parent | 9284e22676a80789a95c3df3b74ac938a0f5eeaa (diff) | |
download | emacs-ce0da8a427467a2a5e5636f4d69eb56b56b0925e.tar.gz |
Rework time-* functions in Tramp
* doc/misc/emacs-mime.texi (time-date): Add time-equal-p.
* lisp/net/tramp-compat.el (tramp-compat-time-equal-p): New defsubst.
* lisp/net/tramp.el (tramp-file-name-handler): Remove `debug'
error handler.
(tramp-half-a-year): Remove.
(tramp-time-dont-know, tramp-time-doesnt-exist): New defconst.
(tramp-time-diff): Remove compat code.
(tramp-handle-set-visited-file-modtime)
(tramp-handle-verify-visited-file-modtime):
* lisp/net/tramp-adb.el (tramp-do-parse-file-attributes-with-ls)
(tramp-adb-handle-set-file-times):
* lisp/net/tramp-sh.el (tramp-do-file-attributes-with-ls)
(tramp-sh-handle-set-visited-file-modtime)
(tramp-sh-handle-verify-visited-file-modtime)
(tramp-sh-handle-set-file-times)
(tramp-sh-handle-file-newer-than-file-p):
Use `tramp-time-dont-know', `tramp-time-doesnt-exist' and
`tramp-compat-time-equal-p'.
(tramp-sh-handle-verify-visited-file-modtime): Simplify check.
* lisp/net/tramp-smb.el (tramp-smb-handle-file-attributes)
(tramp-smb-read-file-entry): Use `tramp-time-dont-know'.
(tramp-smb-handle-insert-directory): Adapt half-a-year check.
* src/editfns.c (Ftime_equal_p): Adapt docstring.
* test/lisp/net/tramp-tests.el
(tramp-test19-directory-files-and-attributes)
(tramp-test22-file-times): Use `tramp-compat-time-equal-p' and
`tramp-time-dont-know'.
(tramp-test23-visited-file-modtime): Extend test.
Diffstat (limited to 'test')
-rw-r--r-- | test/lisp/net/tramp-tests.el | 28 |
1 files changed, 18 insertions, 10 deletions
diff --git a/test/lisp/net/tramp-tests.el b/test/lisp/net/tramp-tests.el index 79013558fdb..523c7afada8 100644 --- a/test/lisp/net/tramp-tests.el +++ b/test/lisp/net/tramp-tests.el @@ -2882,16 +2882,17 @@ 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 - (zerop - (float-time - (nth 5 (file-attributes - (expand-file-name (car elt) tmp-name2))))) + (tramp-compat-time-equal-p + (nth + 5 (file-attributes (expand-file-name (car elt) tmp-name2))) + tramp-time-dont-know) (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 (zerop (float-time (nth 5 (file-attributes (car elt))))) + (unless (tramp-compat-time-equal-p + (nth 5 (file-attributes (car elt))) tramp-time-dont-know) (should (equal (file-attributes (car elt)) (cdr elt))))) (setq attr (directory-files-and-attributes tmp-name2 nil "^b")) @@ -3215,14 +3216,13 @@ This tests also `make-symbolic-link', `file-truename' 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)))) - ;; 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 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 (zerop (float-time (nth 5 (file-attributes tmp-name1)))) + (unless (tramp-compat-time-equal-p + (nth 5 (file-attributes tmp-name1)) tramp-time-dont-know) (should (equal (nth 5 (file-attributes tmp-name1)) (seconds-to-time 1))) (write-region "bla" nil tmp-name2) @@ -3252,6 +3252,14 @@ This tests also `make-symbolic-link', `file-truename' and `add-name-to-file'." (should (verify-visited-file-modtime)) (set-visited-file-modtime (seconds-to-time 1)) (should (verify-visited-file-modtime)) + (should (= 1 (float-time (visited-file-modtime)))) + + ;; Checks with deleted file. + (delete-file tmp-name) + (dired-uncache tmp-name) + (should (verify-visited-file-modtime)) + (set-visited-file-modtime (seconds-to-time 1)) + (should (verify-visited-file-modtime)) (should (= 1 (float-time (visited-file-modtime)))))) ;; Cleanup. |