notex.nvim/test_runner.lua

60 lines
1.3 KiB
Lua
Raw Normal View History

2025-10-05 20:23:47 -04:00
#!/bin/bash
exec nvim --headless "$0" "$@"
-- Set up Lua path
package.path = "./lua/?.lua;./lua/?/init.lua;" .. package.path
-- Mock minimal vim global for testing
_G.vim = {
fn = {
stdpath = function(type)
return "/tmp/notex_test"
end,
getpid = function()
return 12345
end,
},
loop = {
fs_stat = function(path)
-- Mock file stat
return {type = "file", size = 100}
end,
timer_start = function(delay, callback)
return 1 -- mock timer id
end,
timer_stop = function(timer_id)
-- Mock timer stop
end,
},
uv = {
new_timer = function()
return {
start = function() end,
stop = function() end,
close = function() end
}
end,
hrtime = function()
return os.clock() * 1e9
end,
},
trim = function(str)
return str:match("^%s*(.-)%s*$")
end,
split = function(str, sep)
local fields = {}
local pattern = string.format("([^%s]+)", sep)
str:gsub(pattern, function(c) fields[#fields + 1] = c end)
return fields
end,
tbl_contains = function(t, val)
for _, v in ipairs(t) do
if v == val then return true end
end
return false
end,
}
-- Run busted with command line args
local busted = require('busted')
busted.run(arg)