Basic Neovim GUI Test Framework
There's probably a better way to do this but I couldn't find it.
This gets around seeming async issues by feeding a table with a list of function to run into a set of two functions that alternate back and forth between themselves with a delay between calling the functions to test.
This needs editing
Code
grimoire = require('grimoire')
local tests_to_run = {}
local log_file_path = 'testing.log'
local current_delay = 500
-- hr
local
local log_file = io.open(log_file_path, "a")
io.output(log_file)
io.write("OK: ")
io.close(log_file)
end
local
local log_file = io.open(log_file_path, "a")
io.output(log_file)
io.write("FAIL: ")
io.close(log_file)
end
local
local log_file = io.open(log_file_path, "a")
io.output(log_file)
io.write(message.."\n")
io.close(log_file)
end
-- TODO: Reset the timer to the default after
-- each adjustment
if #tests_to_run > 0 then
function_to_run = table.remove(tests_to_run, 1)
_G[function_to_run]()
if #tests_to_run > 0 then
vim.fn.timer_start(current_delay, tock)
end
end
end
if #tests_to_run > 0 then
function_to_run = table.remove(tests_to_run, 1)
_G[function_to_run]()
if #tests_to_run > 0 then
vim.fn.timer_start(current_delay, tick)
end
end
end
-- hr
if grimoire.state.is_active == false then
p()
else
f()
end
log("Pre-launch")
grimoire.grimoire()
if grimoire.state.is_active == true then
p()
else
f()
end
log("Initial state")
end
window_list = vim.api.nvim_list_wins()
if #window_list == 4 then
p()
else
f()
end
log("Initial window count")
end
vim.api.nvim_feedkeys("apple orange", "i", true)
current_delay = 2400
end
grimoire.grimoire()
window_list = vim.api.nvim_list_wins()
if #window_list == 1 then
p()
else
f()
end
log("Windows closed")
end
local
log('---------')
tests_to_run = {
'verify_initial_state',
'verify_open_windows',
'verify_current_search',
'verify_closed_windows',
}
tick()
end
return {
runner = runner
}