diff options
author | Rui Abreu Ferreira <raf-ep@gmx.com> | 2016-04-15 13:57:29 +0100 |
---|---|---|
committer | Rui Abreu Ferreira <raf-ep@gmx.com> | 2016-04-28 23:58:21 +0100 |
commit | 136374ec6f2fcf285a6047b46862a0ec9a92f5d4 (patch) | |
tree | 87bed8e192bc3ccf7c23a2c0eee670e823874d09 /test/functional/ex_cmds/write_spec.lua | |
parent | eefcc50f2c343d95c58ffed756e5dbf4d086fa68 (diff) | |
download | rneovim-136374ec6f2fcf285a6047b46862a0ec9a92f5d4.tar.gz rneovim-136374ec6f2fcf285a6047b46862a0ec9a92f5d4.tar.bz2 rneovim-136374ec6f2fcf285a6047b46862a0ec9a92f5d4.zip |
Remove old UNIX ifdef from buf_write()
When backupcopy=auto buf_write assumes backupcopy=yes when the file is a
hard/symbolic link. However this check was guarded by a UNIX ifdef. The
check itself is portable and the guard can be removed.
Added a couple tests to check the behaviour of bkc=auto and bkc=no
with a symbolic link.
Reported in #4525
Diffstat (limited to 'test/functional/ex_cmds/write_spec.lua')
-rw-r--r-- | test/functional/ex_cmds/write_spec.lua | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/test/functional/ex_cmds/write_spec.lua b/test/functional/ex_cmds/write_spec.lua new file mode 100644 index 0000000000..d90b297ca8 --- /dev/null +++ b/test/functional/ex_cmds/write_spec.lua @@ -0,0 +1,38 @@ +-- Specs for :write + +local helpers = require('test.functional.helpers') +local eq, eval, clear, write_file, execute, source = + helpers.eq, helpers.eval, helpers.clear, helpers.write_file, + helpers.execute, helpers.source + +describe(':write', function() + it('&backupcopy=auto preserves symlinks', function() + clear('set backupcopy=auto') + os.remove('test_bkc_file.txt') + os.remove('test_bkc_link.txt') + write_file('test_bkc_file.txt', 'content0') + execute("silent !ln -s test_bkc_file.txt test_bkc_link.txt") + source([[ + edit test_bkc_link.txt + call setline(1, ['content1']) + write + ]]) + eq(eval("['content1']"), eval("readfile('test_bkc_file.txt')")) + eq(eval("['content1']"), eval("readfile('test_bkc_link.txt')")) + end) + + it('&backupcopy=no replaces symlink with new file', function() + clear('set backupcopy=no') + os.remove('test_bkc_file.txt') + os.remove('test_bkc_link.txt') + write_file('test_bkc_file.txt', 'content0') + execute("silent !ln -s test_bkc_file.txt test_bkc_link.txt") + source([[ + edit test_bkc_link.txt + call setline(1, ['content1']) + write + ]]) + eq(eval("['content0']"), eval("readfile('test_bkc_file.txt')")) + eq(eval("['content1']"), eval("readfile('test_bkc_link.txt')")) + end) +end) |