aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--CMakeLists.txt10
-rw-r--r--Makefile5
-rw-r--r--cmake/RunTestsLint.cmake11
-rw-r--r--test/.luacheckrc13
-rw-r--r--test/benchmark/bench_re_freeze_spec.lua2
-rw-r--r--test/functional/api/menu_spec.lua2
-rw-r--r--test/functional/api/server_requests_spec.lua4
-rw-r--r--test/functional/api/vim_spec.lua2
-rw-r--r--test/functional/api/window_spec.lua8
-rw-r--r--test/functional/autocmd/tabclose_spec.lua5
-rw-r--r--test/functional/autocmd/tabnew_spec.lua6
-rw-r--r--test/functional/autocmd/tabnewentered_spec.lua6
-rw-r--r--test/functional/autocmd/termclose_spec.lua4
-rw-r--r--test/functional/clipboard/clipboard_provider_spec.lua1
-rw-r--r--test/functional/eval/glob_spec.lua1
-rw-r--r--test/functional/eval/msgpack_functions_spec.lua12
-rw-r--r--test/functional/ex_cmds/grep_spec.lua5
-rw-r--r--test/functional/ex_cmds/oldfiles_spec.lua7
-rw-r--r--test/functional/ex_cmds/profile_spec.lua2
-rw-r--r--test/functional/ex_cmds/quit_spec.lua2
-rw-r--r--test/functional/ex_cmds/recover_spec.lua1
-rw-r--r--test/functional/ex_cmds/sign_spec.lua4
-rw-r--r--test/functional/ex_cmds/wviminfo_spec.lua6
-rw-r--r--test/functional/helpers.lua23
-rw-r--r--test/functional/job/job_spec.lua12
-rw-r--r--test/functional/legacy/003_cindent_spec.lua2
-rw-r--r--test/functional/legacy/009_bufleave_autocommand_spec.lua2
-rw-r--r--test/functional/legacy/015_alignment_spec.lua2
-rw-r--r--test/functional/legacy/022_line_ending_spec.lua2
-rw-r--r--test/functional/legacy/023_edit_arguments_spec.lua2
-rw-r--r--test/functional/legacy/026_execute_while_if_spec.lua2
-rw-r--r--test/functional/legacy/027_expand_file_names_spec.lua6
-rw-r--r--test/functional/legacy/029_join_spec.lua2
-rw-r--r--test/functional/legacy/031_close_commands_spec.lua2
-rw-r--r--test/functional/legacy/038_virtual_replace_spec.lua2
-rw-r--r--test/functional/legacy/044_099_regexp_multibyte_magic_spec.lua2
-rw-r--r--test/functional/legacy/046_multi_line_regexps_spec.lua2
-rw-r--r--test/functional/legacy/051_highlight_spec.lua2
-rw-r--r--test/functional/legacy/056_script_local_function_spec.lua2
-rw-r--r--test/functional/legacy/060_exists_and_has_functions_spec.lua4
-rw-r--r--test/functional/legacy/061_undo_tree_spec.lua9
-rw-r--r--test/functional/legacy/063_match_and_matchadd_spec.lua9
-rw-r--r--test/functional/legacy/065_float_and_logic_operators_spec.lua2
-rw-r--r--test/functional/legacy/067_augroup_exists_spec.lua2
-rw-r--r--test/functional/legacy/072_undo_file_spec.lua2
-rw-r--r--test/functional/legacy/074_global_var_in_viminfo_spec.lua2
-rw-r--r--test/functional/legacy/075_maparg_spec.lua2
-rw-r--r--test/functional/legacy/077_mf_hash_grow_spec.lua2
-rw-r--r--test/functional/legacy/078_swapfile_recover_spec.lua4
-rw-r--r--test/functional/legacy/080_substitute_spec.lua2
-rw-r--r--test/functional/legacy/082_string_comparison_spec.lua2
-rw-r--r--test/functional/legacy/084_curswant_spec.lua4
-rw-r--r--test/functional/legacy/089_number_relnumber_findfile_spec.lua2
-rw-r--r--test/functional/legacy/090_sha256_spec.lua4
-rw-r--r--test/functional/legacy/091_context_variables_spec.lua4
-rw-r--r--test/functional/legacy/092_mksession_cursor_cols_utf8_spec.lua2
-rw-r--r--test/functional/legacy/093_mksession_cursor_cols_latin1_spec.lua2
-rw-r--r--test/functional/legacy/095_regexp_multibyte_spec.lua4
-rw-r--r--test/functional/legacy/096_location_list_spec.lua2
-rw-r--r--test/functional/legacy/097_glob_path_spec.lua2
-rw-r--r--test/functional/legacy/098_scrollbind_spec.lua4
-rw-r--r--test/functional/legacy/100_undo_level_spec.lua4
-rw-r--r--test/functional/legacy/101_hlsearch_spec.lua3
-rw-r--r--test/functional/legacy/102_fnameescape_spec.lua2
-rw-r--r--test/functional/legacy/103_visual_mode_reset_spec.lua4
-rw-r--r--test/functional/legacy/105_filename_modifiers_spec.lua2
-rw-r--r--test/functional/legacy/106_errorformat_spec.lua2
-rw-r--r--test/functional/legacy/107_adjust_window_and_contents_spec.lua4
-rw-r--r--test/functional/legacy/listlbr_utf8_spec.lua4
-rw-r--r--test/functional/legacy/nested_function_spec.lua2
-rw-r--r--test/functional/legacy/qf_title_spec.lua4
-rw-r--r--test/functional/legacy/signs_spec.lua1
-rw-r--r--test/functional/legacy/writefile_spec.lua1
-rw-r--r--test/functional/normal/K_spec.lua5
-rw-r--r--test/functional/plugin/helpers.lua6
-rw-r--r--test/functional/plugin/shada_spec.lua14
-rw-r--r--test/functional/provider/define_spec.lua70
-rw-r--r--test/functional/server/server_spec.lua3
-rw-r--r--test/functional/shada/buffers_spec.lua4
-rw-r--r--test/functional/shada/compatibility_spec.lua15
-rw-r--r--test/functional/shada/helpers.lua14
-rw-r--r--test/functional/shada/marks_spec.lua8
-rw-r--r--test/functional/shada/merging_spec.lua10
-rw-r--r--test/functional/shell/viml_system_spec.lua4
-rw-r--r--test/functional/terminal/altscreen_spec.lua1
-rw-r--r--test/functional/terminal/buffer_spec.lua1
-rw-r--r--test/functional/terminal/cursor_spec.lua2
-rw-r--r--test/functional/terminal/ex_terminal_spec.lua3
-rw-r--r--test/functional/terminal/helpers.lua2
-rw-r--r--test/functional/terminal/highlight_spec.lua2
-rw-r--r--test/functional/terminal/mouse_spec.lua5
-rw-r--r--test/functional/terminal/tui_spec.lua3
-rw-r--r--test/functional/terminal/window_spec.lua4
-rw-r--r--test/functional/terminal/window_split_tab_spec.lua3
-rw-r--r--test/functional/ui/highlight_spec.lua2
-rw-r--r--test/functional/ui/input_spec.lua1
-rw-r--r--test/functional/ui/screen.lua38
-rw-r--r--test/functional/ui/screen_basic_spec.lua5
-rw-r--r--test/functional/ui/searchhl_spec.lua4
-rw-r--r--test/functional/viml/completion_spec.lua2
-rw-r--r--test/unit/buffer_spec.lua7
-rw-r--r--test/unit/fileio_spec.lua1
-rw-r--r--test/unit/formatc.lua12
-rw-r--r--test/unit/garray_spec.lua19
-rw-r--r--test/unit/helpers.lua16
-rw-r--r--test/unit/os/env_spec.lua8
-rw-r--r--test/unit/os/fs_spec.lua35
-rw-r--r--test/unit/os/shell_spec.lua4
-rw-r--r--test/unit/os/users_spec.lua8
-rw-r--r--test/unit/path_spec.lua80
-rw-r--r--test/unit/preprocess.lua4
-rw-r--r--test/unit/profile_spec.lua26
-rw-r--r--test/unit/set.lua2
-rw-r--r--third-party/cmake/BuildLuarocks.cmake13
114 files changed, 370 insertions, 387 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index f11b9995c0..0633744e97 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -366,6 +366,8 @@ if(NOT BUSTED_OUTPUT_TYPE)
set(BUSTED_OUTPUT_TYPE "utfTerminal")
endif()
+find_program(LUACHECK_PRG luacheck)
+
include(InstallHelpers)
file(GLOB MANPAGES
@@ -456,3 +458,11 @@ if(BUSTED_PRG)
-P ${PROJECT_SOURCE_DIR}/cmake/RunTests.cmake
DEPENDS ${BENCHMARK_PREREQS})
endif()
+
+if(LUACHECK_PRG)
+ add_custom_target(testlint
+ COMMAND ${CMAKE_COMMAND}
+ -DLUACHECK_PRG=${LUACHECK_PRG}
+ -DTEST_DIR=${CMAKE_CURRENT_SOURCE_DIR}/test
+ -P ${PROJECT_SOURCE_DIR}/cmake/RunTestsLint.cmake)
+endif()
diff --git a/Makefile b/Makefile
index 45065769fb..343307eb2b 100644
--- a/Makefile
+++ b/Makefile
@@ -86,6 +86,9 @@ oldtest: | nvim
functionaltest: | nvim
+$(BUILD_CMD) -C build functionaltest
+testlint: | nvim
+ $(BUILD_CMD) -C build testlint
+
test: functionaltest
unittest: | nvim
@@ -110,4 +113,4 @@ lint:
-DLINT_SUPPRESS_URL="$(DOC_DOWNLOAD_URL_BASE)$(CLINT_ERRORS_FILE_PATH)" \
-P cmake/RunLint.cmake
-.PHONY: test functionaltest unittest lint clean distclean nvim libnvim cmake deps install
+.PHONY: test testlint functionaltest unittest lint clean distclean nvim libnvim cmake deps install
diff --git a/cmake/RunTestsLint.cmake b/cmake/RunTestsLint.cmake
new file mode 100644
index 0000000000..cf5465803e
--- /dev/null
+++ b/cmake/RunTestsLint.cmake
@@ -0,0 +1,11 @@
+execute_process(
+ COMMAND ${LUACHECK_PRG} -q ${TEST_DIR}
+ WORKING_DIRECTORY ${TEST_DIR}
+ ERROR_VARIABLE err
+ RESULT_VARIABLE res
+ ${EXTRA_ARGS})
+
+if(NOT res EQUAL 0)
+ message(STATUS "Output to stderr:\n${err}")
+ message(FATAL_ERROR "Linting tests failed with error: ${res}.")
+endif()
diff --git a/test/.luacheckrc b/test/.luacheckrc
new file mode 100644
index 0000000000..92e19d40e8
--- /dev/null
+++ b/test/.luacheckrc
@@ -0,0 +1,13 @@
+-- vim: ft=lua tw=80
+
+-- Don't report globals from luajit or busted (e.g. jit.os or describe).
+std = '+luajit +busted'
+
+-- One can't test these files properly; assume correctness.
+exclude_files = { '*/preload.lua' }
+
+-- Don't report unused self arguments of methods.
+self = false
+
+-- Rerun tests only if their modification time changed.
+cache = true
diff --git a/test/benchmark/bench_re_freeze_spec.lua b/test/benchmark/bench_re_freeze_spec.lua
index 7242f43c8e..d40d9f9ece 100644
--- a/test/benchmark/bench_re_freeze_spec.lua
+++ b/test/benchmark/bench_re_freeze_spec.lua
@@ -1,7 +1,7 @@
-- Test for benchmarking RE engine.
local helpers = require('test.functional.helpers')
-local feed, insert, source = helpers.feed, helpers.insert, helpers.source
+local insert, source = helpers.insert, helpers.source
local clear, execute, wait = helpers.clear, helpers.execute, helpers.wait
-- Temporary file for gathering benchmarking results for each regexp engine.
diff --git a/test/functional/api/menu_spec.lua b/test/functional/api/menu_spec.lua
index 34d23ca098..5b414fb559 100644
--- a/test/functional/api/menu_spec.lua
+++ b/test/functional/api/menu_spec.lua
@@ -19,7 +19,7 @@ describe("update_menu notification", function()
screen:detach()
end)
- function expect_sent(expected)
+ local function expect_sent(expected)
screen:wait(function()
if screen.update_menu ~= expected then
if expected then
diff --git a/test/functional/api/server_requests_spec.lua b/test/functional/api/server_requests_spec.lua
index 4c7122a549..a3ac864f79 100644
--- a/test/functional/api/server_requests_spec.lua
+++ b/test/functional/api/server_requests_spec.lua
@@ -95,13 +95,13 @@ describe('server -> client', function()
eq('notified!', eval('rpcrequest('..cid..', "notify")'))
end
- local function on_request(method, args)
+ local function on_request(method)
eq('notify', method)
eq(1, eval('rpcnotify('..cid..', "notification")'))
return 'notified!'
end
- local function on_notification(method, args)
+ local function on_notification(method)
eq('notification', method)
if notified == expected then
stop()
diff --git a/test/functional/api/vim_spec.lua b/test/functional/api/vim_spec.lua
index eb4804f141..cba0b7533b 100644
--- a/test/functional/api/vim_spec.lua
+++ b/test/functional/api/vim_spec.lua
@@ -180,6 +180,8 @@ describe('vim_* functions', function()
end)
describe('err_write', function()
+ local screen
+
before_each(function()
clear()
screen = Screen.new(40, 8)
diff --git a/test/functional/api/window_spec.lua b/test/functional/api/window_spec.lua
index 456252522d..17aacafe9b 100644
--- a/test/functional/api/window_spec.lua
+++ b/test/functional/api/window_spec.lua
@@ -1,9 +1,9 @@
-- Sanity checks for window_* API calls via msgpack-rpc
local helpers = require('test.functional.helpers')
-local clear, nvim, buffer, curbuf, curbuf_contents, window, curwin, eq, neq,
- ok, feed, rawfeed, insert, eval = helpers.clear, helpers.nvim, helpers.buffer, helpers.curbuf,
+local clear, nvim, curbuf, curbuf_contents, window, curwin, eq, neq,
+ ok, feed, insert, eval = helpers.clear, helpers.nvim, helpers.curbuf,
helpers.curbuf_contents, helpers.window, helpers.curwin, helpers.eq,
- helpers.neq, helpers.ok, helpers.feed, helpers.rawfeed, helpers.insert, helpers.eval
+ helpers.neq, helpers.ok, helpers.feed, helpers.insert, helpers.eval
local wait = helpers.wait
-- check if str is visible at the beginning of some line
@@ -54,7 +54,7 @@ describe('window_* functions', function()
insert("prologue")
feed('100o<esc>')
insert("epilogue")
- win = curwin()
+ local win = curwin()
feed('gg')
wait() -- let nvim process the 'gg' command
diff --git a/test/functional/autocmd/tabclose_spec.lua b/test/functional/autocmd/tabclose_spec.lua
index 847362e3de..bf609d1846 100644
--- a/test/functional/autocmd/tabclose_spec.lua
+++ b/test/functional/autocmd/tabclose_spec.lua
@@ -1,7 +1,5 @@
local helpers = require('test.functional.helpers')
-local clear, nvim, buffer, curbuf, curwin, eq, neq, ok =
- helpers.clear, helpers.nvim, helpers.buffer, helpers.curbuf, helpers.curwin,
- helpers.eq, helpers.neq, helpers.ok
+local clear, nvim, eq = helpers.clear, helpers.nvim, helpers.eq
describe('TabClosed', function()
describe('au TabClosed', function()
@@ -20,7 +18,6 @@ describe('TabClosed', function()
end)
describe('with NR as <afile>', function()
it('matches when closing a tab whose index is NR', function()
- tmp_path = nvim('eval', 'tempname()')
nvim('command', 'au! TabClosed 2 echom "tabclosed:match"')
repeat
nvim('command', 'tabnew')
diff --git a/test/functional/autocmd/tabnew_spec.lua b/test/functional/autocmd/tabnew_spec.lua
index d80644cd92..5ab504889b 100644
--- a/test/functional/autocmd/tabnew_spec.lua
+++ b/test/functional/autocmd/tabnew_spec.lua
@@ -1,7 +1,5 @@
local helpers = require('test.functional.helpers')
-local clear, nvim, buffer, curbuf, curwin, eq, neq, ok =
- helpers.clear, helpers.nvim, helpers.buffer, helpers.curbuf, helpers.curwin,
- helpers.eq, helpers.neq, helpers.ok
+local clear, nvim, eq = helpers.clear, helpers.nvim, helpers.eq
describe('TabNew', function()
setup(clear)
@@ -15,7 +13,7 @@ describe('TabNew', function()
end)
describe('with FILE as <afile>', function()
it('matches when opening a new tab for FILE', function()
- tmp_path = nvim('eval', 'tempname()')
+ local tmp_path = nvim('eval', 'tempname()')
nvim('command', 'au! TabNew '..tmp_path..' echom "tabnew:match"')
eq("\ntabnew:4:3\ntabnew:match\n\""..tmp_path.."\" [New File]", nvim('command_output', 'tabnew '..tmp_path))
end)
diff --git a/test/functional/autocmd/tabnewentered_spec.lua b/test/functional/autocmd/tabnewentered_spec.lua
index f220c15ef7..64b9a22f41 100644
--- a/test/functional/autocmd/tabnewentered_spec.lua
+++ b/test/functional/autocmd/tabnewentered_spec.lua
@@ -1,7 +1,5 @@
local helpers = require('test.functional.helpers')
-local clear, nvim, buffer, curbuf, curwin, eq, neq, ok =
- helpers.clear, helpers.nvim, helpers.buffer, helpers.curbuf, helpers.curwin,
- helpers.eq, helpers.neq, helpers.ok
+local clear, nvim, eq = helpers.clear, helpers.nvim, helpers.eq
describe('TabNewEntered', function()
describe('au TabNewEntered', function()
@@ -15,7 +13,7 @@ describe('TabNewEntered', function()
end)
describe('with FILE as <afile>', function()
it('matches when opening a new tab for FILE', function()
- tmp_path = nvim('eval', 'tempname()')
+ local tmp_path = nvim('eval', 'tempname()')
nvim('command', 'au! TabNewEntered '..tmp_path..' echom "tabnewentered:match"')
eq("\n\""..tmp_path.."\" [New File]\ntabnewentered:4:4\ntabnewentered:match", nvim('command_output', 'tabnew '..tmp_path))
end)
diff --git a/test/functional/autocmd/termclose_spec.lua b/test/functional/autocmd/termclose_spec.lua
index 265d857a42..0961340e61 100644
--- a/test/functional/autocmd/termclose_spec.lua
+++ b/test/functional/autocmd/termclose_spec.lua
@@ -1,11 +1,11 @@
local helpers = require('test.functional.helpers')
local Screen = require('test.functional.ui.screen')
-local clear, eval, execute, feed, nvim, nvim_dir = helpers.clear, helpers.eval,
+local clear, execute, feed, nvim, nvim_dir = helpers.clear,
helpers.execute, helpers.feed, helpers.nvim, helpers.nvim_dir
-local wait = helpers.wait
describe('TermClose event', function()
+ local screen
before_each(function()
clear()
nvim('set_option', 'shell', nvim_dir .. '/shell-test')
diff --git a/test/functional/clipboard/clipboard_provider_spec.lua b/test/functional/clipboard/clipboard_provider_spec.lua
index 98b8d2dd45..898ec556a2 100644
--- a/test/functional/clipboard/clipboard_provider_spec.lua
+++ b/test/functional/clipboard/clipboard_provider_spec.lua
@@ -4,7 +4,6 @@ local helpers = require('test.functional.helpers')
local Screen = require('test.functional.ui.screen')
local clear, feed, insert = helpers.clear, helpers.feed, helpers.insert
local execute, expect, eq, eval = helpers.execute, helpers.expect, helpers.eq, helpers.eval
-local nvim, run, stop, restart = helpers.nvim, helpers.run, helpers.stop, helpers.restart
local function basic_register_test(noblock)
insert("some words")
diff --git a/test/functional/eval/glob_spec.lua b/test/functional/eval/glob_spec.lua
index f99a9e7d0e..c6bba46424 100644
--- a/test/functional/eval/glob_spec.lua
+++ b/test/functional/eval/glob_spec.lua
@@ -1,3 +1,4 @@
+local lfs = require('lfs')
local helpers = require('test.functional.helpers')
local clear, execute, eval, eq = helpers.clear, helpers.execute, helpers.eval, helpers.eq
diff --git a/test/functional/eval/msgpack_functions_spec.lua b/test/functional/eval/msgpack_functions_spec.lua
index 9a7b630f64..da42fc9d26 100644
--- a/test/functional/eval/msgpack_functions_spec.lua
+++ b/test/functional/eval/msgpack_functions_spec.lua
@@ -1,7 +1,7 @@
local helpers = require('test.functional.helpers')
-local clear, feed, execute = helpers.clear, helpers.feed, helpers.execute
-local eval, eq, neq = helpers.eval, helpers.eq, helpers.neq
-local execute, source = helpers.execute, helpers.source
+local clear = helpers.clear
+local eval, eq = helpers.eval, helpers.eq
+local execute = helpers.execute
local nvim = helpers.nvim
local exc_exec = helpers.exc_exec
@@ -454,9 +454,9 @@ describe('msgpackparse() function', function()
it('msgpackparse(systemlist(...)) does not segfault. #3135', function()
local cmd = "sort(keys(msgpackparse(systemlist('"
..helpers.nvim_prog.." --api-info'))[0]))"
- local api_info = eval(cmd)
- api_info = eval(cmd) -- do it again (try to force segfault)
- api_info = eval(cmd) -- do it again
+ eval(cmd)
+ eval(cmd) -- do it again (try to force segfault)
+ local api_info = eval(cmd) -- do it again
eq({'error_types', 'functions', 'types'}, api_info)
end)
diff --git a/test/functional/ex_cmds/grep_spec.lua b/test/functional/ex_cmds/grep_spec.lua
index 9c792099c1..f3ff0a3817 100644
--- a/test/functional/ex_cmds/grep_spec.lua
+++ b/test/functional/ex_cmds/grep_spec.lua
@@ -1,7 +1,6 @@
local helpers = require('test.functional.helpers')
-local clear, execute, nvim, feed, eq, ok, eval =
- helpers.clear, helpers.execute, helpers.nvim, helpers.feed,
- helpers.eq, helpers.ok, helpers.eval
+local clear, execute, feed, ok, eval =
+ helpers.clear, helpers.execute, helpers.feed, helpers.ok, helpers.eval
describe(':grep', function()
before_each(clear)
diff --git a/test/functional/ex_cmds/oldfiles_spec.lua b/test/functional/ex_cmds/oldfiles_spec.lua
index e02f42cd12..dac6757a97 100644
--- a/test/functional/ex_cmds/oldfiles_spec.lua
+++ b/test/functional/ex_cmds/oldfiles_spec.lua
@@ -2,7 +2,7 @@ local Screen = require('test.functional.ui.screen')
local helpers = require('test.functional.helpers')
local buf, eq, execute = helpers.curbufmeths, helpers.eq, helpers.execute
-local feed, nvim, nvim_prog = helpers.feed, helpers.nvim, helpers.nvim_prog
+local feed, nvim_prog = helpers.feed, helpers.nvim_prog
local ok, set_session, spawn = helpers.ok, helpers.set_session, helpers.spawn
local shada_file = 'test.shada'
@@ -11,9 +11,6 @@ local shada_file = 'test.shada'
-- helpers.clear() uses "-i NONE", which is not useful for this test.
--
local function _clear()
- if session then
- session:exit(0)
- end
set_session(spawn({nvim_prog,
'-u', 'NONE',
'--cmd', 'set noswapfile undodir=. directory=. viewdir=. backupdir=.',
@@ -32,7 +29,7 @@ describe(':oldfiles', function()
end
it('shows most recently used files', function()
- screen = Screen.new(100, 5)
+ local screen = Screen.new(100, 5)
screen:attach()
execute('edit testfile1')
execute('edit testfile2')
diff --git a/test/functional/ex_cmds/profile_spec.lua b/test/functional/ex_cmds/profile_spec.lua
index 721669e73b..744b22621f 100644
--- a/test/functional/ex_cmds/profile_spec.lua
+++ b/test/functional/ex_cmds/profile_spec.lua
@@ -1,5 +1,5 @@
require('os')
-require('lfs')
+local lfs = require('lfs')
local helpers = require('test.functional.helpers')
local eval = helpers.eval
diff --git a/test/functional/ex_cmds/quit_spec.lua b/test/functional/ex_cmds/quit_spec.lua
index 3cd8e19617..a8156228d3 100644
--- a/test/functional/ex_cmds/quit_spec.lua
+++ b/test/functional/ex_cmds/quit_spec.lua
@@ -1,5 +1,5 @@
local helpers = require('test.functional.helpers')
-local execute, eq, clear = helpers.execute, helpers.eq, helpers.clear
+local clear = helpers.clear
describe(':qa', function()
before_each(function()
diff --git a/test/functional/ex_cmds/recover_spec.lua b/test/functional/ex_cmds/recover_spec.lua
index 6749cfaf40..e1d01f6896 100644
--- a/test/functional/ex_cmds/recover_spec.lua
+++ b/test/functional/ex_cmds/recover_spec.lua
@@ -1,6 +1,7 @@
-- Tests for :recover
local helpers = require('test.functional.helpers')
+local lfs = require('lfs')
local execute, eq, clear, eval, feed, expect, source =
helpers.execute, helpers.eq, helpers.clear, helpers.eval, helpers.feed,
helpers.expect, helpers.source
diff --git a/test/functional/ex_cmds/sign_spec.lua b/test/functional/ex_cmds/sign_spec.lua
index be213cd0d9..c50704504d 100644
--- a/test/functional/ex_cmds/sign_spec.lua
+++ b/test/functional/ex_cmds/sign_spec.lua
@@ -1,7 +1,5 @@
local helpers = require('test.functional.helpers')
-local clear, nvim, buffer, curbuf, curwin, eq, ok =
- helpers.clear, helpers.nvim, helpers.buffer, helpers.curbuf, helpers.curwin,
- helpers.eq, helpers.ok
+local clear, nvim, eq = helpers.clear, helpers.nvim, helpers.eq
describe('sign', function()
before_each(clear)
diff --git a/test/functional/ex_cmds/wviminfo_spec.lua b/test/functional/ex_cmds/wviminfo_spec.lua
index b6b9185cf2..207d94124f 100644
--- a/test/functional/ex_cmds/wviminfo_spec.lua
+++ b/test/functional/ex_cmds/wviminfo_spec.lua
@@ -1,6 +1,6 @@
local helpers, lfs = require('test.functional.helpers'), require('lfs')
-local clear, execute, eq, neq, spawn, nvim_prog, set_session, wait, write_file
- = helpers.clear, helpers.execute, helpers.eq, helpers.neq, helpers.spawn,
+local execute, eq, neq, spawn, nvim_prog, set_session, wait, write_file
+ = helpers.execute, helpers.eq, helpers.neq, helpers.spawn,
helpers.nvim_prog, helpers.set_session, helpers.wait, helpers.write_file
describe(':wshada', function()
@@ -13,7 +13,7 @@ describe(':wshada', function()
end
-- Override the default session because we need 'swapfile' for these tests.
- local session = spawn({nvim_prog, '-u', 'NONE', '-i', '/dev/null', '--embed',
+ session = spawn({nvim_prog, '-u', 'NONE', '-i', '/dev/null', '--embed',
'--cmd', 'set swapfile'})
set_session(session)
diff --git a/test/functional/helpers.lua b/test/functional/helpers.lua
index 8a85f187cf..9562457c8e 100644
--- a/test/functional/helpers.lua
+++ b/test/functional/helpers.lua
@@ -1,4 +1,5 @@
require('coxpcall')
+local lfs = require('lfs')
local assert = require('luassert')
local Loop = require('nvim.loop')
local MsgpackStream = require('nvim.msgpack_stream')
@@ -55,7 +56,7 @@ if prepend_argv then
nvim_argv = new_nvim_argv
end
-local session, loop_running, loop_stopped, last_error
+local session, loop_running, last_error
local function set_session(s)
session = s
@@ -79,7 +80,7 @@ local function next_message()
end
local function call_and_stop_on_error(...)
- local status, result = copcall(...)
+ local status, result = copcall(...) -- luacheck: ignore
if not status then
session:stop()
last_error = result
@@ -109,7 +110,6 @@ local function run(request_cb, notification_cb, setup_cb, timeout)
end
end
- loop_stopped = false
loop_running = true
session:run(on_request, on_notification, on_setup, timeout)
loop_running = false
@@ -121,7 +121,6 @@ local function run(request_cb, notification_cb, setup_cb, timeout)
end
local function stop()
- loop_stopped = true
session:stop()
end
@@ -197,9 +196,9 @@ local function spawn(argv, merge)
local loop = Loop.new()
local msgpack_stream = MsgpackStream.new(loop)
local async_session = AsyncSession.new(msgpack_stream)
- local session = Session.new(async_session)
+ local sess = Session.new(async_session)
loop:spawn(merge and merge_args(prepend_argv, argv) or argv)
- return session
+ return sess
end
local function clear(extra_cmd)
@@ -332,14 +331,14 @@ local function rmdir(path)
if file == '.' or file == '..' then
goto continue
end
- ret, err = os.remove(path..'/'..file)
+ local ret, err = os.remove(path..'/'..file)
if not ret then
error('os.remove: '..err)
return nil
end
::continue::
end
- ret, err = os.remove(path)
+ local ret, err = os.remove(path)
if not ret then
error('os.remove: '..err)
end
@@ -371,15 +370,15 @@ local function redir_exec(cmd)
end
local function create_callindex(func)
- local tbl = {}
- setmetatable(tbl, {
+ local table = {}
+ setmetatable(table, {
__index = function(tbl, arg1)
- ret = function(...) return func(arg1, ...) end
+ local ret = function(...) return func(arg1, ...) end
tbl[arg1] = ret
return ret
end,
})
- return tbl
+ return table
end
local funcs = create_callindex(nvim_call)
diff --git a/test/functional/job/job_spec.lua b/test/functional/job/job_spec.lua
index bdaf2a7ec6..0915ab0955 100644
--- a/test/functional/job/job_spec.lua
+++ b/test/functional/job/job_spec.lua
@@ -1,11 +1,11 @@
local helpers = require('test.functional.helpers')
-local clear, eq, eval, execute, expect, feed, insert, neq, next_msg, nvim,
- nvim_dir, ok, run, session, source, stop, wait, write_file = helpers.clear,
- helpers.eq, helpers.eval, helpers.execute, helpers.expect, helpers.feed,
+local clear, eq, eval, execute, feed, insert, neq, next_msg, nvim,
+ nvim_dir, ok, source, write_file = helpers.clear,
+ helpers.eq, helpers.eval, helpers.execute, helpers.feed,
helpers.insert, helpers.neq, helpers.next_message, helpers.nvim,
- helpers.nvim_dir, helpers.ok, helpers.run, helpers.session, helpers.source,
- helpers.stop, helpers.wait, helpers.write_file
+ helpers.nvim_dir, helpers.ok, helpers.source,
+ helpers.write_file
local Screen = require('test.functional.ui.screen')
@@ -370,7 +370,7 @@ describe('jobs', function()
describe('running tty-test program', function()
local function next_chunk()
- local rv = ''
+ local rv
while true do
local msg = next_msg()
local data = msg[3][2]
diff --git a/test/functional/legacy/003_cindent_spec.lua b/test/functional/legacy/003_cindent_spec.lua
index 1857721563..39de3e8280 100644
--- a/test/functional/legacy/003_cindent_spec.lua
+++ b/test/functional/legacy/003_cindent_spec.lua
@@ -4,7 +4,7 @@
-- in the original test. These have been converted to "it" test cases here.
local helpers = require('test.functional.helpers')
-local feed, insert, source = helpers.feed, helpers.insert, helpers.source
+local feed, insert = helpers.feed, helpers.insert
local clear, execute, expect = helpers.clear, helpers.execute, helpers.expect
-- Inserts text as usual, and additionally positions the cursor on line 1 and
diff --git a/test/functional/legacy/009_bufleave_autocommand_spec.lua b/test/functional/legacy/009_bufleave_autocommand_spec.lua
index 0fc1b5b657..8c18639c8f 100644
--- a/test/functional/legacy/009_bufleave_autocommand_spec.lua
+++ b/test/functional/legacy/009_bufleave_autocommand_spec.lua
@@ -1,7 +1,7 @@
-- Test for Bufleave autocommand that deletes the buffer we are about to edit.
local helpers = require('test.functional.helpers')
-local clear, feed, insert = helpers.clear, helpers.feed, helpers.insert
+local clear, insert = helpers.clear, helpers.insert
local execute, expect = helpers.execute, helpers.expect
describe('BufLeave autocommand', function()
diff --git a/test/functional/legacy/015_alignment_spec.lua b/test/functional/legacy/015_alignment_spec.lua
index e71f9d1c90..3b19f4ff42 100644
--- a/test/functional/legacy/015_alignment_spec.lua
+++ b/test/functional/legacy/015_alignment_spec.lua
@@ -3,7 +3,7 @@
-- Also test undo after ":%s" and formatting.
local helpers = require('test.functional.helpers')
-local feed, insert, source = helpers.feed, helpers.insert, helpers.source
+local feed, insert = helpers.feed, helpers.insert
local clear, execute, expect = helpers.clear, helpers.execute, helpers.expect
describe('alignment', function()
diff --git a/test/functional/legacy/022_line_ending_spec.lua b/test/functional/legacy/022_line_ending_spec.lua
index 4b897a7c95..a841378a82 100644
--- a/test/functional/legacy/022_line_ending_spec.lua
+++ b/test/functional/legacy/022_line_ending_spec.lua
@@ -1,7 +1,7 @@
-- Tests for file with some lines ending in CTRL-M, some not
local helpers = require('test.functional.helpers')
-local clear, feed, insert = helpers.clear, helpers.feed, helpers.insert
+local clear, feed = helpers.clear, helpers.feed
local execute, expect = helpers.execute, helpers.expect
describe('line ending', function()
diff --git a/test/functional/legacy/023_edit_arguments_spec.lua b/test/functional/legacy/023_edit_arguments_spec.lua
index e68af9758d..15b30bfa3a 100644
--- a/test/functional/legacy/023_edit_arguments_spec.lua
+++ b/test/functional/legacy/023_edit_arguments_spec.lua
@@ -1,7 +1,7 @@
-- Tests for complicated + argument to :edit command
local helpers = require('test.functional.helpers')
-local clear, feed, insert = helpers.clear, helpers.feed, helpers.insert
+local clear, insert = helpers.clear, helpers.insert
local execute, expect = helpers.execute, helpers.expect
describe(':edit', function()
diff --git a/test/functional/legacy/026_execute_while_if_spec.lua b/test/functional/legacy/026_execute_while_if_spec.lua
index ffe37819de..f17bb79702 100644
--- a/test/functional/legacy/026_execute_while_if_spec.lua
+++ b/test/functional/legacy/026_execute_while_if_spec.lua
@@ -1,7 +1,7 @@
-- Test for :execute, :while and :if
local helpers = require('test.functional.helpers')
-local clear, feed, insert = helpers.clear, helpers.feed, helpers.insert
+local clear = helpers.clear
local execute, expect = helpers.execute, helpers.expect
local source = helpers.source
diff --git a/test/functional/legacy/027_expand_file_names_spec.lua b/test/functional/legacy/027_expand_file_names_spec.lua
index d31f29d38a..4778d16d43 100644
--- a/test/functional/legacy/027_expand_file_names_spec.lua
+++ b/test/functional/legacy/027_expand_file_names_spec.lua
@@ -1,10 +1,10 @@
-- Test for expanding file names
local helpers = require('test.functional.helpers')
-local clear, feed, insert = helpers.clear, helpers.feed, helpers.insert
-local execute, expect = helpers.execute, helpers.expect
+local clear, feed = helpers.clear, helpers.feed
+local execute = helpers.execute
local curbuf_contents = helpers.curbuf_contents
-local eq, eval = helpers.eq, helpers.eval
+local eq = helpers.eq
describe('expand file name', function()
setup(clear)
diff --git a/test/functional/legacy/029_join_spec.lua b/test/functional/legacy/029_join_spec.lua
index eafa50d88c..25a072ad6e 100644
--- a/test/functional/legacy/029_join_spec.lua
+++ b/test/functional/legacy/029_join_spec.lua
@@ -1,7 +1,7 @@
-- Test for joining lines with marks in them (and with 'joinspaces' set/reset)
local helpers = require('test.functional.helpers')
-local feed, insert, source = helpers.feed, helpers.insert, helpers.source
+local feed, insert = helpers.feed, helpers.insert
local clear, execute, expect = helpers.clear, helpers.execute, helpers.expect
describe('joining lines', function()
diff --git a/test/functional/legacy/031_close_commands_spec.lua b/test/functional/legacy/031_close_commands_spec.lua
index 78e71b5fb1..3597cba12a 100644
--- a/test/functional/legacy/031_close_commands_spec.lua
+++ b/test/functional/legacy/031_close_commands_spec.lua
@@ -10,7 +10,7 @@
-- :edit
local helpers = require('test.functional.helpers')
-local feed, insert, source = helpers.feed, helpers.insert, helpers.source
+local feed, insert = helpers.feed, helpers.insert
local clear, execute, expect = helpers.clear, helpers.execute, helpers.expect
describe('Commands that close windows and/or buffers', function()
diff --git a/test/functional/legacy/038_virtual_replace_spec.lua b/test/functional/legacy/038_virtual_replace_spec.lua
index 94503bd42a..10d42f0cea 100644
--- a/test/functional/legacy/038_virtual_replace_spec.lua
+++ b/test/functional/legacy/038_virtual_replace_spec.lua
@@ -1,7 +1,7 @@
-- Test Virtual replace mode.
local helpers = require('test.functional.helpers')
-local feed, insert, source = helpers.feed, helpers.insert, helpers.source
+local feed = helpers.feed
local clear, execute, expect = helpers.clear, helpers.execute, helpers.expect
describe('Virtual replace mode', function()
diff --git a/test/functional/legacy/044_099_regexp_multibyte_magic_spec.lua b/test/functional/legacy/044_099_regexp_multibyte_magic_spec.lua
index efe61aa354..1359b45228 100644
--- a/test/functional/legacy/044_099_regexp_multibyte_magic_spec.lua
+++ b/test/functional/legacy/044_099_regexp_multibyte_magic_spec.lua
@@ -4,7 +4,7 @@
-- This test contains both "test44" and "test99" from the old test suite.
local helpers = require('test.functional.helpers')
-local feed, insert, source = helpers.feed, helpers.insert, helpers.source
+local feed, insert = helpers.feed, helpers.insert
local clear, execute, expect = helpers.clear, helpers.execute, helpers.expect
-- Runs the test protocol with the given 'regexpengine' setting. In the old test
diff --git a/test/functional/legacy/046_multi_line_regexps_spec.lua b/test/functional/legacy/046_multi_line_regexps_spec.lua
index f8a6143b18..b17ab42fe3 100644
--- a/test/functional/legacy/046_multi_line_regexps_spec.lua
+++ b/test/functional/legacy/046_multi_line_regexps_spec.lua
@@ -3,7 +3,7 @@
local helpers = require('test.functional.helpers')
local clear, feed, insert = helpers.clear, helpers.feed, helpers.insert
-local execute, expect = helpers.execute, helpers.expect
+local expect = helpers.expect
describe('multi-line regexp', function()
setup(clear)
diff --git a/test/functional/legacy/051_highlight_spec.lua b/test/functional/legacy/051_highlight_spec.lua
index 620df97aac..94c42b73e5 100644
--- a/test/functional/legacy/051_highlight_spec.lua
+++ b/test/functional/legacy/051_highlight_spec.lua
@@ -3,7 +3,7 @@
local Screen = require('test.functional.ui.screen')
local helpers = require('test.functional.helpers')
-local clear, feed, insert = helpers.clear, helpers.feed, helpers.insert
+local clear, feed = helpers.clear, helpers.feed
local execute, expect = helpers.execute, helpers.expect
local wait = helpers.wait
diff --git a/test/functional/legacy/056_script_local_function_spec.lua b/test/functional/legacy/056_script_local_function_spec.lua
index 147391ceb1..dec88e8001 100644
--- a/test/functional/legacy/056_script_local_function_spec.lua
+++ b/test/functional/legacy/056_script_local_function_spec.lua
@@ -3,7 +3,7 @@
local helpers = require('test.functional.helpers')
local clear, feed, insert = helpers.clear, helpers.feed, helpers.insert
-local execute, expect = helpers.execute, helpers.expect
+local expect = helpers.expect
describe('source function', function()
setup(clear)
diff --git a/test/functional/legacy/060_exists_and_has_functions_spec.lua b/test/functional/legacy/060_exists_and_has_functions_spec.lua
index e9b79b490d..7f44b35a4e 100644
--- a/test/functional/legacy/060_exists_and_has_functions_spec.lua
+++ b/test/functional/legacy/060_exists_and_has_functions_spec.lua
@@ -1,8 +1,8 @@
-- Tests for the exists() and has() functions.
local helpers = require('test.functional.helpers')
-local feed, insert, source = helpers.feed, helpers.insert, helpers.source
-local clear, execute, expect = helpers.clear, helpers.execute, helpers.expect
+local source = helpers.source
+local clear, expect = helpers.clear, helpers.expect
local write_file = helpers.write_file
describe('exists() and has() functions', function()
diff --git a/test/functional/legacy/061_undo_tree_spec.lua b/test/functional/legacy/061_undo_tree_spec.lua
index 8cc2a371bb..ceb114b2a7 100644
--- a/test/functional/legacy/061_undo_tree_spec.lua
+++ b/test/functional/legacy/061_undo_tree_spec.lua
@@ -1,8 +1,8 @@
-- Tests for undo tree and :earlier and :later.
local helpers = require('test.functional.helpers')
-local feed, insert, source, eq, eval, clear, execute, expect, wait, write_file
- = helpers.feed, helpers.insert, helpers.source, helpers.eq, helpers.eval,
+local feed, source, eq, eval, clear, execute, expect, wait, write_file =
+ helpers.feed, helpers.source, helpers.eq, helpers.eval,
helpers.clear, helpers.execute, helpers.expect, helpers.wait,
helpers.write_file
@@ -97,9 +97,8 @@ describe('undo tree:', function()
-- Retry up to 3 times. pcall() is _not_ used for the final attempt, so
-- that failure messages can bubble up.
- local success, result = false, ''
- for i = 1, 2 do
- success, result = pcall(test_earlier_later)
+ for _ = 1, 2 do
+ local success = pcall(test_earlier_later)
if success then
return
end
diff --git a/test/functional/legacy/063_match_and_matchadd_spec.lua b/test/functional/legacy/063_match_and_matchadd_spec.lua
index d819db7812..a354d4d328 100644
--- a/test/functional/legacy/063_match_and_matchadd_spec.lua
+++ b/test/functional/legacy/063_match_and_matchadd_spec.lua
@@ -2,10 +2,9 @@
local helpers = require('test.functional.helpers')
local Screen = require('test.functional.ui.screen')
-local feed, insert, source = helpers.feed, helpers.insert, helpers.source
-local eval, clear, execute, expect = helpers.eval, helpers.clear, helpers.execute
-local expect, eq, neq = helpers.expect, helpers.eq, helpers.neq
-local command = helpers.command
+local feed, insert = helpers.feed, helpers.insert
+local eval, clear, execute = helpers.eval, helpers.clear, helpers.execute
+local eq, neq = helpers.eq, helpers.neq
describe('063: Test for ":match", "matchadd()" and related functions', function()
setup(clear)
@@ -86,7 +85,7 @@ describe('063: Test for ":match", "matchadd()" and related functions', function(
execute("2match MyGroup2 /HUMPPA/")
execute("3match MyGroup3 /VIM/")
execute("let ml = getmatches()")
- ml = eval("ml")
+ local ml = eval("ml")
execute("call clearmatches()")
execute("call setmatches(ml)")
eq(ml, eval('getmatches()'))
diff --git a/test/functional/legacy/065_float_and_logic_operators_spec.lua b/test/functional/legacy/065_float_and_logic_operators_spec.lua
index 5cdb0b7f58..e78b230956 100644
--- a/test/functional/legacy/065_float_and_logic_operators_spec.lua
+++ b/test/functional/legacy/065_float_and_logic_operators_spec.lua
@@ -1,7 +1,7 @@
-- Test for floating point and logical operators.
local helpers = require('test.functional.helpers')
-local feed, insert, source = helpers.feed, helpers.insert, helpers.source
+local insert, source = helpers.insert, helpers.source
local clear, execute, expect = helpers.clear, helpers.execute, helpers.expect
describe('floating point and logical operators', function()
diff --git a/test/functional/legacy/067_augroup_exists_spec.lua b/test/functional/legacy/067_augroup_exists_spec.lua
index 6d89ad6d55..dc4c9c7eeb 100644
--- a/test/functional/legacy/067_augroup_exists_spec.lua
+++ b/test/functional/legacy/067_augroup_exists_spec.lua
@@ -2,7 +2,7 @@
-- autocommands.
local helpers = require('test.functional.helpers')
-local clear, feed, insert = helpers.clear, helpers.feed, helpers.insert
+local clear = helpers.clear
local execute, expect = helpers.execute, helpers.expect
describe('augroup when calling exists()', function()
diff --git a/test/functional/legacy/072_undo_file_spec.lua b/test/functional/legacy/072_undo_file_spec.lua
index ce9129ff43..efcc2f2cc3 100644
--- a/test/functional/legacy/072_undo_file_spec.lua
+++ b/test/functional/legacy/072_undo_file_spec.lua
@@ -3,7 +3,7 @@
-- undo-able pieces. Do that by setting 'undolevels'.
local helpers = require('test.functional.helpers')
-local feed, insert, source = helpers.feed, helpers.insert, helpers.source
+local feed, insert = helpers.feed, helpers.insert
local clear, execute, expect = helpers.clear, helpers.execute, helpers.expect
describe('72', function()
diff --git a/test/functional/legacy/074_global_var_in_viminfo_spec.lua b/test/functional/legacy/074_global_var_in_viminfo_spec.lua
index 2428b7f74d..49c4827613 100644
--- a/test/functional/legacy/074_global_var_in_viminfo_spec.lua
+++ b/test/functional/legacy/074_global_var_in_viminfo_spec.lua
@@ -13,7 +13,7 @@ describe('storing global variables in ShaDa files', function()
end)
it('is working', function()
- local nvim2 = helpers.spawn({helpers.nvim_prog, '-u', 'NONE',
+ local nvim2 = spawn({helpers.nvim_prog, '-u', 'NONE',
'-i', 'Xviminfo', '--embed'})
helpers.set_session(nvim2)
diff --git a/test/functional/legacy/075_maparg_spec.lua b/test/functional/legacy/075_maparg_spec.lua
index 418abb14d4..82965f5cb2 100644
--- a/test/functional/legacy/075_maparg_spec.lua
+++ b/test/functional/legacy/075_maparg_spec.lua
@@ -2,7 +2,7 @@
-- Also test utf8 map with a 0x80 byte.
local helpers = require('test.functional.helpers')
-local clear, feed, insert = helpers.clear, helpers.feed, helpers.insert
+local clear, feed = helpers.clear, helpers.feed
local execute, expect = helpers.execute, helpers.expect
describe('maparg()', function()
diff --git a/test/functional/legacy/077_mf_hash_grow_spec.lua b/test/functional/legacy/077_mf_hash_grow_spec.lua
index 825f08e968..029fe98fe9 100644
--- a/test/functional/legacy/077_mf_hash_grow_spec.lua
+++ b/test/functional/legacy/077_mf_hash_grow_spec.lua
@@ -7,7 +7,7 @@
-- If it isn't available then the test will be skipped.
local helpers = require('test.functional.helpers')
-local feed, insert, source = helpers.feed, helpers.insert, helpers.source
+local feed = helpers.feed
local clear, execute, expect = helpers.clear, helpers.execute, helpers.expect
describe('mf_hash_grow()', function()
diff --git a/test/functional/legacy/078_swapfile_recover_spec.lua b/test/functional/legacy/078_swapfile_recover_spec.lua
index 33115c1317..e48fddaac1 100644
--- a/test/functional/legacy/078_swapfile_recover_spec.lua
+++ b/test/functional/legacy/078_swapfile_recover_spec.lua
@@ -4,9 +4,7 @@
-- pointer blocks.
local helpers = require('test.functional.helpers')
-local feed, insert, source = helpers.feed, helpers.insert, helpers.source
-local clear, execute, expect, source = helpers.clear, helpers.execute, helpers.expect, helpers.source
-local eval = helpers.eval
+local clear, expect, source = helpers.clear, helpers.expect, helpers.source
describe('78', function()
setup(clear)
diff --git a/test/functional/legacy/080_substitute_spec.lua b/test/functional/legacy/080_substitute_spec.lua
index 89ef7a713c..96082364e0 100644
--- a/test/functional/legacy/080_substitute_spec.lua
+++ b/test/functional/legacy/080_substitute_spec.lua
@@ -3,7 +3,7 @@
-- Test for *:s%* on :substitute.
local helpers = require('test.functional.helpers')
-local feed, insert, source = helpers.feed, helpers.insert, helpers.source
+local feed, insert = helpers.feed, helpers.insert
local clear, execute, expect = helpers.clear, helpers.execute, helpers.expect
local eq, eval = helpers.eq, helpers.eval
diff --git a/test/functional/legacy/082_string_comparison_spec.lua b/test/functional/legacy/082_string_comparison_spec.lua
index 1615828ca0..933c6c8fa3 100644
--- a/test/functional/legacy/082_string_comparison_spec.lua
+++ b/test/functional/legacy/082_string_comparison_spec.lua
@@ -2,7 +2,7 @@
-- Also test "g~ap".
local helpers = require('test.functional.helpers')
-local feed, insert, source = helpers.feed, helpers.insert, helpers.source
+local feed, source = helpers.feed, helpers.source
local clear, execute, expect = helpers.clear, helpers.execute, helpers.expect
describe('case-insensitive string comparison in UTF-8', function()
diff --git a/test/functional/legacy/084_curswant_spec.lua b/test/functional/legacy/084_curswant_spec.lua
index 55df5d3e73..946dd5e501 100644
--- a/test/functional/legacy/084_curswant_spec.lua
+++ b/test/functional/legacy/084_curswant_spec.lua
@@ -1,8 +1,8 @@
-- Tests for curswant not changing when setting an option.
local helpers = require('test.functional.helpers')
-local feed, insert, source = helpers.feed, helpers.insert, helpers.source
-local clear, execute, expect = helpers.clear, helpers.execute, helpers.expect
+local insert, source = helpers.insert, helpers.source
+local clear, expect = helpers.clear, helpers.expect
describe('curswant', function()
setup(clear)
diff --git a/test/functional/legacy/089_number_relnumber_findfile_spec.lua b/test/functional/legacy/089_number_relnumber_findfile_spec.lua
index 1f8e49cc81..f72ebf3f72 100644
--- a/test/functional/legacy/089_number_relnumber_findfile_spec.lua
+++ b/test/functional/legacy/089_number_relnumber_findfile_spec.lua
@@ -4,7 +4,7 @@
local helpers = require('test.functional.helpers')
local feed = helpers.feed
-local clear, execute, expect, source = helpers.clear, helpers.execute, helpers.expect, helpers.source
+local clear, expect, source = helpers.clear, helpers.expect, helpers.source
describe("setting 'number' and 'relativenumber'", function()
setup(clear)
diff --git a/test/functional/legacy/090_sha256_spec.lua b/test/functional/legacy/090_sha256_spec.lua
index 35fbd5752e..95e50063a1 100644
--- a/test/functional/legacy/090_sha256_spec.lua
+++ b/test/functional/legacy/090_sha256_spec.lua
@@ -1,8 +1,8 @@
-- Tests for sha256() function.
local helpers = require('test.functional.helpers')
-local feed, insert, source = helpers.feed, helpers.insert, helpers.source
-local clear, execute, expect = helpers.clear, helpers.execute, helpers.expect
+local insert, source = helpers.insert, helpers.source
+local clear, expect = helpers.clear, helpers.expect
describe('sha256()', function()
setup(clear)
diff --git a/test/functional/legacy/091_context_variables_spec.lua b/test/functional/legacy/091_context_variables_spec.lua
index bb9c32b84f..ffeb0c657e 100644
--- a/test/functional/legacy/091_context_variables_spec.lua
+++ b/test/functional/legacy/091_context_variables_spec.lua
@@ -1,8 +1,8 @@
-- Tests for getbufvar(), getwinvar(), gettabvar() and gettabwinvar().
local helpers = require('test.functional.helpers')
-local feed, insert, source = helpers.feed, helpers.insert, helpers.source
-local clear, execute, expect = helpers.clear, helpers.execute, helpers.expect
+local insert, source = helpers.insert, helpers.source
+local clear, expect = helpers.clear, helpers.expect
describe('context variables', function()
setup(clear)
diff --git a/test/functional/legacy/092_mksession_cursor_cols_utf8_spec.lua b/test/functional/legacy/092_mksession_cursor_cols_utf8_spec.lua
index e0cc39dc40..f76ba25d7a 100644
--- a/test/functional/legacy/092_mksession_cursor_cols_utf8_spec.lua
+++ b/test/functional/legacy/092_mksession_cursor_cols_utf8_spec.lua
@@ -4,7 +4,7 @@
-- Same as legacy test 93 but using UTF-8 file encoding.
local helpers = require('test.functional.helpers')
-local feed, insert, source = helpers.feed, helpers.insert, helpers.source
+local feed, insert = helpers.feed, helpers.insert
local clear, execute, expect = helpers.clear, helpers.execute, helpers.expect
describe('store cursor position in session file in UTF-8', function()
diff --git a/test/functional/legacy/093_mksession_cursor_cols_latin1_spec.lua b/test/functional/legacy/093_mksession_cursor_cols_latin1_spec.lua
index 659e716721..bf3af1a827 100644
--- a/test/functional/legacy/093_mksession_cursor_cols_latin1_spec.lua
+++ b/test/functional/legacy/093_mksession_cursor_cols_latin1_spec.lua
@@ -4,7 +4,7 @@
-- Same as legacy test 92 but using Latin-1 file encoding.
local helpers = require('test.functional.helpers')
-local feed, insert, source = helpers.feed, helpers.insert, helpers.source
+local feed, insert = helpers.feed, helpers.insert
local clear, execute, expect = helpers.clear, helpers.execute, helpers.expect
describe('store cursor position in session file in Latin-1', function()
diff --git a/test/functional/legacy/095_regexp_multibyte_spec.lua b/test/functional/legacy/095_regexp_multibyte_spec.lua
index 559222e2ff..a80a247612 100644
--- a/test/functional/legacy/095_regexp_multibyte_spec.lua
+++ b/test/functional/legacy/095_regexp_multibyte_spec.lua
@@ -4,8 +4,8 @@
-- actually tried.
local helpers = require('test.functional.helpers')
-local feed, insert, source = helpers.feed, helpers.insert, helpers.source
-local clear, execute, expect = helpers.clear, helpers.execute, helpers.expect
+local insert, source = helpers.insert, helpers.source
+local clear, expect = helpers.clear, helpers.expect
describe('regex with multi-byte', function()
setup(clear)
diff --git a/test/functional/legacy/096_location_list_spec.lua b/test/functional/legacy/096_location_list_spec.lua
index 2ccfd3530d..6e2f22ea33 100644
--- a/test/functional/legacy/096_location_list_spec.lua
+++ b/test/functional/legacy/096_location_list_spec.lua
@@ -7,7 +7,7 @@
-- it belongs to.
local helpers = require('test.functional.helpers')
-local feed, insert, source = helpers.feed, helpers.insert, helpers.source
+local source = helpers.source
local clear, execute, expect = helpers.clear, helpers.execute, helpers.expect
describe('location list', function()
diff --git a/test/functional/legacy/097_glob_path_spec.lua b/test/functional/legacy/097_glob_path_spec.lua
index 84f26478ac..5c467fbb20 100644
--- a/test/functional/legacy/097_glob_path_spec.lua
+++ b/test/functional/legacy/097_glob_path_spec.lua
@@ -3,7 +3,7 @@
-- characters.
local helpers = require('test.functional.helpers')
-local clear, feed, insert = helpers.clear, helpers.feed, helpers.insert
+local clear = helpers.clear
local execute, expect = helpers.execute, helpers.expect
describe('glob() and globpath()', function()
diff --git a/test/functional/legacy/098_scrollbind_spec.lua b/test/functional/legacy/098_scrollbind_spec.lua
index 7b2059e38b..6850e373ab 100644
--- a/test/functional/legacy/098_scrollbind_spec.lua
+++ b/test/functional/legacy/098_scrollbind_spec.lua
@@ -1,8 +1,8 @@
-- Test for 'scrollbind' causing an unexpected scroll of one of the windows.
local helpers = require('test.functional.helpers')
-local feed, insert, source = helpers.feed, helpers.insert, helpers.source
-local clear, execute, expect = helpers.clear, helpers.execute, helpers.expect
+local source = helpers.source
+local clear, expect = helpers.clear, helpers.expect
describe('scrollbind', function()
setup(clear)
diff --git a/test/functional/legacy/100_undo_level_spec.lua b/test/functional/legacy/100_undo_level_spec.lua
index 9143d9e540..3bf72341d6 100644
--- a/test/functional/legacy/100_undo_level_spec.lua
+++ b/test/functional/legacy/100_undo_level_spec.lua
@@ -1,8 +1,8 @@
-- Tests for 'undolevel' setting being global-local
local helpers = require('test.functional.helpers')
-local feed, insert, source = helpers.feed, helpers.insert, helpers.source
-local clear, execute, expect = helpers.clear, helpers.execute, helpers.expect
+local source = helpers.source
+local clear, expect = helpers.clear, helpers.expect
describe('undolevel', function()
setup(clear)
diff --git a/test/functional/legacy/101_hlsearch_spec.lua b/test/functional/legacy/101_hlsearch_spec.lua
index 4b8b1cef50..335d275c2a 100644
--- a/test/functional/legacy/101_hlsearch_spec.lua
+++ b/test/functional/legacy/101_hlsearch_spec.lua
@@ -1,9 +1,8 @@
-- Test for v:hlsearch
local helpers = require('test.functional.helpers')
-local clear, feed, insert = helpers.clear, helpers.feed, helpers.insert
+local clear, feed = helpers.clear, helpers.feed
local execute, expect = helpers.execute, helpers.expect
-local eval = helpers.eval
describe('v:hlsearch', function()
setup(clear)
diff --git a/test/functional/legacy/102_fnameescape_spec.lua b/test/functional/legacy/102_fnameescape_spec.lua
index 251ce68430..a3b0313d7a 100644
--- a/test/functional/legacy/102_fnameescape_spec.lua
+++ b/test/functional/legacy/102_fnameescape_spec.lua
@@ -1,7 +1,7 @@
-- Test if fnameescape is correct for special chars like!
local helpers = require('test.functional.helpers')
-local clear, feed, insert = helpers.clear, helpers.feed, helpers.insert
+local clear = helpers.clear
local execute, expect = helpers.execute, helpers.expect
describe('fnameescape', function()
diff --git a/test/functional/legacy/103_visual_mode_reset_spec.lua b/test/functional/legacy/103_visual_mode_reset_spec.lua
index 6b2f3bc1b6..c1407ef10a 100644
--- a/test/functional/legacy/103_visual_mode_reset_spec.lua
+++ b/test/functional/legacy/103_visual_mode_reset_spec.lua
@@ -1,8 +1,8 @@
-- Test for visual mode not being reset causing E315 error.
local helpers = require('test.functional.helpers')
-local feed, insert, source = helpers.feed, helpers.insert, helpers.source
-local clear, execute, expect = helpers.clear, helpers.execute, helpers.expect
+local feed, source = helpers.feed, helpers.source
+local clear, expect = helpers.clear, helpers.expect
describe('E315 error', function()
setup(clear)
diff --git a/test/functional/legacy/105_filename_modifiers_spec.lua b/test/functional/legacy/105_filename_modifiers_spec.lua
index 3b417a88eb..3413667022 100644
--- a/test/functional/legacy/105_filename_modifiers_spec.lua
+++ b/test/functional/legacy/105_filename_modifiers_spec.lua
@@ -1,7 +1,7 @@
-- Test filename modifiers.
local helpers = require('test.functional.helpers')
-local clear, feed, insert = helpers.clear, helpers.feed, helpers.insert
+local clear = helpers.clear
local execute, expect = helpers.execute, helpers.expect
describe('filename modifiers', function()
diff --git a/test/functional/legacy/106_errorformat_spec.lua b/test/functional/legacy/106_errorformat_spec.lua
index 5b6037f928..5958f1aa7b 100644
--- a/test/functional/legacy/106_errorformat_spec.lua
+++ b/test/functional/legacy/106_errorformat_spec.lua
@@ -1,7 +1,7 @@
-- Tests for errorformat.
local helpers = require('test.functional.helpers')
-local clear, feed, insert = helpers.clear, helpers.feed, helpers.insert
+local clear = helpers.clear
local execute, expect = helpers.execute, helpers.expect
describe('errorformat', function()
diff --git a/test/functional/legacy/107_adjust_window_and_contents_spec.lua b/test/functional/legacy/107_adjust_window_and_contents_spec.lua
index f6ea7e5a6c..7a6de3d748 100644
--- a/test/functional/legacy/107_adjust_window_and_contents_spec.lua
+++ b/test/functional/legacy/107_adjust_window_and_contents_spec.lua
@@ -2,8 +2,8 @@
local helpers = require('test.functional.helpers')
local Screen = require('test.functional.ui.screen')
-local feed, insert, source = helpers.feed, helpers.insert, helpers.source
-local clear, execute, expect = helpers.clear, helpers.execute, helpers.expect
+local insert = helpers.insert
+local clear, execute = helpers.clear, helpers.execute
describe('107', function()
setup(clear)
diff --git a/test/functional/legacy/listlbr_utf8_spec.lua b/test/functional/legacy/listlbr_utf8_spec.lua
index 15d12ac4af..69e7b87a21 100644
--- a/test/functional/legacy/listlbr_utf8_spec.lua
+++ b/test/functional/legacy/listlbr_utf8_spec.lua
@@ -1,8 +1,8 @@
-- Test for linebreak and list option in utf-8 mode
local helpers = require('test.functional.helpers')
-local feed, insert, source = helpers.feed, helpers.insert, helpers.source
-local clear, execute, expect = helpers.clear, helpers.execute, helpers.expect
+local source = helpers.source
+local clear, expect = helpers.clear, helpers.expect
describe('linebreak', function()
setup(clear)
diff --git a/test/functional/legacy/nested_function_spec.lua b/test/functional/legacy/nested_function_spec.lua
index 87371c8294..fac3b03191 100644
--- a/test/functional/legacy/nested_function_spec.lua
+++ b/test/functional/legacy/nested_function_spec.lua
@@ -1,7 +1,7 @@
-- Tests for nested function.
local helpers = require('test.functional.helpers')
-local clear, feed, insert = helpers.clear, helpers.feed, helpers.insert
+local clear, insert = helpers.clear, helpers.insert
local execute, expect, source = helpers.execute, helpers.expect, helpers.source
describe('test_nested_function', function()
diff --git a/test/functional/legacy/qf_title_spec.lua b/test/functional/legacy/qf_title_spec.lua
index aa005117be..01c781cc05 100644
--- a/test/functional/legacy/qf_title_spec.lua
+++ b/test/functional/legacy/qf_title_spec.lua
@@ -1,8 +1,8 @@
-- Tests for quickfix window's title
local helpers = require('test.functional.helpers')
-local feed, insert, source = helpers.feed, helpers.insert, helpers.source
-local clear, execute, expect = helpers.clear, helpers.execute, helpers.expect
+local insert, source = helpers.insert, helpers.source
+local clear, expect = helpers.clear, helpers.expect
describe('qf_title', function()
setup(clear)
diff --git a/test/functional/legacy/signs_spec.lua b/test/functional/legacy/signs_spec.lua
index 89b2bf3b73..5a834c39e3 100644
--- a/test/functional/legacy/signs_spec.lua
+++ b/test/functional/legacy/signs_spec.lua
@@ -1,7 +1,6 @@
-- Tests for signs
local helpers = require('test.functional.helpers')
-local feed, insert, source = helpers.feed, helpers.insert, helpers.source
local clear, execute, expect = helpers.clear, helpers.execute, helpers.expect
describe('signs', function()
diff --git a/test/functional/legacy/writefile_spec.lua b/test/functional/legacy/writefile_spec.lua
index e7a260bcd9..efdfc1d09f 100644
--- a/test/functional/legacy/writefile_spec.lua
+++ b/test/functional/legacy/writefile_spec.lua
@@ -1,7 +1,6 @@
-- Tests for writefile()
local helpers = require('test.functional.helpers')
-local feed, insert, source = helpers.feed, helpers.insert, helpers.source
local clear, execute, expect = helpers.clear, helpers.execute, helpers.expect
describe('writefile', function()
diff --git a/test/functional/normal/K_spec.lua b/test/functional/normal/K_spec.lua
index dbda6dcb93..df6b429f50 100644
--- a/test/functional/normal/K_spec.lua
+++ b/test/functional/normal/K_spec.lua
@@ -1,7 +1,6 @@
local helpers = require('test.functional.helpers')
-local execute, eq, clear, eval, feed, ok =
- helpers.execute, helpers.eq, helpers.clear, helpers.eval,
- helpers.feed, helpers.ok
+local eq, clear, eval, feed =
+ helpers.eq, helpers.clear, helpers.eval, helpers.feed
describe('K', function()
local test_file = 'K_spec_out'
diff --git a/test/functional/plugin/helpers.lua b/test/functional/plugin/helpers.lua
index 9762ca314e..cc76794267 100644
--- a/test/functional/plugin/helpers.lua
+++ b/test/functional/plugin/helpers.lua
@@ -9,15 +9,15 @@ local additional_cmd = ''
local function nvim_argv(shada_file)
local rtp_value = ('\'%s/runtime\''):format(
paths.test_source_path:gsub('\'', '\'\''))
- local nvim_argv = {nvim_prog, '-u', 'NORC', '-i', shada_file or 'NONE', '-N',
+ local nvim_args = {nvim_prog, '-u', 'NORC', '-i', shada_file or 'NONE', '-N',
'--cmd', 'set shortmess+=I background=light noswapfile',
'--cmd', 'let &runtimepath=' .. rtp_value,
'--cmd', additional_cmd,
'--embed'}
if helpers.prepend_argv then
- return merge_args(helpers.prepend_argv, nvim_argv)
+ return merge_args(helpers.prepend_argv, nvim_args)
else
- return nvim_argv
+ return nvim_args
end
end
diff --git a/test/functional/plugin/shada_spec.lua b/test/functional/plugin/shada_spec.lua
index 407f13a55b..2202f60ce8 100644
--- a/test/functional/plugin/shada_spec.lua
+++ b/test/functional/plugin/shada_spec.lua
@@ -11,7 +11,6 @@ local reset = plugin_helpers.reset
local shada_helpers = require('test.functional.shada.helpers')
local get_shada_rw = shada_helpers.get_shada_rw
-local read_shada_file = shada_helpers.read_shada_file
local mpack_eq = function(expected, mpack_result)
local mpack_keys = {'type', 'timestamp', 'length', 'value'}
@@ -96,10 +95,10 @@ describe('In autoload/shada.vim', function()
return a[1] < b[1]
end)
local state = {i=0}
- return (function(state, var)
- state.i = state.i + 1
- if ret[state.i] then
- return table.unpack(ret[state.i])
+ return (function(state_, _)
+ state_.i = state_.i + 1
+ if ret[state_.i] then
+ return table.unpack(ret[state_.i])
end
end), state
end
@@ -2103,8 +2102,8 @@ describe('In plugin/shada.vim', function()
os.remove(fname_tmp)
end)
- local shada_eq = function(expected, fname)
- local fd = io.open(fname)
+ local shada_eq = function(expected, fname_)
+ local fd = io.open(fname_)
local mpack_result = fd:read('*a')
fd:close()
mpack_eq(expected, mpack_result)
@@ -2574,6 +2573,7 @@ describe('syntax/shada.vim', function()
'ShaDaEntryMapHeader'}, s} end
local ah = function(s) return {{'ShaDaEntryArray',
'ShaDaEntryArrayHeader'}, s} end
+ -- luacheck: ignore
local mses = function(s) return {{'ShaDaEntryMapShort',
'ShaDaEntryMapShortEntryStart'}, s} end
local mles = function(s) return {{'ShaDaEntryMapLong',
diff --git a/test/functional/provider/define_spec.lua b/test/functional/provider/define_spec.lua
index 9b97ed84d9..6e8a3b89cd 100644
--- a/test/functional/provider/define_spec.lua
+++ b/test/functional/provider/define_spec.lua
@@ -1,7 +1,7 @@
local helpers = require('test.functional.helpers')
local eval, command, nvim = helpers.eval, helpers.command, helpers.nvim
local eq, run, stop = helpers.eq, helpers.run, helpers.stop
-local clear, feed = helpers.clear, helpers.feed
+local clear = helpers.clear
local function get_prefix(sync)
@@ -12,8 +12,8 @@ local function get_prefix(sync)
end
-local function call(fn, args)
- command('call '..fn..'('..args..')')
+local function call(fn, arguments)
+ command('call '..fn..'('..arguments..')')
end
@@ -87,9 +87,9 @@ local function command_specs_for(fn, sync, first_arg_factory, init)
command('RpcCommand arg1 arg2 arg3')
end
- local function handler(method, args)
+ local function handler(method, arguments)
eq('test-handler', method)
- eq({'arg1', 'arg2', 'arg3'}, args[1])
+ eq({'arg1', 'arg2', 'arg3'}, arguments[1])
return ''
end
@@ -104,9 +104,9 @@ local function command_specs_for(fn, sync, first_arg_factory, init)
command('1,1RpcCommand')
end
- local function handler(method, args)
+ local function handler(method, arguments)
eq('test-handler', method)
- eq({1, 1}, args[1])
+ eq({1, 1}, arguments[1])
return ''
end
@@ -121,10 +121,10 @@ local function command_specs_for(fn, sync, first_arg_factory, init)
command('1,1RpcCommand arg')
end
- local function handler(method, args)
+ local function handler(method, arguments)
eq('test-handler', method)
- eq({'arg'}, args[1])
- eq({1, 1}, args[2])
+ eq({'arg'}, arguments[1])
+ eq({1, 1}, arguments[2])
return ''
end
@@ -139,10 +139,10 @@ local function command_specs_for(fn, sync, first_arg_factory, init)
command('5RpcCommand arg')
end
- local function handler(method, args)
+ local function handler(method, arguments)
eq('test-handler', method)
- eq({'arg'}, args[1])
- eq(5, args[2])
+ eq({'arg'}, arguments[1])
+ eq(5, arguments[2])
return ''
end
@@ -157,11 +157,11 @@ local function command_specs_for(fn, sync, first_arg_factory, init)
command('5RpcCommand! arg')
end
- local function handler(method, args)
+ local function handler(method, arguments)
eq('test-handler', method)
- eq({'arg'}, args[1])
- eq(5, args[2])
- eq(1, args[3])
+ eq({'arg'}, arguments[1])
+ eq(5, arguments[2])
+ eq(1, arguments[3])
return ''
end
@@ -177,12 +177,12 @@ local function command_specs_for(fn, sync, first_arg_factory, init)
command('5RpcCommand! b arg')
end
- local function handler(method, args)
+ local function handler(method, arguments)
eq('test-handler', method)
- eq({'arg'}, args[1])
- eq(5, args[2])
- eq(1, args[3])
- eq('b', args[4])
+ eq({'arg'}, arguments[1])
+ eq(5, arguments[2])
+ eq(1, arguments[3])
+ eq('b', arguments[4])
return ''
end
@@ -199,13 +199,13 @@ local function command_specs_for(fn, sync, first_arg_factory, init)
command('5RpcCommand! b arg')
end
- local function handler(method, args)
+ local function handler(method, arguments)
eq('test-handler', method)
- eq({'arg'}, args[1])
- eq(5, args[2])
- eq(1, args[3])
- eq('b', args[4])
- eq('regb', args[5])
+ eq({'arg'}, arguments[1])
+ eq(5, arguments[2])
+ eq(1, arguments[3])
+ eq('b', arguments[4])
+ eq('regb', arguments[5])
return ''
end
@@ -243,7 +243,7 @@ local function autocmd_specs_for(fn, sync, first_arg_factory, init)
command('doautocmd BufEnter x.c')
end
- local function handler(method, args)
+ local function handler(method)
eq('test-handler', method)
return ''
end
@@ -259,9 +259,9 @@ local function autocmd_specs_for(fn, sync, first_arg_factory, init)
command('doautocmd BufEnter x.c')
end
- local function handler(method, args)
+ local function handler(method, arguments)
eq('test-handler', method)
- eq('x.c', args[1])
+ eq('x.c', arguments[1])
return ''
end
@@ -303,9 +303,9 @@ local function function_specs_for(fn, sync, first_arg_factory, init)
end
end
- local function handler(method, args)
+ local function handler(method, arguments)
eq('test-handler', method)
- eq({{1, 'a', {'b', 'c'}}}, args)
+ eq({{1, 'a', {'b', 'c'}}}, arguments)
return 'rv'
end
@@ -324,9 +324,9 @@ local function function_specs_for(fn, sync, first_arg_factory, init)
end
end
- local function handler(method, args)
+ local function handler(method, arguments)
eq('test-handler', method)
- eq({{1, 'a', {'b', 'c'}}, 4}, args)
+ eq({{1, 'a', {'b', 'c'}}, 4}, arguments)
return 'rv'
end
diff --git a/test/functional/server/server_spec.lua b/test/functional/server/server_spec.lua
index 1cb3c879b9..d9ce96057e 100644
--- a/test/functional/server/server_spec.lua
+++ b/test/functional/server/server_spec.lua
@@ -1,7 +1,6 @@
local helpers = require('test.functional.helpers')
-local nvim, eq, neq, ok, eval
- = helpers.nvim, helpers.eq, helpers.neq, helpers.ok, helpers.eval
+local nvim, eq, neq, eval = helpers.nvim, helpers.eq, helpers.neq, helpers.eval
local clear = helpers.clear
describe('serverstart(), serverstop()', function()
diff --git a/test/functional/shada/buffers_spec.lua b/test/functional/shada/buffers_spec.lua
index 3666b718f0..fd0c5e9a39 100644
--- a/test/functional/shada/buffers_spec.lua
+++ b/test/functional/shada/buffers_spec.lua
@@ -9,8 +9,8 @@ local reset, set_additional_cmd, clear =
shada_helpers.clear
describe('ShaDa support code', function()
- testfilename = 'Xtestfile-functional-shada-buffers'
- testfilename_2 = 'Xtestfile-functional-shada-buffers-2'
+ local testfilename = 'Xtestfile-functional-shada-buffers'
+ local testfilename_2 = 'Xtestfile-functional-shada-buffers-2'
before_each(reset)
after_each(clear)
diff --git a/test/functional/shada/compatibility_spec.lua b/test/functional/shada/compatibility_spec.lua
index 342dee377b..2ca0b16e75 100644
--- a/test/functional/shada/compatibility_spec.lua
+++ b/test/functional/shada/compatibility_spec.lua
@@ -4,9 +4,8 @@ local nvim_command, funcs, eq = helpers.command, helpers.funcs, helpers.eq
local exc_exec = helpers.exc_exec
local shada_helpers = require('test.functional.shada.helpers')
-local reset, set_additional_cmd, clear, get_shada_rw =
- shada_helpers.reset, shada_helpers.set_additional_cmd,
- shada_helpers.clear, shada_helpers.get_shada_rw
+local reset, clear, get_shada_rw = shada_helpers.reset, shada_helpers.clear,
+ shada_helpers.get_shada_rw
local read_shada_file = shada_helpers.read_shada_file
local wshada, sdrcmd, shada_fname = get_shada_rw('Xtest-functional-shada-compatibility.shada')
@@ -181,7 +180,7 @@ describe('ShaDa forward compatibility support code', function()
end
eq(3, found)
nvim_command('wshada! ' .. shada_fname)
- local found = 0
+ found = 0
for i, subv in ipairs(read_shada_file(shada_fname)) do
if i == 1 then
eq(1, subv.type)
@@ -249,7 +248,7 @@ describe('ShaDa forward compatibility support code', function()
end
eq(1, found)
nvim_command('wshada! ' .. shada_fname)
- local found = 0
+ found = 0
for i, v in ipairs(read_shada_file(shada_fname)) do
if i == 1 then
eq(1, v.type)
@@ -289,7 +288,7 @@ describe('ShaDa forward compatibility support code', function()
end
eq(1, found)
nvim_command('wshada! ' .. shada_fname)
- local found = 0
+ found = 0
for i, v in ipairs(read_shada_file(shada_fname)) do
if i == 1 then
eq(1, v.type)
@@ -395,7 +394,7 @@ describe('ShaDa forward compatibility support code', function()
end
eq(1, found)
nvim_command('wshada! ' .. shada_fname)
- local found = 0
+ found = 0
for i, v in ipairs(read_shada_file(shada_fname)) do
if i == 1 then
eq(1, v.type)
@@ -432,7 +431,7 @@ describe('ShaDa forward compatibility support code', function()
end
eq(1, found)
nvim_command('wshada! ' .. shada_fname)
- local found = 0
+ found = 0
for i, v in ipairs(read_shada_file(shada_fname)) do
if i == 1 then
eq(1, v.type)
diff --git a/test/functional/shada/helpers.lua b/test/functional/shada/helpers.lua
index c2ff4cadd1..146ae8d51e 100644
--- a/test/functional/shada/helpers.lua
+++ b/test/functional/shada/helpers.lua
@@ -9,15 +9,14 @@ local tmpname = os.tmpname()
local additional_cmd = ''
local function nvim_argv()
- local ret
- local nvim_argv = {nvim_prog, '-u', 'NONE', '-i', tmpname, '-N',
- '--cmd', 'set shortmess+=I background=light noswapfile',
- '--cmd', additional_cmd,
- '--embed'}
+ local argv = {nvim_prog, '-u', 'NONE', '-i', tmpname, '-N',
+ '--cmd', 'set shortmess+=I background=light noswapfile',
+ '--cmd', additional_cmd,
+ '--embed'}
if helpers.prepend_argv then
- return merge_args(helpers.prepend_argv, nvim_argv)
+ return merge_args(helpers.prepend_argv, argv)
else
- return nvim_argv
+ return argv
end
end
@@ -88,7 +87,6 @@ return {
reset=reset,
set_additional_cmd=set_additional_cmd,
clear=clear,
- exc_exec=exc_exec,
get_shada_rw=get_shada_rw,
read_shada_file=read_shada_file,
}
diff --git a/test/functional/shada/marks_spec.lua b/test/functional/shada/marks_spec.lua
index 6818844ebd..955a6f382b 100644
--- a/test/functional/shada/marks_spec.lua
+++ b/test/functional/shada/marks_spec.lua
@@ -15,15 +15,15 @@ local nvim_current_line = function()
end
describe('ShaDa support code', function()
- testfilename = 'Xtestfile-functional-shada-marks'
- testfilename_2 = 'Xtestfile-functional-shada-marks-2'
+ local testfilename = 'Xtestfile-functional-shada-marks'
+ local testfilename_2 = 'Xtestfile-functional-shada-marks-2'
before_each(function()
reset()
local fd = io.open(testfilename, 'w')
fd:write('test\n')
fd:write('test2\n')
fd:close()
- local fd = io.open(testfilename_2, 'w')
+ fd = io.open(testfilename_2, 'w')
fd:write('test3\n')
fd:write('test4\n')
fd:close()
@@ -115,7 +115,7 @@ describe('ShaDa support code', function()
eq(tf_full, oldfiles[1])
eq(tf_full_2, oldfiles[2])
nvim_command('rshada!')
- local oldfiles = meths.get_vvar('oldfiles')
+ oldfiles = meths.get_vvar('oldfiles')
table.sort(oldfiles)
eq(2, #oldfiles)
eq(testfilename, oldfiles[1]:sub(-#testfilename))
diff --git a/test/functional/shada/merging_spec.lua b/test/functional/shada/merging_spec.lua
index 7066ca9f54..221f989409 100644
--- a/test/functional/shada/merging_spec.lua
+++ b/test/functional/shada/merging_spec.lua
@@ -1,7 +1,7 @@
-- ShaDa merging data support
local helpers = require('test.functional.helpers')
-local nvim_command, meths, funcs, curbufmeths, eq =
- helpers.command, helpers.meths, helpers.funcs,
+local nvim_command, funcs, curbufmeths, eq =
+ helpers.command, helpers.funcs,
helpers.curbufmeths, helpers.eq
local exc_exec, redir_exec = helpers.exc_exec, helpers.redir_exec
@@ -870,7 +870,7 @@ describe('ShaDa jumps support code', function()
end
wshada(shada)
eq(0, exc_exec(sdrcmd()))
- local shada = ''
+ shada = ''
for i = 1,101 do
local t = i * 2
shada = shada .. (
@@ -964,7 +964,7 @@ describe('ShaDa changes support code', function()
end
wshada(shada)
eq(0, exc_exec(sdrcmd()))
- local shada = ''
+ shada = ''
for i = 1,101 do
local t = i * 2
shada = shada .. (
@@ -1001,7 +1001,7 @@ describe('ShaDa changes support code', function()
end
wshada(shada)
eq(0, exc_exec(sdrcmd()))
- local shada = ''
+ shada = ''
for i = 1,100 do
shada = shada .. ('\011%c\018\131\162mX\195\161f\196\006/a/b/c\161l%c'
):format(i, i)
diff --git a/test/functional/shell/viml_system_spec.lua b/test/functional/shell/viml_system_spec.lua
index 4985c24aec..00b16e9158 100644
--- a/test/functional/shell/viml_system_spec.lua
+++ b/test/functional/shell/viml_system_spec.lua
@@ -133,7 +133,7 @@ describe('system()', function()
-- write more than 1mb of data, which should be enough to overcome
-- the os buffer limit and force multiple event loop iterations to write
-- everything
- for i = 1, 0xffff do
+ for _ = 1, 0xffff do
input[#input + 1] = '01234567890ABCDEFabcdef'
end
input = table.concat(input, '\n')
@@ -299,7 +299,7 @@ describe('systemlist()', function()
describe('passing a lot of input', function()
it('returns the program output', function()
local input = {}
- for i = 1, 0xffff do
+ for _ = 1, 0xffff do
input[#input + 1] = '01234567890ABCDEFabcdef'
end
nvim('set_var', 'input', input)
diff --git a/test/functional/terminal/altscreen_spec.lua b/test/functional/terminal/altscreen_spec.lua
index 9ec0fc7c5a..d9d96b25f9 100644
--- a/test/functional/terminal/altscreen_spec.lua
+++ b/test/functional/terminal/altscreen_spec.lua
@@ -1,6 +1,5 @@
local helpers = require('test.functional.helpers')
local thelpers = require('test.functional.terminal.helpers')
-local Screen = require('test.functional.ui.screen')
local clear, eq, curbuf = helpers.clear, helpers.eq, helpers.curbuf
local feed = helpers.feed
local feed_data = thelpers.feed_data
diff --git a/test/functional/terminal/buffer_spec.lua b/test/functional/terminal/buffer_spec.lua
index ffdfec4428..55ef254a63 100644
--- a/test/functional/terminal/buffer_spec.lua
+++ b/test/functional/terminal/buffer_spec.lua
@@ -1,5 +1,4 @@
local helpers = require('test.functional.helpers')
-local Screen = require('test.functional.ui.screen')
local thelpers = require('test.functional.terminal.helpers')
local feed, clear, nvim = helpers.feed, helpers.clear, helpers.nvim
local wait = helpers.wait
diff --git a/test/functional/terminal/cursor_spec.lua b/test/functional/terminal/cursor_spec.lua
index 7f07467fde..e9cb010003 100644
--- a/test/functional/terminal/cursor_spec.lua
+++ b/test/functional/terminal/cursor_spec.lua
@@ -2,7 +2,7 @@ local helpers = require('test.functional.helpers')
local Screen = require('test.functional.ui.screen')
local thelpers = require('test.functional.terminal.helpers')
local feed, clear, nvim = helpers.feed, helpers.clear, helpers.nvim
-local nvim_dir, execute, eq = helpers.nvim_dir, helpers.execute, helpers.eq
+local nvim_dir, execute = helpers.nvim_dir, helpers.execute
local hide_cursor = thelpers.hide_cursor
local show_cursor = thelpers.show_cursor
diff --git a/test/functional/terminal/ex_terminal_spec.lua b/test/functional/terminal/ex_terminal_spec.lua
index 611ba55793..493539b4d3 100644
--- a/test/functional/terminal/ex_terminal_spec.lua
+++ b/test/functional/terminal/ex_terminal_spec.lua
@@ -2,8 +2,7 @@ local helpers = require('test.functional.helpers')
local Screen = require('test.functional.ui.screen')
local clear, wait, nvim = helpers.clear, helpers.wait, helpers.nvim
local nvim_dir = helpers.nvim_dir
-local execute, source = helpers.execute, helpers.source
-local eq, neq = helpers.eq, helpers.neq
+local execute = helpers.execute
describe(':terminal', function()
local screen
diff --git a/test/functional/terminal/helpers.lua b/test/functional/terminal/helpers.lua
index ae13aab277..a32ae650d6 100644
--- a/test/functional/terminal/helpers.lua
+++ b/test/functional/terminal/helpers.lua
@@ -72,7 +72,7 @@ local function screen_setup(extra_height, command)
empty_line,
empty_line,
}
- for i = 1, extra_height do
+ for _ = 1, extra_height do
table.insert(expected, empty_line)
end
diff --git a/test/functional/terminal/highlight_spec.lua b/test/functional/terminal/highlight_spec.lua
index 1a96cb4dba..045f5aa42f 100644
--- a/test/functional/terminal/highlight_spec.lua
+++ b/test/functional/terminal/highlight_spec.lua
@@ -40,7 +40,7 @@ describe('terminal window highlighting', function()
]])
end)
- function descr(title, attr_num, set_attrs_fn)
+ local function descr(title, attr_num, set_attrs_fn)
local function sub(s)
return s:gsub('NUM', attr_num)
end
diff --git a/test/functional/terminal/mouse_spec.lua b/test/functional/terminal/mouse_spec.lua
index ac61abebcb..c4bd3c2663 100644
--- a/test/functional/terminal/mouse_spec.lua
+++ b/test/functional/terminal/mouse_spec.lua
@@ -1,8 +1,7 @@
-local Screen = require('test.functional.ui.screen')
local helpers = require('test.functional.helpers')
local thelpers = require('test.functional.terminal.helpers')
-local clear, eq, curbuf = helpers.clear, helpers.eq, helpers.curbuf
-local feed, execute, nvim = helpers.feed, helpers.execute, helpers.nvim
+local clear = helpers.clear
+local feed, nvim = helpers.feed, helpers.nvim
local feed_data = thelpers.feed_data
describe('terminal mouse', function()
diff --git a/test/functional/terminal/tui_spec.lua b/test/functional/terminal/tui_spec.lua
index 3c79bc1fdb..14700a2622 100644
--- a/test/functional/terminal/tui_spec.lua
+++ b/test/functional/terminal/tui_spec.lua
@@ -1,6 +1,5 @@
-- Some sanity checks for the TUI using the builtin terminal emulator
-- as a simple way to send keys and assert screen state.
-local Screen = require('test.functional.ui.screen')
local helpers = require('test.functional.helpers')
local thelpers = require('test.functional.terminal.helpers')
local feed = thelpers.feed_data
@@ -176,6 +175,8 @@ describe('tui with non-tty file descriptors', function()
end)
describe('tui focus event handling', function()
+ local screen
+
before_each(function()
helpers.clear()
screen = thelpers.screen_setup(0, '["'..helpers.nvim_prog..'", "-u", "NONE", "-i", "NONE", "--cmd", "set noswapfile"]')
diff --git a/test/functional/terminal/window_spec.lua b/test/functional/terminal/window_spec.lua
index c2b9390a11..6c236ed868 100644
--- a/test/functional/terminal/window_spec.lua
+++ b/test/functional/terminal/window_spec.lua
@@ -1,7 +1,7 @@
local helpers = require('test.functional.helpers')
local thelpers = require('test.functional.terminal.helpers')
-local feed, clear, nvim = helpers.feed, helpers.clear, helpers.nvim
-local wait, eq = helpers.wait, helpers.eq
+local feed, clear = helpers.feed, helpers.clear
+local wait = helpers.wait
describe('terminal window', function()
diff --git a/test/functional/terminal/window_split_tab_spec.lua b/test/functional/terminal/window_split_tab_spec.lua
index c102b1f133..727eba2717 100644
--- a/test/functional/terminal/window_split_tab_spec.lua
+++ b/test/functional/terminal/window_split_tab_spec.lua
@@ -1,8 +1,7 @@
local helpers = require('test.functional.helpers')
local thelpers = require('test.functional.terminal.helpers')
-local clear, eq, curbuf = helpers.clear, helpers.eq, helpers.curbuf
+local clear = helpers.clear
local feed, nvim = helpers.feed, helpers.nvim
-local feed_data = thelpers.feed_data
describe('terminal', function()
local screen
diff --git a/test/functional/ui/highlight_spec.lua b/test/functional/ui/highlight_spec.lua
index 33a53ef201..f9b112e464 100644
--- a/test/functional/ui/highlight_spec.lua
+++ b/test/functional/ui/highlight_spec.lua
@@ -1,6 +1,6 @@
local helpers = require('test.functional.helpers')
local Screen = require('test.functional.ui.screen')
-local clear, feed, nvim = helpers.clear, helpers.feed, helpers.nvim
+local clear, feed = helpers.clear, helpers.feed
local execute, request, eq = helpers.execute, helpers.request, helpers.eq
diff --git a/test/functional/ui/input_spec.lua b/test/functional/ui/input_spec.lua
index a7c8e02def..4818830940 100644
--- a/test/functional/ui/input_spec.lua
+++ b/test/functional/ui/input_spec.lua
@@ -8,7 +8,6 @@ describe('mappings', function()
local cid
local add_mapping = function(mapping, send)
- local str = 'mapped '..mapping
local cmd = "nnoremap "..mapping.." :call rpcnotify("..cid..", 'mapped', '"
..send:gsub('<', '<lt>').."')<cr>"
execute(cmd)
diff --git a/test/functional/ui/screen.lua b/test/functional/ui/screen.lua
index c767f9b83a..e1c2d14759 100644
--- a/test/functional/ui/screen.lua
+++ b/test/functional/ui/screen.lua
@@ -106,8 +106,8 @@
-- use `screen:snapshot_util({},true)`
local helpers = require('test.functional.helpers')
-local request, run, stop = helpers.request, helpers.run, helpers.stop
-local eq, dedent = helpers.eq, helpers.dedent
+local request, run = helpers.request, helpers.run
+local dedent = helpers.dedent
local Screen = {}
Screen.__index = Screen
@@ -241,7 +241,7 @@ function Screen:wait(check, timeout)
checked = true
if not err then
success_seen = true
- stop()
+ helpers.stop()
elseif success_seen and #args > 0 then
failure_after_success = true
--print(require('inspect')(args))
@@ -294,9 +294,9 @@ end
function Screen:_handle_resize(width, height)
local rows = {}
- for i = 1, height do
+ for _ = 1, height do
local cols = {}
- for j = 1, width do
+ for _ = 1, width do
table.insert(cols, {text = ' ', attrs = {}})
end
table.insert(rows, cols)
@@ -448,7 +448,7 @@ function Screen:_row_repr(row, attr_ids, attr_ignore)
local rv = {}
local current_attr_id
for i = 1, self._width do
- local attr_id = get_attr_id(attr_ids, attr_ignore, row[i].attrs)
+ local attr_id = self:_get_attr_id(attr_ids, attr_ignore, row[i].attrs)
if current_attr_id and attr_id ~= current_attr_id then
-- close current attribute bracket, add it before any whitespace
-- up to the current cell
@@ -524,8 +524,8 @@ function Screen:print_snapshot(attrs, ignore)
local row = self._rows[i]
for j = 1, self._width do
local attr = row[j].attrs
- if attr_index(attrs, attr) == nil and attr_index(ignore, attr) == nil then
- if not equal_attrs(attr, {}) then
+ if self:_attr_index(attrs, attr) == nil and self:_attr_index(ignore, attr) == nil then
+ if not self:_equal_attrs(attr, {}) then
table.insert(attrs, attr)
end
end
@@ -544,7 +544,7 @@ function Screen:print_snapshot(attrs, ignore)
if self._default_attr_ids == nil or self._default_attr_ids[i] ~= a then
alldefault = false
end
- local dict = "{"..pprint_attrs(a).."}"
+ local dict = "{"..self:_pprint_attrs(a).."}"
table.insert(attrstrs, "["..tostring(i).."] = "..dict)
end
local attrstr = "{"..table.concat(attrstrs, ", ").."}"
@@ -558,7 +558,7 @@ function Screen:print_snapshot(attrs, ignore)
io.stdout:flush()
end
-function pprint_attrs(attrs)
+function Screen:_pprint_attrs(attrs)
local items = {}
for f, v in pairs(attrs) do
local desc = tostring(v)
@@ -572,7 +572,7 @@ function pprint_attrs(attrs)
return table.concat(items, ", ")
end
-function backward_find_meaningful(tbl, from)
+function backward_find_meaningful(tbl, from) -- luacheck: ignore
for i = from or #tbl, 1, -1 do
if tbl[i] ~= ' ' then
return i + 1
@@ -581,24 +581,24 @@ function backward_find_meaningful(tbl, from)
return from
end
-function get_attr_id(attr_ids, ignore, attrs)
+function Screen:_get_attr_id(attr_ids, ignore, attrs)
if not attr_ids then
return
end
for id, a in pairs(attr_ids) do
- if equal_attrs(a, attrs) then
+ if self:_equal_attrs(a, attrs) then
return id
end
end
- if equal_attrs(attrs, {}) or
- ignore == true or attr_index(ignore, attrs) ~= nil then
+ if self:_equal_attrs(attrs, {}) or
+ ignore == true or self:_attr_index(ignore, attrs) ~= nil then
-- ignore this attrs
return nil
end
- return "UNEXPECTED "..pprint_attrs(attrs)
+ return "UNEXPECTED "..self:_pprint_attrs(attrs)
end
-function equal_attrs(a, b)
+function Screen:_equal_attrs(a, b)
return a.bold == b.bold and a.standout == b.standout and
a.underline == b.underline and a.undercurl == b.undercurl and
a.italic == b.italic and a.reverse == b.reverse and
@@ -606,12 +606,12 @@ function equal_attrs(a, b)
a.background == b.background
end
-function attr_index(attrs, attr)
+function Screen:_attr_index(attrs, attr)
if not attrs then
return nil
end
for i,a in pairs(attrs) do
- if equal_attrs(a, attr) then
+ if self:_equal_attrs(a, attr) then
return i
end
end
diff --git a/test/functional/ui/screen_basic_spec.lua b/test/functional/ui/screen_basic_spec.lua
index 092cc8c126..a4545eeff0 100644
--- a/test/functional/ui/screen_basic_spec.lua
+++ b/test/functional/ui/screen_basic_spec.lua
@@ -2,7 +2,7 @@ local helpers = require('test.functional.helpers')
local Screen = require('test.functional.ui.screen')
local spawn, set_session, clear = helpers.spawn, helpers.set_session, helpers.clear
local feed, execute = helpers.feed, helpers.execute
-local insert, wait = helpers.insert, helpers.wait
+local insert = helpers.insert
describe('Initial screen', function()
local screen
@@ -11,9 +11,6 @@ describe('Initial screen', function()
'--embed'}
before_each(function()
- if session then
- session:exit(0)
- end
local screen_nvim = spawn(nvim_argv)
set_session(screen_nvim)
screen = Screen.new()
diff --git a/test/functional/ui/searchhl_spec.lua b/test/functional/ui/searchhl_spec.lua
index d04329e1e2..e4217abcfe 100644
--- a/test/functional/ui/searchhl_spec.lua
+++ b/test/functional/ui/searchhl_spec.lua
@@ -1,7 +1,7 @@
local helpers = require('test.functional.helpers')
local Screen = require('test.functional.ui.screen')
-local clear, feed, nvim, insert = helpers.clear, helpers.feed, helpers.nvim, helpers.insert
-local execute, request, eq = helpers.execute, helpers.request, helpers.eq
+local clear, feed, insert = helpers.clear, helpers.feed, helpers.insert
+local execute = helpers.execute
describe('search highlighting', function()
local screen
diff --git a/test/functional/viml/completion_spec.lua b/test/functional/viml/completion_spec.lua
index 5e3d4a6658..12f542de7f 100644
--- a/test/functional/viml/completion_spec.lua
+++ b/test/functional/viml/completion_spec.lua
@@ -1,6 +1,6 @@
local helpers = require('test.functional.helpers')
-local clear, feed, execute = helpers.clear, helpers.feed, helpers.execute
+local clear, feed = helpers.clear, helpers.feed
local eval, eq, neq = helpers.eval, helpers.eq, helpers.neq
local execute, source = helpers.execute, helpers.source
diff --git a/test/unit/buffer_spec.lua b/test/unit/buffer_spec.lua
index 05fba684d6..a2e7bd91af 100644
--- a/test/unit/buffer_spec.lua
+++ b/test/unit/buffer_spec.lua
@@ -5,13 +5,10 @@ local helpers = require("test.unit.helpers")
local to_cstr = helpers.to_cstr
local eq = helpers.eq
local neq = helpers.neq
+local NULL = helpers.NULL
local globals = helpers.cimport("./src/nvim/globals.h")
local buffer = helpers.cimport("./src/nvim/buffer.h")
-local fileio = helpers.cimport("./src/nvim/fileio.h")
-local ex_docmd = helpers.cimport("./src/nvim/ex_docmd.h")
-local window = helpers.cimport("./src/nvim/window.h")
-local option = helpers.cimport("./src/nvim/option.h")
describe('buffer functions', function()
@@ -215,7 +212,7 @@ describe('buffer functions', function()
describe('build_stl_str_hl', function()
- output_buffer = to_cstr(string.rep(" ", 100))
+ local output_buffer = to_cstr(string.rep(" ", 100))
local build_stl_str_hl = function(pat)
return buffer.build_stl_str_hl(globals.curwin,
diff --git a/test/unit/fileio_spec.lua b/test/unit/fileio_spec.lua
index 180fc3c184..3e3c36617d 100644
--- a/test/unit/fileio_spec.lua
+++ b/test/unit/fileio_spec.lua
@@ -4,6 +4,7 @@ local helpers = require("test.unit.helpers")
local eq = helpers.eq
local ffi = helpers.ffi
local to_cstr = helpers.to_cstr
+local NULL = helpers.NULL
local fileio = helpers.cimport("./src/nvim/fileio.h")
diff --git a/test/unit/formatc.lua b/test/unit/formatc.lua
index f9397eaec6..3f86c5f1b1 100644
--- a/test/unit/formatc.lua
+++ b/test/unit/formatc.lua
@@ -124,13 +124,13 @@ end
local function set(t)
local s = {}
- for i, v in ipairs(t) do
+ for _, v in ipairs(t) do
s[v] = true
end
return s
end
-local C_keywords = set {
+local C_keywords = set { -- luacheck: ignore
"break", "case", "char", "const", "continue", "default", "do", "double",
"else", "enum", "extern", "float", "for", "goto", "if", "int", "long",
"register", "return", "short", "signed", "sizeof", "static", "struct",
@@ -154,13 +154,13 @@ local C_keywords = set {
-- The first one will have a lot of false positives (the line '{' for
-- example), the second one is more unique.
local function formatc(str)
- local tokens = TokeniseC(str)
+ local toks = TokeniseC(str)
local result = {}
local block_level = 0
local allow_one_nl = false
local end_at_brace = false
- for i, token in ipairs(tokens) do
+ for _, token in ipairs(toks) do
local typ = token[2]
if typ == '{' then
block_level = block_level + 1
@@ -213,8 +213,8 @@ local function formatc(str)
end
-- standalone operation (very handy for debugging)
-local function standalone(...)
- Preprocess = require("preprocess")
+local function standalone(...) -- luacheck: ignore
+ local Preprocess = require("preprocess")
Preprocess.add_to_include_path('./../../src')
Preprocess.add_to_include_path('./../../build/include')
Preprocess.add_to_include_path('./../../.deps/usr/include')
diff --git a/test/unit/garray_spec.lua b/test/unit/garray_spec.lua
index e779cab8a7..9694e3c427 100644
--- a/test/unit/garray_spec.lua
+++ b/test/unit/garray_spec.lua
@@ -5,8 +5,6 @@ local internalize = helpers.internalize
local eq = helpers.eq
local neq = helpers.neq
local ffi = helpers.ffi
-local lib = helpers.lib
-local cstr = helpers.cstr
local to_cstr = helpers.to_cstr
local NULL = helpers.NULL
@@ -48,7 +46,7 @@ local ga_size = function(garr)
return ga_len(garr) * ga_itemsize(garr)
end
-local ga_maxsize = function(garr)
+local ga_maxsize = function(garr) -- luacheck: ignore
return ga_maxlen(garr) * ga_itemsize(garr)
end
@@ -65,8 +63,8 @@ local ga_data_as_ints = function(garr)
end
-- garray manipulation
-local ga_init = function(garr, itemsize, growsize)
- return garray.ga_init(garr, itemsize, growsize)
+local ga_init = function(garr, itemsize_, growsize_)
+ return garray.ga_init(garr, itemsize_, growsize_)
end
local ga_clear = function(garr)
@@ -113,7 +111,7 @@ local ga_set_len = function(garr, len)
end
local ga_inc_len = function(garr, by)
- return ga_set_len(garr, ga_len(garr) + 1)
+ return ga_set_len(garr, ga_len(garr) + by)
end
-- custom append functions
@@ -197,10 +195,9 @@ describe('garray', function()
end)
describe('ga_grow', function()
- local new_and_grow
- function new_and_grow(itemsize, growsize, req)
+ local function new_and_grow(itemsize_, growsize_, req)
local garr = new_garray()
- ga_init(garr, itemsize, growsize)
+ ga_init(garr, itemsize_, growsize_)
eq(0, ga_size(garr)) -- should be 0 at first
eq(NULL, ga_data(garr)) -- should be NULL
ga_grow(garr, req) -- add space for `req` items
@@ -306,7 +303,7 @@ describe('garray', function()
ga_init(garr, ffi.sizeof("char"), 1)
local str = "ohwell●●"
local loop = 5
- for i = 1, loop do
+ for _ = 1, loop do
ga_concat(garr, str)
end
@@ -321,7 +318,7 @@ describe('garray', function()
end)
end)
- function test_concat_fn(input, fn, sep)
+ local function test_concat_fn(input, fn, sep)
local garr = new_string_garray()
ga_append_strings(garr, unpack(input))
if sep == nil then
diff --git a/test/unit/helpers.lua b/test/unit/helpers.lua
index 5bcc661226..7b43b2218c 100644
--- a/test/unit/helpers.lua
+++ b/test/unit/helpers.lua
@@ -18,17 +18,9 @@ local function trim(s)
end
-- a Set that keeps around the lines we've already seen
-if cdefs == nil then
- cdefs = Set:new()
-end
-
-if imported == nil then
- imported = Set:new()
-end
-
-if pragma_pack_id == nil then
- pragma_pack_id = 1
-end
+local cdefs = Set:new()
+local imported = Set:new()
+local pragma_pack_id = 1
-- some things are just too complex for the LuaJIT C parser to digest. We
-- usually don't need them anyway.
@@ -67,7 +59,7 @@ local function cimport(...)
end
local body = nil
- for i=1, 10 do
+ for _ = 1, 10 do
local stream = Preprocess.preprocess_stream(unpack(paths))
body = stream:read("*a")
stream:close()
diff --git a/test/unit/os/env_spec.lua b/test/unit/os/env_spec.lua
index 8e18c599d9..e0e12a24f2 100644
--- a/test/unit/os/env_spec.lua
+++ b/test/unit/os/env_spec.lua
@@ -1,11 +1,9 @@
local helpers = require('test.unit.helpers')
local cimport = helpers.cimport
-local internalize = helpers.internalize
local eq = helpers.eq
local neq = helpers.neq
local ffi = helpers.ffi
-local lib = helpers.lib
local cstr = helpers.cstr
local to_cstr = helpers.to_cstr
local NULL = helpers.NULL
@@ -15,15 +13,15 @@ require('lfs')
local env = cimport('./src/nvim/os/os.h')
describe('env function', function()
- function os_setenv(name, value, override)
+ local function os_setenv(name, value, override)
return env.os_setenv((to_cstr(name)), (to_cstr(value)), override)
end
- function os_unsetenv(name, value, override)
+ local function os_unsetenv(name, _, _)
return env.os_unsetenv((to_cstr(name)))
end
- function os_getenv(name)
+ local function os_getenv(name)
local rval = env.os_getenv((to_cstr(name)))
if rval ~= NULL then
return ffi.string(rval)
diff --git a/test/unit/os/fs_spec.lua b/test/unit/os/fs_spec.lua
index c7a1f55b5d..5a1b9e3aa8 100644
--- a/test/unit/os/fs_spec.lua
+++ b/test/unit/os/fs_spec.lua
@@ -1,3 +1,6 @@
+local lfs = require('lfs')
+local bit = require('bit')
+
local helpers = require('test.unit.helpers')
local cimport = helpers.cimport
@@ -6,16 +9,12 @@ local internalize = helpers.internalize
local eq = helpers.eq
local neq = helpers.neq
local ffi = helpers.ffi
-local lib = helpers.lib
local cstr = helpers.cstr
local to_cstr = helpers.to_cstr
local OK = helpers.OK
local FAIL = helpers.FAIL
local NULL = helpers.NULL
-require('lfs')
-require('bit')
-
cimport('unistd.h')
cimport('./src/nvim/os/shell.h')
cimport('./src/nvim/option_defs.h')
@@ -26,8 +25,7 @@ cppimport('sys/stat.h')
cppimport('sys/fcntl.h')
cppimport('sys/errno.h')
-local len = 0
-local buf = ""
+local buffer = ""
local directory = nil
local absolute_executable = nil
local executable_name = nil
@@ -85,24 +83,26 @@ describe('fs function', function()
end)
describe('os_dirname', function()
+ local length
+
local function os_dirname(buf, len)
return fs.os_dirname(buf, len)
end
before_each(function()
- len = (string.len(lfs.currentdir())) + 1
- buf = cstr(len, '')
+ length = (string.len(lfs.currentdir())) + 1
+ buffer = cstr(length, '')
end)
it('returns OK and writes current directory into the buffer if it is large\n enough', function()
- eq(OK, (os_dirname(buf, len)))
- eq(lfs.currentdir(), (ffi.string(buf)))
+ eq(OK, (os_dirname(buffer, length)))
+ eq(lfs.currentdir(), (ffi.string(buffer)))
end)
-- What kind of other failing cases are possible?
it('returns FAIL if the buffer is too small', function()
- local buf = cstr((len - 1), '')
- eq(FAIL, (os_dirname(buf, (len - 1))))
+ local buf = cstr((length - 1), '')
+ eq(FAIL, (os_dirname(buf, (length - 1))))
end)
end)
@@ -213,15 +213,6 @@ describe('fs function', function()
os_setperm('unit-test-directory/test.file', orig_test_file_perm)
end)
- local function os_getperm(filename)
- local perm = fs.os_getperm((to_cstr(filename)))
- return tonumber(perm)
- end
-
- local function os_setperm(filename, perm)
- return fs.os_setperm((to_cstr(filename)), perm)
- end
-
local function os_fchown(filename, user_id, group_id)
local fd = ffi.C.open(filename, 0)
local res = fs.os_fchown(fd, user_id, group_id)
@@ -611,7 +602,7 @@ describe('fs function', function()
it('removes the given directory and returns 0', function()
lfs.mkdir('unit-test-directory/new-dir')
- eq(0, (os_rmdir('unit-test-directory/new-dir', mode)))
+ eq(0, os_rmdir('unit-test-directory/new-dir'))
eq(false, (os_isdir('unit-test-directory/new-dir')))
end)
end)
diff --git a/test/unit/os/shell_spec.lua b/test/unit/os/shell_spec.lua
index 20cfc17950..01deefab0c 100644
--- a/test/unit/os/shell_spec.lua
+++ b/test/unit/os/shell_spec.lua
@@ -17,7 +17,7 @@ local shell = helpers.cimport(
'./src/nvim/main.h',
'./src/nvim/misc1.h'
)
-local ffi, eq, neq = helpers.ffi, helpers.eq, helpers.neq
+local ffi, eq = helpers.ffi, helpers.eq
local intern = helpers.internalize
local to_cstr = helpers.to_cstr
local NULL = ffi.cast('void *', 0)
@@ -70,7 +70,7 @@ describe('shell functions', function()
end)
it ('returns non-zero exit code', function()
- local status, output = os_system('exit 2')
+ local status = os_system('exit 2')
eq(2, status)
end)
end)
diff --git a/test/unit/os/users_spec.lua b/test/unit/os/users_spec.lua
index df5d2365c6..236481e9e7 100644
--- a/test/unit/os/users_spec.lua
+++ b/test/unit/os/users_spec.lua
@@ -1,26 +1,24 @@
local helpers = require('test.unit.helpers')
local cimport = helpers.cimport
-local internalize = helpers.internalize
local eq = helpers.eq
local ffi = helpers.ffi
local lib = helpers.lib
-local cstr = helpers.cstr
local NULL = helpers.NULL
local OK = helpers.OK
local FAIL = helpers.FAIL
local users = cimport('./src/nvim/os/os.h', 'unistd.h')
-function garray_new()
+local function garray_new()
return ffi.new('garray_T[1]')
end
-function garray_get_len(array)
+local function garray_get_len(array)
return array[0].ga_len
end
-function garray_get_item(array, index)
+local function garray_get_item(array, index)
return (ffi.cast('void **', array[0].ga_data))[index]
end
diff --git a/test/unit/path_spec.lua b/test/unit/path_spec.lua
index 239a255151..9b76834383 100644
--- a/test/unit/path_spec.lua
+++ b/test/unit/path_spec.lua
@@ -1,18 +1,16 @@
+local lfs = require('lfs')
local helpers = require('test.unit.helpers')
local cimport = helpers.cimport
-local internalize = helpers.internalize
local eq = helpers.eq
local neq = helpers.neq
local ffi = helpers.ffi
-local lib = helpers.lib
local cstr = helpers.cstr
local to_cstr = helpers.to_cstr
local NULL = helpers.NULL
local OK = helpers.OK
local FAIL = helpers.FAIL
-require('lfs')
cimport('string.h')
local path = cimport('./src/nvim/path.h')
@@ -23,7 +21,7 @@ local kBothFilesMissing = path.kBothFilesMissing
local kOneFileMissing = path.kOneFileMissing
local kEqualFileNames = path.kEqualFileNames
-local len = 0
+local length = 0
local buffer = nil
describe('path function', function()
@@ -36,19 +34,19 @@ describe('path function', function()
lfs.rmdir('unit-test-directory')
end)
- function path_full_dir_name(directory, buffer, len)
+ local function path_full_dir_name(directory, buf, len)
directory = to_cstr(directory)
- return path.path_full_dir_name(directory, buffer, len)
+ return path.path_full_dir_name(directory, buf, len)
end
before_each(function()
-- Create empty string buffer which will contain the resulting path.
- len = (string.len(lfs.currentdir())) + 22
- buffer = cstr(len, '')
+ length = string.len(lfs.currentdir()) + 22
+ buffer = cstr(length, '')
end)
it('returns the absolute directory name of a given relative one', function()
- local result = path_full_dir_name('..', buffer, len)
+ local result = path_full_dir_name('..', buffer, length)
eq(OK, result)
local old_dir = lfs.currentdir()
lfs.chdir('..')
@@ -58,23 +56,23 @@ describe('path function', function()
end)
it('returns the current directory name if the given string is empty', function()
- eq(OK, (path_full_dir_name('', buffer, len)))
+ eq(OK, (path_full_dir_name('', buffer, length)))
eq(lfs.currentdir(), (ffi.string(buffer)))
end)
it('fails if the given directory does not exist', function()
- eq(FAIL, path_full_dir_name('does_not_exist', buffer, len))
+ eq(FAIL, path_full_dir_name('does_not_exist', buffer, length))
end)
it('works with a normal relative dir', function()
- local result = path_full_dir_name('unit-test-directory', buffer, len)
+ local result = path_full_dir_name('unit-test-directory', buffer, length)
eq(lfs.currentdir() .. '/unit-test-directory', (ffi.string(buffer)))
eq(OK, result)
end)
end)
describe('path_full_compare', function()
- function path_full_compare(s1, s2, cn)
+ local function path_full_compare(s1, s2, cn)
s1 = to_cstr(s1)
s2 = to_cstr(s2)
return path.path_full_compare(s1, s2, cn or 0)
@@ -117,7 +115,7 @@ describe('path function', function()
end)
describe('path_tail', function()
- function path_tail(file)
+ local function path_tail(file)
local res = path.path_tail((to_cstr(file)))
neq(NULL, res)
return ffi.string(res)
@@ -133,7 +131,7 @@ describe('path function', function()
end)
describe('path_tail_with_sep', function()
- function path_tail_with_sep(file)
+ local function path_tail_with_sep(file)
local res = path.path_tail_with_sep((to_cstr(file)))
neq(NULL, res)
return ffi.string(res)
@@ -165,7 +163,7 @@ describe('path function', function()
-- Returns the path tail and length (out param) of the tail.
-- Does not convert the tail from C-pointer to lua string for use with
-- strcmp.
- function invocation_path_tail(invk)
+ local function invocation_path_tail(invk)
local plen = ffi.new('size_t[?]', 1)
local ptail = path.invocation_path_tail((to_cstr(invk)), plen)
neq(NULL, ptail)
@@ -178,7 +176,7 @@ describe('path function', function()
end
-- This test mimics the intended use in C.
- function compare(base, pinvk, len)
+ local function compare(base, pinvk, len)
return eq(0, (ffi.C.strncmp((to_cstr(base)), pinvk, len)))
end
@@ -207,7 +205,7 @@ describe('path function', function()
end)
it('only accepts whitespace as a terminator for the executable name', function()
- local invk, len = invocation_path_tail('exe-a+b_c[]()|#!@$%^&*')
+ local invk, _ = invocation_path_tail('exe-a+b_c[]()|#!@$%^&*')
eq('exe-a+b_c[]()|#!@$%^&*', (ffi.string(invk)))
end)
@@ -215,20 +213,20 @@ describe('path function', function()
local ptail = path.path_tail(to_cstr("a/b/c x y z"))
neq(NULL, ptail)
local tail = ffi.string(ptail)
- local invk, len = invocation_path_tail("a/b/c x y z")
+ local invk, _ = invocation_path_tail("a/b/c x y z")
eq(tail, ffi.string(invk))
end)
it('is not equivalent to path_tail when args contain a path separator', function()
local ptail = path.path_tail(to_cstr("a/b/c x y/z"))
neq(NULL, ptail)
- local invk, len = invocation_path_tail("a/b/c x y/z")
+ local invk, _ = invocation_path_tail("a/b/c x y/z")
neq((ffi.string(ptail)), (ffi.string(invk)))
end)
end)
describe('path_next_component', function()
- function path_next_component(file)
+ local function path_next_component(file)
local res = path.path_next_component((to_cstr(file)))
neq(NULL, res)
return ffi.string(res)
@@ -308,11 +306,11 @@ describe('more path function', function()
-- Since the tests are executed, they are called by an executable. We use
-- that executable for several asserts.
- absolute_executable = arg[0]
+ local absolute_executable = arg[0]
-- Split absolute_executable into a directory and the actual file name for
-- later usage.
- directory, executable_name = string.match(absolute_executable, '^(.*)/(.*)$')
+ local directory, executable_name = string.match(absolute_executable, '^(.*)/(.*)$') -- luacheck: ignore
end)
teardown(function()
@@ -321,27 +319,27 @@ describe('more path function', function()
end)
describe('vim_FullName', function()
- function vim_FullName(filename, buffer, length, force)
+ local function vim_FullName(filename, buf, len, force)
filename = to_cstr(filename)
- return path.vim_FullName(filename, buffer, length, force)
+ return path.vim_FullName(filename, buf, len, force)
end
before_each(function()
-- Create empty string buffer which will contain the resulting path.
- len = (string.len(lfs.currentdir())) + 33
- buffer = cstr(len, '')
+ length = (string.len(lfs.currentdir())) + 33
+ buffer = cstr(length, '')
end)
it('fails if given filename is NULL', function()
local force_expansion = 1
- local result = path.vim_FullName(NULL, buffer, len, force_expansion)
+ local result = path.vim_FullName(NULL, buffer, length, force_expansion)
eq(FAIL, result)
end)
it('uses the filename if the filename is a URL', function()
local force_expansion = 1
local filename = 'http://www.neovim.org'
- local result = vim_FullName(filename, buffer, len, force_expansion)
+ local result = vim_FullName(filename, buffer, length, force_expansion)
eq(filename, (ffi.string(buffer)))
eq(OK, result)
end)
@@ -349,14 +347,14 @@ describe('more path function', function()
it('fails and uses filename if given filename contains non-existing directory', function()
local force_expansion = 1
local filename = 'non_existing_dir/test.file'
- local result = vim_FullName(filename, buffer, len, force_expansion)
+ local result = vim_FullName(filename, buffer, length, force_expansion)
eq(filename, (ffi.string(buffer)))
eq(FAIL, result)
end)
it('concatenates given filename if it does not contain a slash', function()
local force_expansion = 1
- local result = vim_FullName('test.file', buffer, len, force_expansion)
+ local result = vim_FullName('test.file', buffer, length, force_expansion)
local expected = lfs.currentdir() .. '/test.file'
eq(expected, (ffi.string(buffer)))
eq(OK, result)
@@ -364,7 +362,7 @@ describe('more path function', function()
it('concatenates given filename if it is a directory but does not contain a\n slash', function()
local force_expansion = 1
- local result = vim_FullName('..', buffer, len, force_expansion)
+ local result = vim_FullName('..', buffer, length, force_expansion)
local expected = lfs.currentdir() .. '/..'
eq(expected, (ffi.string(buffer)))
eq(OK, result)
@@ -374,7 +372,7 @@ describe('more path function', function()
-- the unit tests? Which other directory would be better?
it('enters given directory (instead of just concatenating the strings) if possible and if path contains a slash', function()
local force_expansion = 1
- local result = vim_FullName('../test.file', buffer, len, force_expansion)
+ local result = vim_FullName('../test.file', buffer, length, force_expansion)
local old_dir = lfs.currentdir()
lfs.chdir('..')
local expected = lfs.currentdir() .. '/test.file'
@@ -386,7 +384,7 @@ describe('more path function', function()
it('just copies the path if it is already absolute and force=0', function()
local force_expansion = 0
local absolute_path = '/absolute/path'
- local result = vim_FullName(absolute_path, buffer, len, force_expansion)
+ local result = vim_FullName(absolute_path, buffer, length, force_expansion)
eq(absolute_path, (ffi.string(buffer)))
eq(OK, result)
end)
@@ -394,14 +392,14 @@ describe('more path function', function()
it('fails and uses filename when the path is relative to HOME', function()
local force_expansion = 1
local absolute_path = '~/home.file'
- local result = vim_FullName(absolute_path, buffer, len, force_expansion)
+ local result = vim_FullName(absolute_path, buffer, length, force_expansion)
eq(absolute_path, (ffi.string(buffer)))
eq(FAIL, result)
end)
it('works with some "normal" relative path with directories', function()
local force_expansion = 1
- local result = vim_FullName('unit-test-directory/test.file', buffer, len, force_expansion)
+ local result = vim_FullName('unit-test-directory/test.file', buffer, length, force_expansion)
eq(OK, result)
eq(lfs.currentdir() .. '/unit-test-directory/test.file', (ffi.string(buffer)))
end)
@@ -411,7 +409,7 @@ describe('more path function', function()
local filename = to_cstr('unit-test-directory/test.file')
-- Don't use the wrapper here but pass a cstring directly to the c
-- function.
- local result = path.vim_FullName(filename, buffer, len, force_expansion)
+ local result = path.vim_FullName(filename, buffer, length, force_expansion)
eq(lfs.currentdir() .. '/unit-test-directory/test.file', (ffi.string(buffer)))
eq('unit-test-directory/test.file', (ffi.string(filename)))
eq(OK, result)
@@ -420,15 +418,15 @@ describe('more path function', function()
it('works with directories that have one path component', function()
local force_expansion = 1
local filename = to_cstr('/tmp')
- local result = path.vim_FullName(filename, buffer, len, force_expansion)
+ local result = path.vim_FullName(filename, buffer, length, force_expansion)
eq('/tmp', ffi.string(buffer))
eq(OK, result)
end)
end)
describe('path_fix_case', function()
- function fix_case(file)
- c_file = to_cstr(file)
+ local function fix_case(file)
+ local c_file = to_cstr(file)
path.path_fix_case(c_file)
return ffi.string(c_file)
end
@@ -493,7 +491,7 @@ describe('more path function', function()
end)
describe('path_is_absolute_path', function()
- function path_is_absolute_path(filename)
+ local function path_is_absolute_path(filename)
filename = to_cstr(filename)
return path.path_is_absolute_path(filename)
end
diff --git a/test/unit/preprocess.lua b/test/unit/preprocess.lua
index d4c2e088a4..e5c838b13b 100644
--- a/test/unit/preprocess.lua
+++ b/test/unit/preprocess.lua
@@ -169,8 +169,8 @@ local type_to_class = {
-- find the best cc. If os.exec causes problems on windows (like popping up
-- a console window) we might consider using something like this:
-- http://scite-ru.googlecode.com/svn/trunk/pack/tools/LuaLib/shell.html#exec
-local function find_best_cc(ccs)
- for _, meta in pairs(ccs) do
+local function find_best_cc(compilers)
+ for _, meta in pairs(compilers) do
local version = io.popen(tostring(meta.path) .. " -v 2>&1")
version:close()
if version then
diff --git a/test/unit/profile_spec.lua b/test/unit/profile_spec.lua
index 2b006a0768..852475fe2c 100644
--- a/test/unit/profile_spec.lua
+++ b/test/unit/profile_spec.lua
@@ -36,20 +36,20 @@ local function cmp_assert(v1, v2, op, opstr)
assert.is_true(res)
end
-local function lt(v1, v2)
- cmp_assert(v1, v2, function(v1, v2) return v1 < v2 end, "<")
+local function lt(a, b) -- luacheck: ignore
+ cmp_assert(a, b, function(x, y) return x < y end, "<")
end
-local function lte(v1, v2)
- cmp_assert(v1, v2, function(v1, v2) return v1 <= v2 end, "<=")
+local function lte(a, b) -- luacheck: ignore
+ cmp_assert(a, b, function(x, y) return x <= y end, "<=")
end
-local function gt(v1, v2)
- cmp_assert(v1, v2, function(v1, v2) return v1 > v2 end, ">")
+local function gt(a, b) -- luacheck: ignore
+ cmp_assert(a, b, function(x, y) return x > y end, ">")
end
-local function gte(v1, v2)
- cmp_assert(v1, v2, function(v1, v2) return v1 >= v2 end, ">=")
+local function gte(a, b)
+ cmp_assert(a, b, function(x, y) return x >= y end, ">=")
end
-- missing functions:
@@ -70,7 +70,7 @@ describe('profiling related functions', function()
local function profile_equal(t1, t2) return prof.profile_equal(t1, t2) end
local function profile_msg(t) return ffi.string(prof.profile_msg(t)) end
- local function toseconds(t)
+ local function toseconds(t) -- luacheck: ignore
local str = trim(profile_msg(t))
local spl = split(str, ".")
local s, us = spl[1], spl[2]
@@ -122,7 +122,7 @@ describe('profiling related functions', function()
local divided = profile_divide(start, divisor)
local res = divided
- for i = 1, divisor - 1 do
+ for _ = 1, divisor - 1 do
res = profile_add(res, divided)
end
@@ -143,7 +143,7 @@ describe('profiling related functions', function()
describe('profile_start', function()
it('increases', function()
local last = profile_start()
- for i=1,100 do
+ for _ = 1, 100 do
local curr = profile_start()
gte(curr, last)
last = curr
@@ -157,7 +157,7 @@ describe('profiling related functions', function()
end)
it('outer elapsed >= inner elapsed', function()
- for i = 1, 100 do
+ for _ = 1, 100 do
local start_outer = profile_start()
local start_inner = profile_start()
local elapsed_inner = profile_end(start_inner)
@@ -238,7 +238,7 @@ describe('profiling related functions', function()
-- t2 >= t1 => profile_cmp(t1, t2) >= 0
assert.is_true(cmp >= 0)
- local cmp = profile_cmp(profile_sub(start3, start1), profile_sub(start2, start1))
+ cmp = profile_cmp(profile_sub(start3, start1), profile_sub(start2, start1))
-- t2 <= t1 => profile_cmp(t1, t2) <= 0
assert.is_true(cmp <= 0)
end)
diff --git a/test/unit/set.lua b/test/unit/set.lua
index bfb6b8c41c..4e66546f32 100644
--- a/test/unit/set.lua
+++ b/test/unit/set.lua
@@ -35,7 +35,7 @@ end
-- adds the argument table to this Set
function Set:union_table(t)
- for k, v in pairs(t) do
+ for _, v in pairs(t) do
self:add(v)
end
end
diff --git a/third-party/cmake/BuildLuarocks.cmake b/third-party/cmake/BuildLuarocks.cmake
index cb38b3b6cc..f3e5a96220 100644
--- a/third-party/cmake/BuildLuarocks.cmake
+++ b/third-party/cmake/BuildLuarocks.cmake
@@ -114,8 +114,6 @@ add_custom_target(lpeg
list(APPEND THIRD_PARTY_DEPS lpeg)
if(USE_BUNDLED_BUSTED)
- # We can remove the cliargs dependency once the busted version dependency
- # is fixed.
add_custom_command(OUTPUT ${HOSTDEPS_BIN_DIR}/busted
COMMAND ${LUAROCKS_BINARY}
ARGS build https://raw.githubusercontent.com/Olivine-Labs/busted/v2.0.rc11-0/busted-2.0.rc11-0.rockspec ${LUAROCKS_BUILDARGS}
@@ -123,12 +121,19 @@ if(USE_BUNDLED_BUSTED)
add_custom_target(busted
DEPENDS ${HOSTDEPS_BIN_DIR}/busted)
+ add_custom_command(OUTPUT ${HOSTDEPS_BIN_DIR}/luacheck
+ COMMAND ${LUAROCKS_BINARY}
+ ARGS build https://raw.githubusercontent.com/mpeterv/luacheck/0.12.0/luacheck-scm-1.rockspec ${LUAROCKS_BUILDARGS}
+ DEPENDS busted)
+ add_custom_target(luacheck
+ DEPENDS ${HOSTDEPS_BIN_DIR}/luacheck)
+
add_custom_command(OUTPUT ${HOSTDEPS_LIB_DIR}/luarocks/rocks/nvim-client
COMMAND ${LUAROCKS_BINARY}
ARGS build https://raw.githubusercontent.com/neovim/lua-client/0.0.1-14/nvim-client-0.0.1-14.rockspec ${LUAROCKS_BUILDARGS} LIBUV_DIR=${HOSTDEPS_INSTALL_DIR}
- DEPENDS busted libuv)
+ DEPENDS luacheck libuv)
add_custom_target(nvim-client
DEPENDS ${HOSTDEPS_LIB_DIR}/luarocks/rocks/nvim-client)
- list(APPEND THIRD_PARTY_DEPS busted nvim-client)
+ list(APPEND THIRD_PARTY_DEPS busted luacheck nvim-client)
endif()