aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorJustin M. Keyes <justinkz@gmail.com>2019-05-20 22:33:19 +0200
committerJustin M. Keyes <justinkz@gmail.com>2019-05-20 22:33:19 +0200
commit7cc01c704c86f45854c29cb8427ed3b3029b4188 (patch)
tree77210b9f4ae69a023e65d9e5e4a3caf8951a6c1d /test
parentb9ba1295b466a440600b36a717c701bfcea53dbc (diff)
parent6feb9cb09d243eb811e301b39dbfbba5863617be (diff)
downloadrneovim-7cc01c704c86f45854c29cb8427ed3b3029b4188.tar.gz
rneovim-7cc01c704c86f45854c29cb8427ed3b3029b4188.tar.bz2
rneovim-7cc01c704c86f45854c29cb8427ed3b3029b4188.zip
Merge #9709 'fileio: use os_copy to create backups'
ref #8288
Diffstat (limited to 'test')
-rw-r--r--test/functional/core/fileio_spec.lua23
-rw-r--r--test/helpers.lua5
-rw-r--r--test/unit/helpers.lua5
3 files changed, 29 insertions, 4 deletions
diff --git a/test/functional/core/fileio_spec.lua b/test/functional/core/fileio_spec.lua
index 09533e4e60..c74eb3bb02 100644
--- a/test/functional/core/fileio_spec.lua
+++ b/test/functional/core/fileio_spec.lua
@@ -10,6 +10,8 @@ local request = helpers.request
local retry = helpers.retry
local rmdir = helpers.rmdir
local sleep = helpers.sleep
+local read_file = helpers.read_file
+local trim = helpers.trim
describe('fileio', function()
before_each(function()
@@ -18,6 +20,7 @@ describe('fileio', function()
command(':qall!')
os.remove('Xtest_startup_shada')
os.remove('Xtest_startup_file1')
+ os.remove('Xtest_startup_file1~')
os.remove('Xtest_startup_file2')
rmdir('Xtest_startup_swapdir')
end)
@@ -64,5 +67,25 @@ describe('fileio', function()
command('write')
eq(4, request('nvim__stats').fsync)
end)
+
+ it('backup #9709', function()
+ clear({ args={ '-i', 'Xtest_startup_shada',
+ '--cmd', 'set directory=Xtest_startup_swapdir' } })
+
+ command('write Xtest_startup_file1')
+ feed('ifoo<esc>')
+ command('set backup')
+ command('set backupcopy=yes')
+ command('write')
+ feed('Abar<esc>')
+ command('write')
+
+ local foobar_contents = trim(read_file('Xtest_startup_file1'))
+ local bar_contents = trim(read_file('Xtest_startup_file1~'))
+
+ eq('foobar', foobar_contents);
+ eq('foo', bar_contents);
+
+ end)
end)
diff --git a/test/helpers.lua b/test/helpers.lua
index 3311f3ef97..2a6285e685 100644
--- a/test/helpers.lua
+++ b/test/helpers.lua
@@ -697,6 +697,10 @@ local function read_nvim_log()
return log
end
+local function trim(s)
+ return s:match('^%s*(.*%S)') or ''
+end
+
local module = {
REMOVE_THIS = REMOVE_THIS,
argss_to_cmd = argss_to_cmd,
@@ -736,6 +740,7 @@ local module = {
updated = updated,
which = which,
write_file = write_file,
+ trim = trim,
}
module = shared.tbl_extend('error', module, Paths, shared)
diff --git a/test/unit/helpers.lua b/test/unit/helpers.lua
index e634b7296e..b5d3dd9f47 100644
--- a/test/unit/helpers.lua
+++ b/test/unit/helpers.lua
@@ -15,6 +15,7 @@ local dedent = global_helpers.dedent
local neq = global_helpers.neq
local map = global_helpers.map
local eq = global_helpers.eq
+local trim = global_helpers.trim
-- C constants.
local NULL = ffi.cast('void*', 0)
@@ -119,10 +120,6 @@ local deinit = only_separate(function()
end
end)
-local function trim(s)
- return s:match('^%s*(.*%S)') or ''
-end
-
-- a Set that keeps around the lines we've already seen
local cdefs_init = Set:new()
local cdefs_mod = nil