[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
bug#35497: [PATCH v3] Don't rewrite buffer contents after saving by rena
From: |
Michael Albinus |
Subject: |
bug#35497: [PATCH v3] Don't rewrite buffer contents after saving by rename |
Date: |
Thu, 02 May 2019 13:50:56 +0200 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/27.0.50 (gnu/linux) |
Jonathan Tomer <jktomer@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.
- bug#35497: [PATCH] Don't rewrite buffer contents after saving by rename, Eli Zaretskii, 2019/05/01
- bug#35497: [PATCH] Don't rewrite buffer contents after saving by rename, Jonathan Tomer, 2019/05/01
- bug#35497: [PATCH] Don't rewrite buffer contents after saving by rename, Eli Zaretskii, 2019/05/01
- bug#35497: [PATCH] Don't rewrite buffer contents after saving by rename, Jonathan Tomer, 2019/05/01
- bug#35497: [PATCH v3] Don't rewrite buffer contents after saving by rename, Jonathan Tomer, 2019/05/01
- bug#35497: [PATCH v3] Don't rewrite buffer contents after saving by rename,
Michael Albinus <=
- bug#35497: [PATCH v3] Don't rewrite buffer contents after saving by rename, Jonathan Tomer, 2019/05/02
- bug#35497: [PATCH v4] Don't rewrite buffer contents after saving by rename, Jonathan Tomer, 2019/05/02
- Message not available
- bug#35497: [PATCH v4] Don't rewrite buffer contents after saving by rename, Michael Albinus, 2019/05/03
- bug#35497: [PATCH v4] Don't rewrite buffer contents after saving by rename, Eli Zaretskii, 2019/05/03
- bug#35497: [PATCH v4] Don't rewrite buffer contents after saving by rename, Jonathan Tomer, 2019/05/06
- bug#35497: [PATCH v4] Don't rewrite buffer contents after saving by rename, Michael Albinus, 2019/05/07
- bug#35497: [PATCH v4] Don't rewrite buffer contents after saving by rename, Richard Stallman, 2019/05/07
- bug#35497: [PATCH v5] Don't rewrite buffer contents after saving by rename, Jonathan Tomer, 2019/05/06
- bug#35497: [PATCH v6] Don't rewrite buffer contents after saving by rename, Jonathan Tomer, 2019/05/06
- bug#35497: [PATCH v6] Don't rewrite buffer contents after saving by rename, Michael Albinus, 2019/05/07