mirror of
https://github.com/neovim/neovim.git
synced 2025-12-10 00:22:41 +00:00
API: nvim__stats()
Use it to verify fsync() behavior.
This commit is contained in:
@@ -3,10 +3,11 @@ local helpers = require('test.functional.helpers')(after_each)
|
||||
local clear = helpers.clear
|
||||
local command = helpers.command
|
||||
local eq = helpers.eq
|
||||
local eval = helpers.eval
|
||||
local feed = helpers.feed
|
||||
local funcs = helpers.funcs
|
||||
local nvim_prog = helpers.nvim_prog
|
||||
local request = helpers.request
|
||||
local retry = helpers.retry
|
||||
local rmdir = helpers.rmdir
|
||||
local sleep = helpers.sleep
|
||||
|
||||
@@ -22,20 +23,24 @@ describe('fileio', function()
|
||||
end)
|
||||
|
||||
it('fsync() codepaths #8304', function()
|
||||
-- This is an "acceptance test" or "smoke test".
|
||||
|
||||
clear({ args={ '-i', 'Xtest_startup_shada',
|
||||
'--cmd', 'set directory=Xtest_startup_swapdir' } })
|
||||
|
||||
-- These cases ALWAYS force fsync (regardless of 'fsync' option):
|
||||
|
||||
-- 1. Idle (CursorHold) with modified buffers (+ 'swapfile').
|
||||
command('set swapfile')
|
||||
command('set updatetime=1')
|
||||
command('write Xtest_startup_file1')
|
||||
feed('ifoo<esc>h')
|
||||
sleep(2)
|
||||
eq(1, eval('&modified'))
|
||||
command('write')
|
||||
eq(0, request('nvim__stats').fsync) -- 'nofsync' is the default.
|
||||
command('set swapfile')
|
||||
command('set updatetime=1')
|
||||
feed('izub<esc>h') -- File is 'modified'.
|
||||
sleep(3) -- Allow 'updatetime' to expire.
|
||||
retry(3, nil, function()
|
||||
eq(1, request('nvim__stats').fsync)
|
||||
end)
|
||||
command('set updatetime=9999')
|
||||
|
||||
-- 2. Exit caused by deadly signal (+ 'swapfile').
|
||||
local j = funcs.jobstart({ nvim_prog, '-u', 'NONE', '-i',
|
||||
@@ -51,11 +56,13 @@ describe('fileio', function()
|
||||
|
||||
-- 4. Explicit :preserve command.
|
||||
command('preserve')
|
||||
eq(2, request('nvim__stats').fsync)
|
||||
|
||||
-- 5. Enable 'fsync' option, write file.
|
||||
command('set fsync')
|
||||
feed('ibaz<esc>h')
|
||||
command('write')
|
||||
eq(4, request('nvim__stats').fsync)
|
||||
end)
|
||||
end)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user