Skip to content

Commit

Permalink
(all tests) Address diagnostics of tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
echasnovski committed Sep 23, 2023
1 parent 67a6206 commit 6ccd3f8
Show file tree
Hide file tree
Showing 35 changed files with 40 additions and 63 deletions.
2 changes: 1 addition & 1 deletion TESTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -622,7 +622,7 @@ You can customize which files will be sourced and which cases will be later exec
```lua
local new_set = MiniTest.new_set

T = new_set()
local T = new_set()

-- Use `data` field to pass custom information for easier test management
T['fast'] = new_set({ data = { type = 'fast' } })
Expand Down
4 changes: 1 addition & 3 deletions tests/dir-test/testref_run-hooks.lua
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
local new_set = MiniTest.new_set

local T = new_set()

local erroring = function(x)
return function() error(x, 0) end
end

-- Track order of hook execution via error messages in `exec.fails`
T = new_set()
local T = new_set()

T['order'] = new_set({
hooks = {
Expand Down
2 changes: 1 addition & 1 deletion tests/test_ai.lua
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ local mock_treesitter_builtin = function() child.cmd('source tests/dir-ai/mock-l
local mock_treesitter_plugin = function() child.cmd('set rtp+=tests/dir-ai') end

-- Output test set
T = new_set({
local T = new_set({
hooks = {
pre_case = function()
child.setup()
Expand Down
2 changes: 1 addition & 1 deletion tests/test_align.lua
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ local eq_tostring = function(var_name1, var_name2)
end

-- Output test set
T = new_set({
local T = new_set({
hooks = {
pre_case = function()
child.setup()
Expand Down
2 changes: 1 addition & 1 deletion tests/test_animate.lua
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ local example_scroll_lines_2 = {
}

-- Output test set ============================================================
T = new_set({
local T = new_set({
hooks = {
pre_case = function()
child.setup()
Expand Down
2 changes: 1 addition & 1 deletion tests/test_base16.lua
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ local minischeme_use_cterm = {
}

-- Output test set ============================================================
T = new_set({
local T = new_set({
hooks = {
pre_case = function()
child.setup()
Expand Down
4 changes: 1 addition & 3 deletions tests/test_basics.lua
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@ local new_set = MiniTest.new_set
-- Helpers with child processes
--stylua: ignore start
local load_module = function(config) child.mini_load('basics', config) end
local unload_module = function() child.mini_unload('basics') end
local reload_module = function(config) unload_module(); load_module(config) end
local set_cursor = function(...) return child.set_cursor(...) end
local get_cursor = function(...) return child.get_cursor(...) end
local set_lines = function(...) return child.set_lines(...) end
Expand All @@ -17,7 +15,7 @@ local type_keys = function(...) return child.type_keys(...) end
--stylua: ignore end

-- Output test set ============================================================
T = new_set({
local T = new_set({
hooks = {
pre_case = child.setup,
post_once = child.stop,
Expand Down
4 changes: 2 additions & 2 deletions tests/test_bracketed.lua
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ end
local test_files = { 'file-a', 'file-b', 'file-c', 'file-d', 'file-e' }

-- Output test set ============================================================
T = new_set({
local T = new_set({
hooks = {
pre_case = function()
child.setup()
Expand Down Expand Up @@ -2905,7 +2905,7 @@ T['yank()'] = new_set()
--- - String. Will be yanked in charwise mode.
--- - Table. First element is array of lines, second - keys used to yank them
--- (assuming Normal mode and cursor being {1, 0}).
---@return table Array of arrays with yank history lines.
---@return ... Array of arrays with yank history lines and its validator.
---@private
local setup_yank = function(...)
local yank_entries = vim.tbl_map(function(x)
Expand Down
2 changes: 1 addition & 1 deletion tests/test_bufremove.lua
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ end

-- Output test set ============================================================
local layout
T = new_set({
local T = new_set({
hooks = {
pre_case = function()
child.setup()
Expand Down
20 changes: 1 addition & 19 deletions tests/test_clue.lua
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ local new_set = MiniTest.new_set
-- Helpers with child processes
--stylua: ignore start
local load_module = function(config) child.mini_load('clue', config) end
local unload_module = function() child.mini_unload('clue') end
local set_cursor = function(...) return child.set_cursor(...) end
local get_cursor = function(...) return child.get_cursor(...) end
local set_lines = function(...) return child.set_lines(...) end
Expand Down Expand Up @@ -166,7 +165,7 @@ end
-- Data =======================================================================

-- Output test set ============================================================
T = new_set({
local T = new_set({
hooks = {
pre_case = function() child.setup() end,
post_once = child.stop,
Expand Down Expand Up @@ -965,23 +964,6 @@ T['gen_clues']['windows()']['respects `opts.submode_resize`'] = function()
local win_init = get_window()
local get_height = function() return child.api.nvim_win_get_height(0) end
local get_width = function() return child.api.nvim_win_get_width(0) end
local validate = function(keys_dims)
-- Set up
set_window(win_init)
type_keys('<C-w>')

-- Test
for _, v in ipairs(keys_dims) do
type_keys(v[1])
eq(child.api.nvim_win_get_height(0), v[2][1])
eq(child.api.nvim_win_get_width(0), v[2][2])
end

-- Clean up
type_keys('<Esc>')
set_window(win_init)
child.cmd('only')
end

-- Width
set_window(win_init)
Expand Down
3 changes: 1 addition & 2 deletions tests/test_colors.lua
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ end
local small_time = 15

-- Output test set ============================================================
T = new_set({
local T = new_set({
hooks = {
pre_case = function()
child.setup()
Expand Down Expand Up @@ -1705,7 +1705,6 @@ T['animate()']['works'] = function()

-- Check slightly after half-way
local validate_after_half = function()
local test_single_hl = nil
eq(
child.lua_get('_G.get_relevant_cs_data()'),
{
Expand Down
2 changes: 1 addition & 1 deletion tests/test_comment.lua
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ end
local example_lines = { 'aa', ' aa', ' aa', '', ' aa', ' aa', 'aa' }

-- Output test set ============================================================
T = new_set({
local T = new_set({
hooks = {
pre_case = function()
child.setup()
Expand Down
2 changes: 1 addition & 1 deletion tests/test_completion.lua
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ end
local test_times = { completion = 100, info = 100, signature = 50 }

-- Output test set ============================================================
T = new_set({
local T = new_set({
hooks = {
pre_case = function()
child.setup()
Expand Down
2 changes: 1 addition & 1 deletion tests/test_cursorword.lua
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ local example_lines = { 'aa', 'aa', 'aaa' }
local test_times = { delay = 100 }

-- Output test set ============================================================
T = new_set({
local T = new_set({
hooks = {
pre_case = function()
child.setup()
Expand Down
2 changes: 1 addition & 1 deletion tests/test_doc.lua
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ local default_section_names = {
--stylua: ignore end

-- Output test set ============================================================
T = new_set({
local T = new_set({
hooks = {
pre_case = function()
child.setup()
Expand Down
6 changes: 2 additions & 4 deletions tests/test_files.lua
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ end

local make_temp_dir = function(name, children)
-- Make temporary directory and make sure it is removed after test is done
local temp_dir = make_test_path('temp')
local temp_dir = make_test_path(name or 'temp')
vim.fn.mkdir(temp_dir, 'p')

MiniTest.finally(function() vim.fn.delete(temp_dir, 'rf') end)
Expand Down Expand Up @@ -165,7 +165,7 @@ local test_fs_entries = {
}

-- Output test set ============================================================
T = new_set({
local T = new_set({
hooks = {
pre_case = function()
child.setup()
Expand Down Expand Up @@ -1239,8 +1239,6 @@ T['trim_left()']['works when no explorer is opened'] = function() expect.no_erro

T['trim_right()'] = new_set()

local trim_right = forward_lua('MiniFiles.trim_right')

T['trim_right()']['works'] = function()
open(make_test_path('nested'))
go_in()
Expand Down
2 changes: 1 addition & 1 deletion tests/test_fuzzy.lua
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ local reload_module = function(config) unload_module(); load_module(config) end
--stylua: ignore end

-- Output test set ============================================================
T = new_set({
local T = new_set({
hooks = {
pre_case = function()
child.setup()
Expand Down
4 changes: 2 additions & 2 deletions tests/test_hipatterns.lua
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ local small_time = 5
local test_lines = { 'abcd abcd', 'Abcd ABCD', 'abcdaabcd' }

-- Output test set ============================================================
T = new_set({
local T = new_set({
hooks = {
pre_case = function()
child.setup()
Expand Down Expand Up @@ -725,7 +725,7 @@ T['get_enabled_buffers()'] = new_set()
T['get_enabled_buffers()']['works'] = function()
local create_buf = function() return child.api.nvim_create_buf(true, false) end
local buf_id_1 = create_buf()
local buf_id_2 = create_buf()
create_buf()
local buf_id_3 = create_buf()
local buf_id_4 = create_buf()

Expand Down
2 changes: 1 addition & 1 deletion tests/test_hues.lua
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ local bg = '#11262d'
local fg = '#c0c8cc'

-- Output test set ============================================================
T = new_set({
local T = new_set({
hooks = {
pre_case = function()
child.setup()
Expand Down
2 changes: 1 addition & 1 deletion tests/test_indentscope.lua
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ local example_lines_nested = { 'aa', ' aa', ' aa', ' aa', ' aa', ' aa', '
local test_times = { delay = 100, animation_step = 20 }

-- Output test set ============================================================
T = new_set({
local T = new_set({
hooks = {
pre_case = function()
child.setup()
Expand Down
2 changes: 1 addition & 1 deletion tests/test_jump.lua
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ local example_lines = {
local test_times = { highlight = 250 }

-- Output test set ============================================================
T = new_set({
local T = new_set({
hooks = {
pre_case = function()
child.setup()
Expand Down
2 changes: 1 addition & 1 deletion tests/test_jump2d.lua
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ local setup_two_windows = function()
end

-- Output test set ============================================================
T = new_set({
local T = new_set({
hooks = {
pre_case = function()
child.setup()
Expand Down
2 changes: 1 addition & 1 deletion tests/test_map.lua
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ end
local get_n_shown_windows = function() return #child.api.nvim_tabpage_list_wins(0) end

-- Output test set
T = new_set({
local T = new_set({
hooks = {
pre_case = function()
child.setup()
Expand Down
2 changes: 1 addition & 1 deletion tests/test_misc.lua
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ local edit = function(x) child.cmd('edit ' .. x) end
--stylua: ignore end

-- Output test set ============================================================
T = new_set({
local T = new_set({
hooks = {
pre_case = function()
child.setup()
Expand Down
2 changes: 1 addition & 1 deletion tests/test_move.lua
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ local validate_line_state = function(lines, cursor)
end

-- Output test set ============================================================
T = new_set({
local T = new_set({
hooks = {
pre_case = function()
child.setup()
Expand Down
2 changes: 1 addition & 1 deletion tests/test_operators.lua
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ local validate_edit1d = function(line_before, col_before, keys, line_after, col_
end

-- Output test set ============================================================
T = new_set({
local T = new_set({
hooks = {
pre_case = function()
child.setup()
Expand Down
2 changes: 1 addition & 1 deletion tests/test_pairs.lua
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,7 @@ local apply_unmap = function(fun_name, args_string)
end

-- Output test set ============================================================
T = new_set({
local T = new_set({
hooks = {
pre_case = function()
child.setup()
Expand Down
2 changes: 1 addition & 1 deletion tests/test_sessions.lua
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ local validate_executed_hook = function(pre_post, action, value)
end

-- Output test set ============================================================
T = new_set({
local T = new_set({
hooks = {
pre_case = function()
child.setup()
Expand Down
2 changes: 1 addition & 1 deletion tests/test_splitjoin.lua
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ local validate_keys = function(lines_before, cursor_before, lines_after, cursor_
end

-- Output test set ============================================================
T = new_set({
local T = new_set({
hooks = {
pre_case = function()
child.setup()
Expand Down
2 changes: 1 addition & 1 deletion tests/test_starter.lua
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ local example_itemstring = '{ '
.. ' }'

-- Output test set ============================================================
T = new_set({
local T = new_set({
hooks = {
pre_case = function()
child.setup()
Expand Down
2 changes: 1 addition & 1 deletion tests/test_statusline.lua
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ end
local unmock_file = function() pcall(vim.fn.delete, mocked_filepath) end

-- Output test set ============================================================
T = new_set({
local T = new_set({
hooks = {
pre_case = function()
child.setup()
Expand Down
2 changes: 1 addition & 1 deletion tests/test_surround.lua
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ local mock_treesitter_builtin = function() child.cmd('source tests/dir-surround/
local mock_treesitter_plugin = function() child.cmd('set rtp+=tests/dir-surround') end

-- Output test set ============================================================
T = new_set({
local T = new_set({
hooks = {
pre_case = function()
child.setup()
Expand Down
2 changes: 1 addition & 1 deletion tests/test_tabline.lua
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ local eval_tabline = function(show_hl, show_action)
end

-- Output test set ============================================================
T = new_set({
local T = new_set({
hooks = {
pre_case = function()
child.setup()
Expand Down
Loading

0 comments on commit 6ccd3f8

Please sign in to comment.