-- Set up Lua path package.path = "./lua/?.lua;./lua/?/init.lua;" .. package.path -- Extend existing vim global if not _G.vim then _G.vim = {} end local vim = _G.vim -- Mock missing vim functions if they don't exist vim.fn = vim.fn or {} vim.fn.stdpath = vim.fn.stdpath or function(type) return "/tmp/notex_test" end vim.fn.getpid = vim.fn.getpid or function() return 12345 end vim.loop = vim.loop or {} vim.loop.fs_stat = vim.loop.fs_stat or function(path) return {type = "file", size = 100} end vim.loop.timer_start = vim.loop.timer_start or function(delay, callback) return 1 end vim.loop.timer_stop = vim.loop.timer_stop or function(timer_id) -- Mock timer stop end vim.uv = vim.uv or {} vim.uv.new_timer = vim.uv.new_timer or function() return { start = function() end, stop = function() end, close = function() end } end vim.uv.hrtime = vim.uv.hrtime or function() return os.clock() * 1e9 end vim.trim = vim.trim or function(str) return str:match("^%s*(.-)%s*$") end vim.split = vim.split or function(str, sep) local fields = {} local pattern = string.format("([^%s]+)", sep) str:gsub(pattern, function(c) fields[#fields + 1] = c end) return fields end vim.tbl_contains = vim.tbl_contains or function(t, val) for _, v in ipairs(t) do if v == val then return true end end return false end -- Add missing API functions vim.api = vim.api or {} vim.api.nvim_buf_get_lines = vim.api.nvim_buf_get_lines or function() return {} end vim.api.nvim_buf_set_lines = vim.api.nvim_buf_set_lines or function() end vim.api.nvim_create_buf = vim.api.nvim_create_buf or function() return 1 end vim.g = vim.g or {} vim.b = vim.b or {} vim.o = vim.o or {} vim.bo = vim.bo or {} vim.wo = vim.wo or {} -- Mock scheduler vim.schedule = vim.schedule or function(fn) fn() end vim.defer_fn = vim.defer_fn or function(fn, delay) fn() end -- Run busted with command line args local busted = require('busted') local args = arg or {} if #args == 0 then args = {'tests/', '--verbose'} end busted.run(args)