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

@@ -11,14 +11,25 @@ let g:loaded_shellspec = 1
" Detect Neovim and use appropriate implementation
if has('nvim-0.7')
" Use modern Neovim Lua implementation
lua require('shellspec.autocmds').setup()
" Initialize with error handling
lua << EOF
local ok, err = pcall(function()
-- Initialize configuration with defaults
require('shellspec.config').setup()
" Create commands that delegate to Lua
command! ShellSpecFormat lua require('shellspec').format_buffer()
command! -range ShellSpecFormatRange lua require('shellspec').format_selection(0, <line1>, <line2>)
-- Setup autocommands and commands
require('shellspec.autocmds').setup()
" Optional: Auto-format on save (handled in Lua)
" This is now managed by the Lua autocmds module based on configuration
-- Debug message
if vim.g.shellspec_debug then
vim.notify('ShellSpec Neovim: Loaded successfully', vim.log.levels.INFO)
end
end)
if not ok then
vim.notify('ShellSpec Neovim: Failed to load - ' .. tostring(err), vim.log.levels.ERROR)
end
EOF
else
" Fallback to VimScript implementation for older Vim