commit c0f8b3fb668b734555c796e846ec764a132d2bff
parent 1983c70d109eaaff97c998035b8f5ed19e2fcff9
Author: Justin M. Keyes <justinkz@gmail.com>
Date: Wed, 25 Feb 2026 13:06:53 -0500
refactor(test): simplify v:argf tests #38055
Diffstat:
3 files changed, 49 insertions(+), 101 deletions(-)
diff --git a/test/functional/core/startup_spec.lua b/test/functional/core/startup_spec.lua
@@ -1806,88 +1806,3 @@ describe('inccommand on ex mode', function()
]])
end)
end)
-
-describe('v:argf', function()
- local files = {}
-
- before_each(function()
- clear()
- files = {}
-
- for _, f in ipairs({
- 'Xargf_file1',
- 'Xargf_file2',
- 'Xargf_sep1',
- 'Xargf_sep2',
- 'Xargf_sep3',
- }) do
- os.remove(f)
- end
- end)
-
- after_each(function()
- for _, f in ipairs(files) do
- os.remove(f)
- end
- end)
-
- it('stores full path of file args', function()
- local file1, file2 = 'Xargf_file1', 'Xargf_file2'
- write_file(file1, '')
- write_file(file2, '')
- files = { file1, file2 }
-
- local abs1 = fn.fnamemodify(file1, ':p')
- local abs2 = fn.fnamemodify(file2, ':p')
-
- local p = n.spawn_wait('--cmd', 'echo v:argf', '-c', 'qall', file1, file2)
-
- eq(0, p.status)
- matches(pesc(abs1), p.stderr)
- matches(pesc(abs2), p.stderr)
- end)
-
- it('argadd does not affect v:argf', function()
- local file1, file2 = 'Xargf_file1', 'Xargf_file2'
- write_file(file1, '')
- write_file(file2, '')
- files = { file1, file2 }
-
- local p = n.spawn_wait(
- '--cmd',
- 'argadd extrafile.txt',
- '--cmd',
- 'echo v:argf',
- '-c',
- 'qall',
- file1,
- file2
- )
-
- eq(0, p.status)
- eq(nil, string.find(p.stderr, 'extrafile.txt'))
- end)
-
- it('handles -- separator correctly', function()
- local file1, file2, file3 = 'Xargf_sep1', 'Xargf_sep2', 'Xargf_sep3'
- write_file(file1, '')
- write_file(file2, '')
- write_file(file3, '')
- files = { file1, file2, file3 }
-
- local abs1 = fn.fnamemodify(file1, ':p')
- local abs2 = fn.fnamemodify(file2, ':p')
- local abs3 = fn.fnamemodify(file3, ':p')
-
- local p = n.spawn_wait(file1, '--cmd', 'echo v:argf', '-c', 'qall', '--', file2, file3)
-
- eq(0, p.status)
- matches(pesc(abs1), p.stderr)
- matches(pesc(abs2), p.stderr)
- matches(pesc(abs3), p.stderr)
- end)
-
- it('is read-only', function()
- matches('E46', t.pcall_err(command, "let v:argf = ['foo']"))
- end)
-end)
diff --git a/test/functional/vimscript/vvar_event_spec.lua b/test/functional/vimscript/vvar_event_spec.lua
@@ -1,16 +0,0 @@
-local t = require('test.testutil')
-local n = require('test.functional.testnvim')()
-
-local clear, eval, eq = n.clear, n.eval, t.eq
-local command = n.command
-describe('v:event', function()
- before_each(clear)
- it('is empty before any autocommand', function()
- eq({}, eval('v:event'))
- end)
-
- it('is immutable', function()
- eq(false, pcall(command, 'let v:event = {}'))
- eq(false, pcall(command, 'let v:event.mykey = {}'))
- end)
-end)
diff --git a/test/functional/vimscript/vvars_spec.lua b/test/functional/vimscript/vvars_spec.lua
@@ -0,0 +1,49 @@
+local t = require('test.testutil')
+local n = require('test.functional.testnvim')()
+
+local clear, eval, eq = n.clear, n.eval, t.eq
+local command = n.command
+
+describe('v:event', function()
+ before_each(clear)
+ it('is empty before any autocommand', function()
+ eq({}, eval('v:event'))
+ end)
+
+ it('is immutable', function()
+ eq(false, pcall(command, 'let v:event = {}'))
+ eq(false, pcall(command, 'let v:event.mykey = {}'))
+ end)
+end)
+
+describe('v:argf', function()
+ it('is read-only', function()
+ n.clear()
+ t.matches('E46', t.pcall_err(command, "let v:argf = ['foo']"))
+ end)
+
+ it('gets file args, ignores :argadd, handles "--"', function()
+ local file1, file2, file3 = 'Xargf_sep1', 'Xargf_sep2', 'Xargf_sep3'
+
+ n.clear {
+ args_rm = { '--cmd', '-c' },
+ args = {
+ '--clean',
+ '--cmd',
+ 'argadd extrafile.txt', -- :argadd should not affect v:argf.
+ file1,
+ file2,
+ '-c',
+ 'let a = 1 + 3',
+ '--',
+ file3,
+ },
+ }
+
+ local abs1 = n.fn.fnamemodify(file1, ':p')
+ local abs2 = n.fn.fnamemodify(file2, ':p')
+ local abs3 = n.fn.fnamemodify(file3, ':p')
+
+ eq({ abs1, abs2, abs3 }, n.eval('v:argf'))
+ end)
+end)