diff options
author | Justin M. Keyes <justinkz@gmail.com> | 2024-01-03 02:09:18 +0100 |
---|---|---|
committer | Justin M. Keyes <justinkz@gmail.com> | 2024-01-03 02:09:29 +0100 |
commit | 04f2f864e270e772c6326cefdf24947f0130e492 (patch) | |
tree | 46f83f909b888a66c741032ab955afc6eab84292 /test/functional/core/main_spec.lua | |
parent | 59d117ec99b6037cb9fad5bbfb6d0b18f5012927 (diff) | |
download | rneovim-04f2f864e270e772c6326cefdf24947f0130e492.tar.gz rneovim-04f2f864e270e772c6326cefdf24947f0130e492.tar.bz2 rneovim-04f2f864e270e772c6326cefdf24947f0130e492.zip |
refactor: format test/*
Diffstat (limited to 'test/functional/core/main_spec.lua')
-rw-r--r-- | test/functional/core/main_spec.lua | 117 |
1 files changed, 83 insertions, 34 deletions
diff --git a/test/functional/core/main_spec.lua b/test/functional/core/main_spec.lua index 0501a75bd6..4a9943be20 100644 --- a/test/functional/core/main_spec.lua +++ b/test/functional/core/main_spec.lua @@ -33,27 +33,44 @@ describe('command-line option', function() it('treats - as stdin', function() eq(nil, luv.fs_stat(fname)) - funcs.system( - {nvim_prog_abs(), '-u', 'NONE', '-i', 'NONE', '--headless', - '--cmd', 'set noswapfile shortmess+=IFW fileformats=unix', - '-s', '-', fname}, - {':call setline(1, "42")', ':wqall!', ''}) + funcs.system({ + nvim_prog_abs(), + '-u', + 'NONE', + '-i', + 'NONE', + '--headless', + '--cmd', + 'set noswapfile shortmess+=IFW fileformats=unix', + '-s', + '-', + fname, + }, { ':call setline(1, "42")', ':wqall!', '' }) eq(0, eval('v:shell_error')) local attrs = luv.fs_stat(fname) - eq(#('42\n'), attrs.size) + eq(#'42\n', attrs.size) end) it('does not expand $VAR', function() eq(nil, luv.fs_stat(fname)) eq(true, not not dollar_fname:find('%$%w+')) write_file(dollar_fname, ':call setline(1, "100500")\n:wqall!\n') - funcs.system( - {nvim_prog_abs(), '-u', 'NONE', '-i', 'NONE', '--headless', - '--cmd', 'set noswapfile shortmess+=IFW fileformats=unix', - '-s', dollar_fname, fname}) + funcs.system({ + nvim_prog_abs(), + '-u', + 'NONE', + '-i', + 'NONE', + '--headless', + '--cmd', + 'set noswapfile shortmess+=IFW fileformats=unix', + '-s', + dollar_fname, + fname, + }) eq(0, eval('v:shell_error')) local attrs = luv.fs_stat(fname) - eq(#('100500\n'), attrs.size) + eq(#'100500\n', attrs.size) end) it('does not crash after reading from stdin in non-headless mode', function() @@ -61,24 +78,33 @@ describe('command-line option', function() local screen = Screen.new(40, 8) screen:attach() local args = { - nvim_prog_abs(), '-u', 'NONE', '-i', 'NONE', - '--cmd', '"set noswapfile shortmess+=IFW fileformats=unix notermguicolors"', - '-s', '-' + nvim_prog_abs(), + '-u', + 'NONE', + '-i', + 'NONE', + '--cmd', + '"set noswapfile shortmess+=IFW fileformats=unix notermguicolors"', + '-s', + '-', } -- Need to explicitly pipe to stdin so that the embedded Nvim instance doesn't try to read -- data from the terminal #18181 - funcs.termopen(string.format([[echo "" | %s]], table.concat(args, " ")), { - env = { VIMRUNTIME = os.getenv('VIMRUNTIME') } + funcs.termopen(string.format([[echo "" | %s]], table.concat(args, ' ')), { + env = { VIMRUNTIME = os.getenv('VIMRUNTIME') }, }) - screen:expect([[ + screen:expect( + [[ ^ | ~ |*4 {1:[No Name] 0,0-1 All}| |*2 - ]], { - [1] = {reverse = true}; - }) + ]], + { + [1] = { reverse = true }, + } + ) feed('i:cq<CR>') screen:expect([[ | @@ -101,12 +127,22 @@ describe('command-line option', function() it('errors out when trying to use nonexistent file with -s', function() eq( - 'Cannot open for reading: "'..nonexistent_fname..'": no such file or directory\n', - funcs.system( - {nvim_prog_abs(), '-u', 'NONE', '-i', 'NONE', '--headless', - '--cmd', 'set noswapfile shortmess+=IFW fileformats=unix', - '--cmd', 'language C', - '-s', nonexistent_fname})) + 'Cannot open for reading: "' .. nonexistent_fname .. '": no such file or directory\n', + funcs.system({ + nvim_prog_abs(), + '-u', + 'NONE', + '-i', + 'NONE', + '--headless', + '--cmd', + 'set noswapfile shortmess+=IFW fileformats=unix', + '--cmd', + 'language C', + '-s', + nonexistent_fname, + }) + ) eq(2, eval('v:shell_error')) end) @@ -114,12 +150,25 @@ describe('command-line option', function() write_file(fname, ':call setline(1, "1")\n:wqall!\n') write_file(dollar_fname, ':call setline(1, "2")\n:wqall!\n') eq( - 'Attempt to open script file again: "-s '..dollar_fname..'"\n', - funcs.system( - {nvim_prog_abs(), '-u', 'NONE', '-i', 'NONE', '--headless', - '--cmd', 'set noswapfile shortmess+=IFW fileformats=unix', - '--cmd', 'language C', - '-s', fname, '-s', dollar_fname, fname_2})) + 'Attempt to open script file again: "-s ' .. dollar_fname .. '"\n', + funcs.system({ + nvim_prog_abs(), + '-u', + 'NONE', + '-i', + 'NONE', + '--headless', + '--cmd', + 'set noswapfile shortmess+=IFW fileformats=unix', + '--cmd', + 'language C', + '-s', + fname, + '-s', + dollar_fname, + fname_2, + }) + ) eq(2, eval('v:shell_error')) eq(nil, luv.fs_stat(fname_2)) end) @@ -128,7 +177,7 @@ describe('command-line option', function() it('nvim -v, :version', function() matches('Run ":verbose version"', funcs.execute(':version')) matches('Compilation: .*Run :checkhealth', funcs.execute(':verbose version')) - matches('Run "nvim %-V1 %-v"', funcs.system({nvim_prog_abs(), '-v'})) - matches('Compilation: .*Run :checkhealth', funcs.system({nvim_prog_abs(), '-V1', '-v'})) + matches('Run "nvim %-V1 %-v"', funcs.system({ nvim_prog_abs(), '-v' })) + matches('Compilation: .*Run :checkhealth', funcs.system({ nvim_prog_abs(), '-V1', '-v' })) end) end) |