The words Under construction in black text on a yellow background with diagonal black stipes surrounding it
I'm in the process of moving my site. It's still a work in progress. Please excuse the mess and broken links.

Basic Neovim GUI Test Framework

TODO: Pull subtitle into page object

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_start_default_section code_end_default_section

Debugging Stuff

I'm moving stuff around right now. All this below is helping me figure out where to put stuff

        -- title

Basic Neovim GUI Test Framework

-- p

There's probably a better way to do this but I couldn't find it.

-- p

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.

-- p

This needs editing

-- code/
-- lua

grimoire = require('grimoire')

local tests_to_run = {}
local log_file_path = 'testing.log'
local current_delay = 500

-- hr

local function p()
    local log_file = io.open(log_file_path, "a")
    io.output(log_file)
    io.write("OK: ")
    io.close(log_file)
end

local function f()
    local log_file = io.open(log_file_path, "a")
    io.output(log_file)
    io.write("FAIL: ")
    io.close(log_file)
end

local function log(message)
    local log_file = io.open(log_file_path, "a")
    io.output(log_file)
    io.write(message.."\n")
    io.close(log_file)
end

function tick()
    -- 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

function tock()
    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

function verify_initial_state() 
    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

function verify_open_windows()
    window_list = vim.api.nvim_list_wins()
    if #window_list == 4 then
        p()
    else
        f()
    end
    log("Initial window count")
end

function verify_current_search()
    vim.api.nvim_feedkeys("apple orange", "i", true)
    current_delay = 2400
end

function verify_closed_windows()
    grimoire.grimoire()
    window_list = vim.api.nvim_list_wins()
    if #window_list == 1 then
        p()
    else
        f()
    end
    log("Windows closed")
end

local function runner() 
    log('---------')
    tests_to_run = {
        'verify_initial_state',
        'verify_open_windows',
        'verify_current_search',
        'verify_closed_windows',
    }
    tick()
end 

return {
    runner = runner
}

-- /code


-- categories
-- Miscellaneous

-- metadata
-- date: 2021-07-03 21:40:48
-- id: 20eoffgx
-- status: scratch
-- type: post
-- SCRUBBED_NEO: false
-- site: aws