GNU bug report logs -
#35497
[PATCH] Don't rewrite buffer contents after saving by rename
Previous Next
Reported by: Jonathan Tomer <jktomer <at> google.com>
Date: Mon, 29 Apr 2019 23:32:01 UTC
Severity: normal
Tags: patch
Done: Michael Albinus <michael.albinus <at> gmx.de>
Bug is archived. No further changes may be made.
Full log
Message #44 received at 35497 <at> debbugs.gnu.org (full text, mbox):
Jonathan Tomer <jktomer <at> google.com> writes:
Hi Jonathan,
> +(ert-deftest tramp-test46-file-precious-flag ()
Since this belongs rather to write-region, I would call it
`tramp-test10-write-region-file-precious-flag', and move it to the
repsective place in file.
> + "Check that file-precious-flag is respected with Tramp in use."
> + (let* ((temp-file (make-temp-file "emacs"))
> + (remote-file (concat "/mock:localhost:" temp-file))
Please don't do this. The mock method does not work everywhere, for
example on an MS Windows machine.
`file-precious-flag' is handled in the tramp-sh.el handler only. So you
might start with the test `tramp--test-sh-p', and skip otherwise.
And then you could use the same mechanism like in the other
tests. Something like this:
--8<---------------cut here---------------start------------->8---
(ert-deftest tramp-test10-write-region-file-precious-flag ()
"Check that `file-precious-flag' is respected with Tramp in use."
(skip-unless (tramp--test-enabled))
(skip-unless (tramp--test-sh-p))
(let ((tmp-name (tramp--test-make-temp-name))
(advice (lambda (_start _end filename &rest r)
(should-not (string= filename tmp-name)))))
(unwind-protect
(with-current-buffer (find-file-noselect tmp-name)
;; Write initial contents. Adapt `visited-file-modtime'
;; in order to suppress confirmation.
(insert "foo")
(write-region nil nil tmp-name)
(set-visited-file-modtime)
;; Run the test.
(advice-add 'write-region :before advice)
(setq-local file-precious-flag t)
(insert "bar")
(should (null (save-buffer))))
;; Cleanup.
(ignore-errors (advice-remove 'write-region advice))
(ignore-errors (delete-file tmp-name)))))
--8<---------------cut here---------------end--------------->8---
I haven't tested further, this gives an error for me. Don't know yet,
whether it is the test definition, or (more likely) a problem in Tramp.
Best regards, Michael.
This bug report was last modified 6 years and 71 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.