feat: implement dynamic test generation and resolve pre-commit conflicts

- Replace static test fixture files with dynamic test generation
- Implement comprehensive test suite with unit, integration, and golden master tests
- Add vim API mocking for standalone Lua test execution
- Fix pre-commit hook interference by eliminating external fixture files
- Add StyLua formatting for consistent Lua code style
- Enhance ShellSpec formatting with improved HEREDOC and comment handling
- Update documentation with new test architecture details

This resolves issues where pre-commit hooks (shfmt, end-of-file-fixer) were
modifying test fixture files and breaking golden master tests. The new dynamic
approach generates test data programmatically, making tests immune to formatting
tools while maintaining comprehensive coverage.
This commit is contained in:
2025-09-09 23:11:47 +03:00
parent ce620cd035
commit b54d6ed365
10 changed files with 1079 additions and 69 deletions

View File

@@ -10,11 +10,13 @@ local augroup = vim.api.nvim_create_augroup("ShellSpec", { clear = true })
local function setup_buffer(bufnr)
-- Set buffer options
vim.api.nvim_set_option_value("commentstring", "# %s", { buf = bufnr })
vim.api.nvim_set_option_value("foldmethod", "indent", { buf = bufnr })
vim.api.nvim_set_option_value("shiftwidth", config.get("indent_size"), { buf = bufnr })
vim.api.nvim_set_option_value("tabstop", config.get("indent_size"), { buf = bufnr })
vim.api.nvim_set_option_value("expandtab", config.get("use_spaces"), { buf = bufnr })
-- Set window-local options (foldmethod is window-local)
vim.api.nvim_set_option_value("foldmethod", "indent", { win = 0 })
-- Buffer-local commands
vim.api.nvim_buf_create_user_command(bufnr, "ShellSpecFormat", function()
format.format_buffer(bufnr)
@@ -35,6 +37,18 @@ end
-- Create all autocommands
function M.setup()
-- Create global commands first
vim.api.nvim_create_user_command("ShellSpecFormat", function()
format.format_buffer()
end, { desc = "Format current ShellSpec buffer" })
vim.api.nvim_create_user_command("ShellSpecFormatRange", function(cmd_opts)
format.format_selection(0, cmd_opts.line1, cmd_opts.line2)
end, {
range = true,
desc = "Format ShellSpec selection",
})
-- FileType detection and setup
vim.api.nvim_create_autocmd("FileType", {
group = augroup,