diff options
Diffstat (limited to 'test/functional/core')
-rw-r--r-- | test/functional/core/fileio_spec.lua | 41 |
1 files changed, 34 insertions, 7 deletions
diff --git a/test/functional/core/fileio_spec.lua b/test/functional/core/fileio_spec.lua index c347b51dd3..6458d07ec7 100644 --- a/test/functional/core/fileio_spec.lua +++ b/test/functional/core/fileio_spec.lua @@ -30,6 +30,8 @@ local feed_command = helpers.feed_command local skip = helpers.skip local is_os = helpers.is_os local is_ci = helpers.is_ci +local spawn = helpers.spawn +local set_session = helpers.set_session describe('fileio', function() before_each(function() @@ -49,6 +51,23 @@ describe('fileio', function() rmdir('Xtest_backupdir with spaces') end) + local args = { nvim_prog, '--clean', '--cmd', 'set nofsync directory=Xtest_startup_swapdir', } + --- Starts a new nvim session and returns an attached screen. + local function startup(extra_args) + extra_args = extra_args or {} + local argv = vim.tbl_flatten({args, '--embed', extra_args}) + local screen_nvim = spawn(argv) + set_session(screen_nvim) + local screen = Screen.new(70, 10) + screen:attach() + screen:set_default_attr_ids({ + [1] = {foreground = Screen.colors.NvimDarkGrey4}; + [2] = {background = Screen.colors.NvimDarkGrey1, foreground = Screen.colors.NvimLightGrey3}; + [3] = {foreground = Screen.colors.NvimLightCyan}; + }) + return screen + end + it("fsync() with 'nofsync' #8304", function() clear({ args={ '--cmd', 'set nofsync directory=Xtest_startup_swapdir', } }) @@ -81,16 +100,24 @@ describe('fileio', function() eq('foozubbaz', trim(read_file('Xtest_startup_file1'))) -- 4. Exit caused by deadly signal (+ 'swapfile'). - local j = funcs.jobstart({ nvim_prog, '-u', 'NONE', '--headless', - '--cmd', 'set nofsync directory=Xtest_startup_swapdir', - '-c', 'set swapfile', - '-c', 'write Xtest_startup_file2', - '-c', 'put =localtime()', }) - sleep(10) -- Let Nvim start. + local j = funcs.jobstart(vim.tbl_flatten({args, '--embed'}), {rpc=true}) + funcs.rpcrequest(j, 'nvim_exec2', [[ + set nofsync directory=Xtest_startup_swapdir + edit Xtest_startup_file2 + write + put ='fsyncd text' + ]], {}) + eq('Xtest_startup_swapdir', funcs.rpcrequest(j, 'nvim_eval', '&directory')) funcs.jobstop(j) -- Send deadly signal. + local screen = startup() + feed(':recover Xtest_startup_file2<cr>') + screen:expect({any = [[Using swap file "Xtest_startup_swapdir[/\]Xtest_startup_file2%.swp"]]}) + feed('<cr>') + screen:expect({any = 'fsyncd text'}) + -- 5. SIGPWR signal. - -- ?? + -- oldtest: Test_signal_PWR() end) it('backup #9709', function() |