aboutsummaryrefslogtreecommitdiff
path: root/test/functional/ex_cmds
diff options
context:
space:
mode:
authorJosh Rahm <joshuarahm@gmail.com>2023-11-29 22:39:54 +0000
committerJosh Rahm <joshuarahm@gmail.com>2023-11-29 22:39:54 +0000
commit21cb7d04c387e4198ca8098a884c78b56ffcf4c2 (patch)
tree84fe5690df1551f0bb2bdfe1a13aacd29ebc1de7 /test/functional/ex_cmds
parentd9c904f85a23a496df4eb6be42aa43f007b22d50 (diff)
parent4a8bf24ac690004aedf5540fa440e788459e5e34 (diff)
downloadrneovim-colorcolchar.tar.gz
rneovim-colorcolchar.tar.bz2
rneovim-colorcolchar.zip
Merge remote-tracking branch 'upstream/master' into colorcolcharcolorcolchar
Diffstat (limited to 'test/functional/ex_cmds')
-rw-r--r--test/functional/ex_cmds/append_spec.lua3
-rw-r--r--test/functional/ex_cmds/cd_spec.lua9
-rw-r--r--test/functional/ex_cmds/cmd_map_spec.lua6
-rw-r--r--test/functional/ex_cmds/dict_notifications_spec.lua2
-rw-r--r--test/functional/ex_cmds/excmd_spec.lua37
-rw-r--r--test/functional/ex_cmds/file_spec.lua7
-rw-r--r--test/functional/ex_cmds/help_spec.lua17
-rw-r--r--test/functional/ex_cmds/highlight_spec.lua30
-rw-r--r--test/functional/ex_cmds/ls_spec.lua2
-rw-r--r--test/functional/ex_cmds/make_spec.lua12
-rw-r--r--test/functional/ex_cmds/map_spec.lua4
-rw-r--r--test/functional/ex_cmds/mksession_spec.lua20
-rw-r--r--test/functional/ex_cmds/mkview_spec.lua6
-rw-r--r--test/functional/ex_cmds/oldfiles_spec.lua5
-rw-r--r--test/functional/ex_cmds/profile_spec.lua13
-rw-r--r--test/functional/ex_cmds/script_spec.lua5
-rw-r--r--test/functional/ex_cmds/source_spec.lua130
-rw-r--r--test/functional/ex_cmds/swapfile_preserve_recover_spec.lua235
-rw-r--r--test/functional/ex_cmds/trust_spec.lua117
-rw-r--r--test/functional/ex_cmds/verbose_spec.lua25
-rw-r--r--test/functional/ex_cmds/write_spec.lua12
-rw-r--r--test/functional/ex_cmds/wviminfo_spec.lua8
22 files changed, 434 insertions, 271 deletions
diff --git a/test/functional/ex_cmds/append_spec.lua b/test/functional/ex_cmds/append_spec.lua
index fadb5c9b42..4134eed87e 100644
--- a/test/functional/ex_cmds/append_spec.lua
+++ b/test/functional/ex_cmds/append_spec.lua
@@ -8,6 +8,7 @@ local clear = helpers.clear
local funcs = helpers.funcs
local command = helpers.command
local curbufmeths = helpers.curbufmeths
+local meths = helpers.meths
local Screen = require('test.functional.ui.screen')
local cmdtest = function(cmd, prep, ret1)
@@ -42,7 +43,7 @@ local cmdtest = function(cmd, prep, ret1)
eq(hisline, funcs.histget(':', -2))
eq(cmd, funcs.histget(':'))
-- Test that command-line window was launched
- eq('nofile', curbufmeths.get_option('buftype'))
+ eq('nofile', meths.get_option_value('buftype', {}))
eq('n', funcs.mode(1))
feed('<CR>')
eq('c', funcs.mode(1))
diff --git a/test/functional/ex_cmds/cd_spec.lua b/test/functional/ex_cmds/cd_spec.lua
index 5ed71651c7..b6a3713158 100644
--- a/test/functional/ex_cmds/cd_spec.lua
+++ b/test/functional/ex_cmds/cd_spec.lua
@@ -1,6 +1,6 @@
-- Specs for :cd, :tcd, :lcd and getcwd()
-local lfs = require('lfs')
+local luv = require('luv')
local helpers = require('test.functional.helpers')(after_each)
local eq = helpers.eq
@@ -11,6 +11,7 @@ local exc_exec = helpers.exc_exec
local pathsep = helpers.get_pathsep()
local skip = helpers.skip
local is_os = helpers.is_os
+local mkdir = helpers.mkdir
-- These directories will be created for testing
local directories = {
@@ -36,14 +37,14 @@ for _, cmd in ipairs {'cd', 'chdir'} do
before_each(function()
clear()
for _, d in pairs(directories) do
- lfs.mkdir(d)
+ mkdir(d)
end
directories.start = cwd()
end)
after_each(function()
for _, d in pairs(directories) do
- lfs.rmdir(d)
+ luv.fs_rmdir(d)
end
end)
@@ -273,7 +274,7 @@ end
describe("getcwd()", function ()
before_each(function()
clear()
- lfs.mkdir(directories.global)
+ mkdir(directories.global)
end)
after_each(function()
diff --git a/test/functional/ex_cmds/cmd_map_spec.lua b/test/functional/ex_cmds/cmd_map_spec.lua
index 919d167712..2a2628350d 100644
--- a/test/functional/ex_cmds/cmd_map_spec.lua
+++ b/test/functional/ex_cmds/cmd_map_spec.lua
@@ -90,7 +90,7 @@ describe('mappings with <Cmd>', function()
{1:~ }|
{1:~ }|
{1:~ }|
- {2:E5521: <Cmd> mapping must end with <CR> before second <Cmd>} |
+ {2:E1136: <Cmd> mapping must end with <CR> before second <Cmd>} |
]])
command('noremap <F3> <Cmd>let x = 3')
@@ -103,7 +103,7 @@ describe('mappings with <Cmd>', function()
{1:~ }|
{1:~ }|
{1:~ }|
- {2:E5520: <Cmd> mapping must end with <CR>} |
+ {2:E1255: <Cmd> mapping must end with <CR>} |
]])
eq(0, eval('x'))
end)
@@ -451,7 +451,7 @@ describe('mappings with <Cmd>', function()
]])
eq('s', funcs.mode(1))
- -- visual mapping in select mode restart selct mode after operator
+ -- visual mapping in select mode restart select mode after operator
feed('<F5>')
eq('s', funcs.mode(1))
eq({'some short l'}, funcs.getreg('a',1,1))
diff --git a/test/functional/ex_cmds/dict_notifications_spec.lua b/test/functional/ex_cmds/dict_notifications_spec.lua
index afa6b519d5..6a0b40bd88 100644
--- a/test/functional/ex_cmds/dict_notifications_spec.lua
+++ b/test/functional/ex_cmds/dict_notifications_spec.lua
@@ -9,7 +9,7 @@ local command = helpers.command
local eval = helpers.eval
-describe('VimL dictionary notifications', function()
+describe('Vimscript dictionary notifications', function()
local channel
before_each(function()
diff --git a/test/functional/ex_cmds/excmd_spec.lua b/test/functional/ex_cmds/excmd_spec.lua
index e243f3c524..a92329ede5 100644
--- a/test/functional/ex_cmds/excmd_spec.lua
+++ b/test/functional/ex_cmds/excmd_spec.lua
@@ -2,6 +2,7 @@ local helpers = require("test.functional.helpers")(after_each)
local command = helpers.command
local eq = helpers.eq
local clear = helpers.clear
+local funcs = helpers.funcs
local pcall_err = helpers.pcall_err
local assert_alive = helpers.assert_alive
@@ -10,21 +11,43 @@ describe('Ex cmds', function()
clear()
end)
+ local function check_excmd_err(cmd, err)
+ eq(err .. ': ' .. cmd, pcall_err(command, cmd))
+ end
+
it('handle integer overflow from user-input #5555', function()
command(':9999999999999999999999999999999999999999')
command(':later 9999999999999999999999999999999999999999')
command(':echo expand("#<9999999999999999999999999999999999999999")')
command(':lockvar 9999999999999999999999999999999999999999')
command(':winsize 9999999999999999999999999999999999999999 9999999999999999999999999999999999999999')
- eq('Vim(tabnext):E475: Invalid argument: 9999999999999999999999999999999999999999',
- pcall_err(command, ':tabnext 9999999999999999999999999999999999999999'))
- eq('Vim(Next):E939: Positive count required',
- pcall_err(command, ':N 9999999999999999999999999999999999999999'))
+ check_excmd_err(':tabnext 9999999999999999999999999999999999999999',
+ 'Vim(tabnext):E475: Invalid argument: 9999999999999999999999999999999999999999')
+ check_excmd_err(':N 9999999999999999999999999999999999999999',
+ 'Vim(Next):E939: Positive count required')
+ check_excmd_err(':bdelete 9999999999999999999999999999999999999999',
+ 'Vim(bdelete):E939: Positive count required')
eq('Vim(menu):E329: No menu "9999999999999999999999999999999999999999"',
pcall_err(command, ':menu 9999999999999999999999999999999999999999'))
- eq('Vim(bdelete):E939: Positive count required',
- pcall_err(command, ':bdelete 9999999999999999999999999999999999999999'))
assert_alive()
end)
-end)
+ it('listing long user command does not crash', function()
+ command('execute "command" repeat("T", 255) ":"')
+ command('command')
+ end)
+
+ it(':def is an unknown command #23149', function()
+ eq('Vim:E492: Not an editor command: def', pcall_err(command, 'def'))
+ eq(1, funcs.exists(':d'))
+ eq('delete', funcs.fullcommand('d'))
+ eq(1, funcs.exists(':de'))
+ eq('delete', funcs.fullcommand('de'))
+ eq(0, funcs.exists(':def'))
+ eq('', funcs.fullcommand('def'))
+ eq(1, funcs.exists(':defe'))
+ eq('defer', funcs.fullcommand('defe'))
+ eq(2, funcs.exists(':defer'))
+ eq('defer', funcs.fullcommand('defer'))
+ end)
+end)
diff --git a/test/functional/ex_cmds/file_spec.lua b/test/functional/ex_cmds/file_spec.lua
index 771c283134..131661828e 100644
--- a/test/functional/ex_cmds/file_spec.lua
+++ b/test/functional/ex_cmds/file_spec.lua
@@ -1,17 +1,18 @@
local helpers = require('test.functional.helpers')(after_each)
-local lfs = require('lfs')
+local luv = require('luv')
local clear = helpers.clear
local command = helpers.command
local eq = helpers.eq
local funcs = helpers.funcs
local rmdir = helpers.rmdir
+local mkdir = helpers.mkdir
describe(':file', function()
- local swapdir = lfs.currentdir()..'/Xtest-file_spec'
+ local swapdir = luv.cwd()..'/Xtest-file_spec'
before_each(function()
clear()
rmdir(swapdir)
- lfs.mkdir(swapdir)
+ mkdir(swapdir)
end)
after_each(function()
command('%bwipeout!')
diff --git a/test/functional/ex_cmds/help_spec.lua b/test/functional/ex_cmds/help_spec.lua
index 0ec7249218..aca0cbbaa6 100644
--- a/test/functional/ex_cmds/help_spec.lua
+++ b/test/functional/ex_cmds/help_spec.lua
@@ -4,6 +4,10 @@ local clear = helpers.clear
local command = helpers.command
local eq = helpers.eq
local funcs = helpers.funcs
+local meths = helpers.meths
+local mkdir = helpers.mkdir
+local rmdir = helpers.rmdir
+local write_file = helpers.write_file
describe(':help', function()
before_each(clear)
@@ -25,4 +29,17 @@ describe(':help', function()
-- Before #9773, Nvim would crash on quitting the help window.
eq(1002, funcs.win_getid())
end)
+
+ it('multibyte help tags work #23975', function()
+ mkdir('Xhelptags')
+ finally(function()
+ rmdir('Xhelptags')
+ end)
+ mkdir('Xhelptags/doc')
+ write_file('Xhelptags/doc/Xhelptags.txt', '*…*')
+ command('helptags Xhelptags/doc')
+ command('set rtp+=Xhelptags')
+ command('help …')
+ eq('*…*', meths.get_current_line())
+ end)
end)
diff --git a/test/functional/ex_cmds/highlight_spec.lua b/test/functional/ex_cmds/highlight_spec.lua
index 1cd6759a53..958dd99226 100644
--- a/test/functional/ex_cmds/highlight_spec.lua
+++ b/test/functional/ex_cmds/highlight_spec.lua
@@ -3,6 +3,9 @@ local helpers = require("test.functional.helpers")(after_each)
local eq, command = helpers.eq, helpers.command
local clear = helpers.clear
local eval, exc_exec = helpers.eval, helpers.exc_exec
+local exec = helpers.exec
+local funcs = helpers.funcs
+local meths = helpers.meths
describe(':highlight', function()
local screen
@@ -21,7 +24,7 @@ describe(':highlight', function()
end)
it('invalid group name', function()
- eq('Vim(highlight):E411: highlight group not found: foo',
+ eq('Vim(highlight):E411: Highlight group not found: foo',
exc_exec("highlight foo"))
end)
@@ -36,4 +39,29 @@ describe(':highlight', function()
command('highlight normal ctermbg=red')
eq('9', eval('synIDattr(hlID("Normal"), "bg", "cterm")'))
end)
+
+ it('only the last underline style takes effect #22371', function()
+ command('highlight NonText gui=underline,undercurl')
+ eq('', eval('synIDattr(hlID("NonText"), "underline", "gui")'))
+ eq('1', eval('synIDattr(hlID("NonText"), "undercurl", "gui")'))
+ command('highlight NonText gui=undercurl,underline')
+ eq('', eval('synIDattr(hlID("NonText"), "undercurl", "gui")'))
+ eq('1', eval('synIDattr(hlID("NonText"), "underline", "gui")'))
+ end)
+
+ it('clear', function()
+ meths.set_var('colors_name', 'foo')
+ eq(1, funcs.exists('g:colors_name'))
+ command('hi clear')
+ eq(0, funcs.exists('g:colors_name'))
+ meths.set_var('colors_name', 'foo')
+ eq(1, funcs.exists('g:colors_name'))
+ exec([[
+ func HiClear()
+ hi clear
+ endfunc
+ ]])
+ funcs.HiClear()
+ eq(0, funcs.exists('g:colors_name'))
+ end)
end)
diff --git a/test/functional/ex_cmds/ls_spec.lua b/test/functional/ex_cmds/ls_spec.lua
index 2583d80269..d02af21731 100644
--- a/test/functional/ex_cmds/ls_spec.lua
+++ b/test/functional/ex_cmds/ls_spec.lua
@@ -14,7 +14,7 @@ describe(':ls', function()
end)
it('R, F for :terminal buffers', function()
- nvim('set_option', 'shell', string.format('"%s" INTERACT', testprg('shell-test')))
+ nvim('set_option_value', 'shell', string.format('"%s" INTERACT', testprg('shell-test')), {})
command('edit foo')
command('set hidden')
diff --git a/test/functional/ex_cmds/make_spec.lua b/test/functional/ex_cmds/make_spec.lua
index bf585ee44c..d82f59ddf9 100644
--- a/test/functional/ex_cmds/make_spec.lua
+++ b/test/functional/ex_cmds/make_spec.lua
@@ -22,20 +22,18 @@ describe(':make', function()
end)
it('captures stderr & non zero exit code #14349', function ()
- nvim('set_option', 'makeprg', testprg('shell-test')..' foo')
+ nvim('set_option_value', 'makeprg', testprg('shell-test')..' foo', {})
local out = eval('execute("make")')
- -- Make program exit code correctly captured
- matches('\nshell returned 3', out)
-- Error message is captured in the file and printed in the footer
- matches('\n.*%: Unknown first argument%: foo', out)
+ matches('[\r\n]+.*[\r\n]+Unknown first argument%: foo[\r\n]+%(1 of 1%)%: Unknown first argument%: foo', out)
end)
it('captures stderr & zero exit code #14349', function ()
- nvim('set_option', 'makeprg', testprg('shell-test'))
+ nvim('set_option_value', 'makeprg', testprg('shell-test'), {})
local out = eval('execute("make")')
-- Ensure there are no "shell returned X" messages between
- -- command and last line (indicating zero exit)
- matches('LastExitCode%s+[(]', out)
+ -- command and last line (indicating zero exit)
+ matches('LastExitCode%s+ready [$]%s+[(]', out)
matches('\n.*%: ready [$]', out)
end)
diff --git a/test/functional/ex_cmds/map_spec.lua b/test/functional/ex_cmds/map_spec.lua
index ec912053b2..a580e88b93 100644
--- a/test/functional/ex_cmds/map_spec.lua
+++ b/test/functional/ex_cmds/map_spec.lua
@@ -18,7 +18,7 @@ describe(':*map', function()
it('are not affected by &isident', function()
meths.set_var('counter', 0)
command('nnoremap <C-x> :let counter+=1<CR>')
- meths.set_option('isident', ('%u'):format(('>'):byte()))
+ meths.set_option_value('isident', ('%u'):format(('>'):byte()), {})
command('nnoremap <C-y> :let counter+=1<CR>')
-- &isident used to disable keycode parsing here as well
feed('\24\25<C-x><C-y>')
@@ -152,7 +152,7 @@ describe('Screen', function()
~ |
~ |
~ |
- > |
+ -- INSERT -- |
]])
end)
diff --git a/test/functional/ex_cmds/mksession_spec.lua b/test/functional/ex_cmds/mksession_spec.lua
index 0a0c7ca410..7522d4a99c 100644
--- a/test/functional/ex_cmds/mksession_spec.lua
+++ b/test/functional/ex_cmds/mksession_spec.lua
@@ -1,4 +1,3 @@
-local lfs = require('lfs')
local helpers = require('test.functional.helpers')(after_each)
local Screen = require('test.functional.ui.screen')
@@ -15,16 +14,19 @@ local sleep = helpers.sleep
local meths = helpers.meths
local skip = helpers.skip
local is_os = helpers.is_os
+local mkdir = helpers.mkdir
local file_prefix = 'Xtest-functional-ex_cmds-mksession_spec'
+if helpers.skip(helpers.is_os('win')) then return end
+
describe(':mksession', function()
local session_file = file_prefix .. '.vim'
local tab_dir = file_prefix .. '.d'
before_each(function()
clear()
- lfs.mkdir(tab_dir)
+ mkdir(tab_dir)
end)
after_each(function()
@@ -79,13 +81,13 @@ describe(':mksession', function()
local buf_count = #meths.list_bufs()
eq(2, buf_count)
- eq('terminal', meths.buf_get_option(0, 'buftype'))
+ eq('terminal', meths.get_option_value('buftype', {}))
test_terminal_session_disabled(2)
-- no terminal should be set. As a side effect we end up with a blank buffer
- eq('', meths.buf_get_option(meths.list_bufs()[1], 'buftype'))
- eq('', meths.buf_get_option(meths.list_bufs()[2], 'buftype'))
+ eq('', meths.get_option_value('buftype', { buf = meths.list_bufs()[1] }))
+ eq('', meths.get_option_value('buftype', { buf = meths.list_bufs()[2] }))
end
)
@@ -110,7 +112,7 @@ describe(':mksession', function()
it('do not restore :terminal if not set in sessionoptions, only buffer #13078', function()
command('terminal')
- eq('terminal', meths.buf_get_option(0, 'buftype'))
+ eq('terminal', meths.get_option_value('buftype', {}))
local buf_count = #meths.list_bufs()
eq(1, buf_count)
@@ -118,7 +120,7 @@ describe(':mksession', function()
test_terminal_session_disabled(1)
-- no terminal should be set
- eq('', meths.buf_get_option(0, 'buftype'))
+ eq('', meths.get_option_value('buftype', {}))
end)
it('restores tab-local working directories', function()
@@ -247,7 +249,7 @@ describe(':mksession', function()
style = 'minimal',
}
meths.open_win(buf, false, config)
- local cmdheight = meths.get_option('cmdheight')
+ local cmdheight = meths.get_option_value('cmdheight', {})
command('mksession ' .. session_file)
-- Create a new test instance of Nvim.
@@ -260,7 +262,7 @@ describe(':mksession', function()
-- window was not restored.
eq(1, funcs.winnr('$'))
-- The command-line height should remain the same as it was.
- eq(cmdheight, meths.get_option('cmdheight'))
+ eq(cmdheight, meths.get_option_value('cmdheight', {}))
os.remove(tmpfile)
end)
diff --git a/test/functional/ex_cmds/mkview_spec.lua b/test/functional/ex_cmds/mkview_spec.lua
index fef8065b2e..f71b826210 100644
--- a/test/functional/ex_cmds/mkview_spec.lua
+++ b/test/functional/ex_cmds/mkview_spec.lua
@@ -1,4 +1,3 @@
-local lfs = require('lfs')
local helpers = require('test.functional.helpers')(after_each)
local clear = helpers.clear
@@ -7,6 +6,7 @@ local get_pathsep = helpers.get_pathsep
local eq = helpers.eq
local funcs = helpers.funcs
local rmdir = helpers.rmdir
+local mkdir = helpers.mkdir
local file_prefix = 'Xtest-functional-ex_cmds-mkview_spec'
@@ -17,8 +17,8 @@ describe(':mkview', function()
before_each(function()
clear()
- lfs.mkdir(view_dir)
- lfs.mkdir(local_dir)
+ mkdir(view_dir)
+ mkdir(local_dir)
end)
after_each(function()
diff --git a/test/functional/ex_cmds/oldfiles_spec.lua b/test/functional/ex_cmds/oldfiles_spec.lua
index 5f87c3cdd9..19611429e0 100644
--- a/test/functional/ex_cmds/oldfiles_spec.lua
+++ b/test/functional/ex_cmds/oldfiles_spec.lua
@@ -2,6 +2,8 @@ local Screen = require('test.functional.ui.screen')
local helpers = require('test.functional.helpers')(after_each)
local clear = helpers.clear
+local command = helpers.command
+local expect_exit = helpers.expect_exit
local buf, eq, feed_command = helpers.curbufmeths, helpers.eq, helpers.feed_command
local feed, poke_eventloop = helpers.feed, helpers.poke_eventloop
local ok = helpers.ok
@@ -19,6 +21,7 @@ describe(':oldfiles', function()
before_each(_clear)
after_each(function()
+ expect_exit(command, 'qall!')
os.remove(shada_file)
end)
@@ -42,6 +45,7 @@ describe(':oldfiles', function()
|
Press ENTER or type command to continue^ |
]])
+ feed('<CR>')
end)
it('can be filtered with :filter', function()
@@ -107,6 +111,7 @@ describe(':browse oldfiles', function()
end)
after_each(function()
+ expect_exit(command, 'qall!')
os.remove(shada_file)
end)
diff --git a/test/functional/ex_cmds/profile_spec.lua b/test/functional/ex_cmds/profile_spec.lua
index 2b92f8d0de..249373a9c4 100644
--- a/test/functional/ex_cmds/profile_spec.lua
+++ b/test/functional/ex_cmds/profile_spec.lua
@@ -1,5 +1,5 @@
require('os')
-local lfs = require('lfs')
+local luv = require('luv')
local helpers = require('test.functional.helpers')(after_each)
local eval = helpers.eval
@@ -12,25 +12,24 @@ local read_file = helpers.read_file
-- tmpname() also creates the file on POSIX systems. Remove it again.
-- We just need the name, ignoring any race conditions.
-if lfs.attributes(tempfile, 'uid') then
+if luv.fs_stat(tempfile).uid then
os.remove(tempfile)
end
local function assert_file_exists(filepath)
- -- Use 2-argument lfs.attributes() so no extra table gets created.
- -- We don't really care for the uid.
- neq(nil, lfs.attributes(filepath, 'uid'))
+ neq(nil, luv.fs_stat(filepath).uid)
end
local function assert_file_exists_not(filepath)
- eq(nil, lfs.attributes(filepath, 'uid'))
+ eq(nil, luv.fs_stat(filepath))
end
describe(':profile', function()
before_each(helpers.clear)
after_each(function()
- if lfs.attributes(tempfile, 'uid') ~= nil then
+ helpers.expect_exit(command, 'qall!')
+ if luv.fs_stat(tempfile).uid ~= nil then
os.remove(tempfile)
end
end)
diff --git a/test/functional/ex_cmds/script_spec.lua b/test/functional/ex_cmds/script_spec.lua
index bf69ada820..62249caa5e 100644
--- a/test/functional/ex_cmds/script_spec.lua
+++ b/test/functional/ex_cmds/script_spec.lua
@@ -3,6 +3,7 @@ local helpers = require('test.functional.helpers')(after_each)
local eq = helpers.eq
local neq = helpers.neq
local command = helpers.command
+local exec_capture = helpers.exec_capture
local write_file = helpers.write_file
local meths = helpers.meths
local clear = helpers.clear
@@ -34,7 +35,7 @@ describe('script_get-based command', function()
%s %s
endif
]])):format(cmd, garbage)))
- eq('', meths.exec('messages', true))
+ eq('', exec_capture('messages'))
if check_neq then
neq(0, exc_exec(dedent([[
%s %s
@@ -49,7 +50,7 @@ describe('script_get-based command', function()
EOF
endif
]])):format(cmd, garbage)))
- eq('', meths.exec('messages', true))
+ eq('', exec_capture('messages'))
if check_neq then
eq(true, pcall(source, (dedent([[
let g:exc = 0
diff --git a/test/functional/ex_cmds/source_spec.lua b/test/functional/ex_cmds/source_spec.lua
index 64c3464be7..24987354a4 100644
--- a/test/functional/ex_cmds/source_spec.lua
+++ b/test/functional/ex_cmds/source_spec.lua
@@ -7,6 +7,7 @@ local meths = helpers.meths
local feed = helpers.feed
local feed_command = helpers.feed_command
local write_file = helpers.write_file
+local tmpname = helpers.tmpname
local exec = helpers.exec
local exc_exec = helpers.exc_exec
local exec_lua = helpers.exec_lua
@@ -48,7 +49,7 @@ describe(':source', function()
pending("'shellslash' only works on Windows")
return
end
- meths.set_option('shellslash', false)
+ meths.set_option_value('shellslash', false, {})
mkdir('Xshellslash')
write_file([[Xshellslash/Xstack.vim]], [[
@@ -96,12 +97,12 @@ describe(':source', function()
let d = s:s]])
command('source')
- eq('2', meths.exec('echo a', true))
- eq("{'k': 'v'}", meths.exec('echo b', true))
+ eq('2', exec_capture('echo a'))
+ eq("{'k': 'v'}", exec_capture('echo b'))
-- Script items are created only on script var access
- eq("1", meths.exec('echo c', true))
- eq("0zBEEFCAFE", meths.exec('echo d', true))
+ eq("1", exec_capture('echo c'))
+ eq("0zBEEFCAFE", exec_capture('echo d'))
exec('set cpoptions+=C')
eq('Vim(let):E723: Missing end of Dictionary \'}\': ', exc_exec('source'))
@@ -124,14 +125,14 @@ describe(':source', function()
-- Source the 2nd line only
feed('ggjV')
feed_command(':source')
- eq('3', meths.exec('echo a', true))
+ eq('3', exec_capture('echo a'))
-- Source from 2nd line to end of file
feed('ggjVG')
feed_command(':source')
- eq('4', meths.exec('echo a', true))
- eq("{'K': 'V'}", meths.exec('echo b', true))
- eq("<SNR>1_C()", meths.exec('echo D()', true))
+ eq('4', exec_capture('echo a'))
+ eq("{'K': 'V'}", exec_capture('echo b'))
+ eq("<SNR>1_C()", exec_capture('echo D()'))
-- Source last line only
feed_command(':$source')
@@ -147,7 +148,7 @@ describe(':source', function()
let a = 123
]]
command('source')
- eq('123', meths.exec('echo a', true))
+ eq('123', exec_capture('echo a'))
end)
it('multiline heredoc command', function()
@@ -157,7 +158,7 @@ describe(':source', function()
EOF]])
command('source')
- eq('4', meths.exec('echo luaeval("y")', true))
+ eq('4', exec_capture('echo luaeval("y")'))
end)
it('can source lua files', function()
@@ -179,56 +180,65 @@ describe(':source', function()
os.remove(test_file)
end)
- it('can source selected region in lua file', function()
- local test_file = 'test.lua'
-
- write_file (test_file, [[
- vim.g.b = 5
- vim.g.b = 6
- vim.g.b = 7
- a = [=[
- "\ a
- \ b]=]
- ]])
-
- command('edit '..test_file)
-
- feed('ggjV')
- feed_command(':source')
- eq(6, eval('g:b'))
-
- feed('GVkk')
- feed_command(':source')
- eq(' "\\ a\n \\ b', exec_lua('return _G.a'))
-
- os.remove(test_file)
- end)
-
- it('can source current lua buffer without argument', function()
- local test_file = 'test.lua'
-
- write_file(test_file, [[
- vim.g.c = 10
- vim.g.c = 11
- vim.g.c = 12
- a = [=[
- \ 1
- "\ 2]=]
- vim.g.sfile_value = vim.fn.expand('<sfile>')
- vim.g.stack_value = vim.fn.expand('<stack>')
- vim.g.script_value = vim.fn.expand('<script>')
- ]])
-
- command('edit '..test_file)
- feed_command(':source')
-
- eq(12, eval('g:c'))
- eq(' \\ 1\n "\\ 2', exec_lua('return _G.a'))
- eq(':source (no file)', meths.get_var('sfile_value'))
- eq(':source (no file)', meths.get_var('stack_value'))
- eq(':source (no file)', meths.get_var('script_value'))
+ describe('can source current buffer', function()
+ local function test_source_lua_curbuf()
+ it('selected region', function()
+ insert([[
+ vim.g.b = 5
+ vim.g.b = 6
+ vim.g.b = 7
+ a = [=[
+ "\ a
+ \ b]=]
+ ]])
+ feed('dd')
+
+ feed('ggjV')
+ feed_command(':source')
+ eq(6, eval('g:b'))
+
+ feed('GVkk')
+ feed_command(':source')
+ eq(' "\\ a\n \\ b', exec_lua('return _G.a'))
+ end)
+
+ it('whole buffer', function()
+ insert([[
+ vim.g.c = 10
+ vim.g.c = 11
+ vim.g.c = 12
+ a = [=[
+ \ 1
+ "\ 2]=]
+ vim.g.sfile_value = vim.fn.expand('<sfile>')
+ vim.g.stack_value = vim.fn.expand('<stack>')
+ vim.g.script_value = vim.fn.expand('<script>')
+ ]])
+ feed('dd')
+
+ feed_command(':source')
+
+ eq(12, eval('g:c'))
+ eq(' \\ 1\n "\\ 2', exec_lua('return _G.a'))
+ eq(':source (no file)', meths.get_var('sfile_value'))
+ eq(':source (no file)', meths.get_var('stack_value'))
+ eq(':source (no file)', meths.get_var('script_value'))
+ end)
+ end
- os.remove(test_file)
+ describe('with ft=lua', function()
+ before_each(function()
+ command('setlocal ft=lua')
+ end)
+ test_source_lua_curbuf()
+ end)
+
+ describe('with .lua extension', function()
+ before_each(function()
+ command('edit ' .. tmpname() .. '.lua')
+ end)
+ test_source_lua_curbuf()
+ end)
end)
it("doesn't throw E484 for lua parsing/runtime errors", function()
diff --git a/test/functional/ex_cmds/swapfile_preserve_recover_spec.lua b/test/functional/ex_cmds/swapfile_preserve_recover_spec.lua
index 8eed00c973..436873b464 100644
--- a/test/functional/ex_cmds/swapfile_preserve_recover_spec.lua
+++ b/test/functional/ex_cmds/swapfile_preserve_recover_spec.lua
@@ -1,6 +1,5 @@
local Screen = require('test.functional.ui.screen')
local helpers = require('test.functional.helpers')(after_each)
-local lfs = require('lfs')
local luv = require('luv')
local eq, eval, expect, exec =
helpers.eq, helpers.eval, helpers.expect, helpers.exec
@@ -13,13 +12,19 @@ local nvim_prog = helpers.nvim_prog
local ok = helpers.ok
local rmdir = helpers.rmdir
local new_argv = helpers.new_argv
+local new_pipename = helpers.new_pipename