diff options
author | Justin M. Keyes <justinkz@gmail.com> | 2018-04-23 04:43:00 +0200 |
---|---|---|
committer | Justin M. Keyes <justinkz@gmail.com> | 2018-04-23 21:29:07 +0200 |
commit | 32f3937477e05b13e05bba4463c5cfd417a2fde8 (patch) | |
tree | 6f1cd0c6cc6eb0ef8e73e927e45eaed12b204319 /test/functional/core/fileio_spec.lua | |
parent | b71697bc67dcb90002dcabaf4a61f69d04281f06 (diff) | |
download | rneovim-32f3937477e05b13e05bba4463c5cfd417a2fde8.tar.gz rneovim-32f3937477e05b13e05bba4463c5cfd417a2fde8.tar.bz2 rneovim-32f3937477e05b13e05bba4463c5cfd417a2fde8.zip |
test: fsync() codepaths
Diffstat (limited to 'test/functional/core/fileio_spec.lua')
-rw-r--r-- | test/functional/core/fileio_spec.lua | 61 |
1 files changed, 61 insertions, 0 deletions
diff --git a/test/functional/core/fileio_spec.lua b/test/functional/core/fileio_spec.lua new file mode 100644 index 0000000000..848ef7cae0 --- /dev/null +++ b/test/functional/core/fileio_spec.lua @@ -0,0 +1,61 @@ +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 rmdir = helpers.rmdir +local sleep = helpers.sleep + +describe('fileio', function() + before_each(function() + end) + after_each(function() + command(':qall!') + os.remove('Xtest_startup_shada') + os.remove('Xtest_startup_file1') + os.remove('Xtest_startup_file2') + rmdir('Xtest_startup_swapdir') + 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')) + + -- 2. Exit caused by deadly signal (+ 'swapfile'). + local j = funcs.jobstart({ nvim_prog, '-u', 'NONE', '-i', + 'Xtest_startup_shada', '--headless', + '-c', 'set swapfile', + '-c', 'write Xtest_startup_file2', + '-c', 'put =localtime()', }) + sleep(10) -- Let Nvim start. + funcs.jobstop(j) -- Send deadly signal. + + -- 3. SIGPWR signal. + -- ?? + + -- 4. Explicit :preserve command. + command('preserve') + + -- 5. Enable 'fsync' option, write file. + command('set fsync') + feed('ibaz<esc>h') + command('write') + end) +end) + |