aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorMichael Albinus2017-08-12 12:30:39 +0200
committerMichael Albinus2017-08-12 12:30:39 +0200
commitec5cfaa4568327b5b0b299be2664f7fdae123292 (patch)
tree7d79d2a4fd23960763365e192b5934e872f0534c /test
parente94b0d4d54e39b2601b7f3f724d6c6d8a556e89f (diff)
downloademacs-ec5cfaa4568327b5b0b299be2664f7fdae123292.tar.gz
emacs-ec5cfaa4568327b5b0b299be2664f7fdae123292.zip
Implement EXCL of write-region for Tramp
* lisp/net/ange-ftp.el (ange-ftp-write-region): * lisp/net/tramp-adb.el (tramp-adb-handle-write-region) * lisp/net/tramp-gvfs.el (tramp-gvfs-handle-write-region): * lisp/net/tramp-sh.el (tramp-sh-handle-write-region) * lisp/net/tramp-smb.el (tramp-smb-handle-write-region): Implement MUSTBENEW. * lisp/net/tramp-gvfs.el (tramp-gvfs-do-copy-or-rename-file) * lisp/net/tramp-sh.el (tramp-sh-handle-make-symbolic-link) (tramp-sh-handle-add-name-to-file) (tramp-do-copy-or-rename-file) * lisp/net/tramp-smb.el (tramp-smb-handle-make-symbolic-link): Adapt error message for `file-already-exists'. * src/lisp.h: * src/eval.c (call8): New function. * src/fileio.c (write_region): Pass also lockname and mustbenew to the file name handler. * test/lisp/net/tramp-tests.el (tramp-test10-write-region): Add tests for MUSTBENEW.
Diffstat (limited to 'test')
-rw-r--r--test/lisp/net/tramp-tests.el18
1 files changed, 17 insertions, 1 deletions
diff --git a/test/lisp/net/tramp-tests.el b/test/lisp/net/tramp-tests.el
index 50dfd6fac2e..45cf95fcfe0 100644
--- a/test/lisp/net/tramp-tests.el
+++ b/test/lisp/net/tramp-tests.el
@@ -1846,7 +1846,23 @@ This checks also `file-name-as-directory', `file-name-directory',
1846 (write-region 3 5 tmp-name)) 1846 (write-region 3 5 tmp-name))
1847 (with-temp-buffer 1847 (with-temp-buffer
1848 (insert-file-contents tmp-name) 1848 (insert-file-contents tmp-name)
1849 (should (string-equal (buffer-string) "34")))) 1849 (should (string-equal (buffer-string) "34")))
1850
1851 ;; Do not overwrite if excluded.
1852 (cl-letf (((symbol-function 'y-or-n-p) (lambda (_prompt) t)))
1853 (write-region "foo" nil tmp-name nil nil nil 'mustbenew))
1854 ;; `mustbenew' is passed to Tramp since Emacs 26.1. We
1855 ;; have no test for this, so we check function
1856 ;; `temporary-file-directory', which has been added to
1857 ;; Emacs 26.1 as well.
1858 (when (fboundp 'temporary-file-directory)
1859 (should-error
1860 (cl-letf (((symbol-function 'y-or-n-p) 'ignore))
1861 (write-region "foo" nil tmp-name nil nil nil 'mustbenew))
1862 :type 'file-already-exists)
1863 (should-error
1864 (write-region "foo" nil tmp-name nil nil nil 'excl)
1865 :type 'file-already-exists)))
1850 1866
1851 ;; Cleanup. 1867 ;; Cleanup.
1852 (ignore-errors (delete-file tmp-name)))))) 1868 (ignore-errors (delete-file tmp-name))))))