-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
120 lines (101 loc) · 4.3 KB
/
Copy pathMakefile
File metadata and controls
120 lines (101 loc) · 4.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
.PHONY: test test-stress test-unit test-e2e test-e2e-sequential test-file deps lint dev test-repo dev-repo setup-gh demo demo-basics demo-advanced demo-forge
# Run plugin in development mode
dev:
nvim -u dev/init.lua
link:
rm -f ~/dev/nvim/gitlad.nvim
ln -s $(CURDIR) ~/dev/nvim/gitlad.nvim
# Create a test repository for manual testing
test-repo:
@./scripts/create-test-repo.sh
# Create test repo and open it with the plugin
dev-repo: test-repo
cd /tmp/gitlad-test-repo && nvim -u $(CURDIR)/dev/init.lua
# Run all tests (unit sequential + e2e parallel)
test: test-unit test-e2e
# Run full suite 3 times with high parallelism (for catching flaky tests)
test-stress: deps
@for i in 1 2 3; do \
echo "=== Stress run $$i (JOBS=32) ==="; \
$(MAKE) test JOBS=32 || exit 1; \
done
@echo "All stress runs passed!"
# Run only unit tests
test-unit: deps
nvim --headless -u tests/minimal_init.lua -c "lua require('mini.test').setup(); local ok, err = pcall(MiniTest.run, {collect = {find_files = function() return vim.fn.glob('tests/unit/*.lua', false, true) end}}); if not ok then print('Error: ' .. err); vim.cmd('cq!') end; local has_fail = false; for _, c in ipairs(MiniTest.current.all_cases or {}) do if c.exec and c.exec.state == 'Fail' then has_fail = true; break end end; if has_fail then vim.cmd('cq!') end" -c "qa!"
# Run only e2e tests (parallel by default, requires GNU parallel)
# Use JOBS=N to control parallelism (default: min(16, CPU count))
test-e2e: deps
@if command -v parallel > /dev/null; then \
./scripts/run-tests-parallel.sh --e2e-only; \
else \
echo "GNU parallel not found, running sequentially..."; \
$(MAKE) test-e2e-sequential; \
fi
# Run e2e tests sequentially (useful for debugging)
test-e2e-sequential: deps
nvim --headless -u tests/minimal_init.lua -c "lua require('mini.test').setup(); local ok, err = pcall(MiniTest.run, {collect = {find_files = function() return vim.fn.glob('tests/e2e/*.lua', false, true) end}}); if not ok then print('Error: ' .. err); vim.cmd('cq!') end; local has_fail = false; for _, c in ipairs(MiniTest.current.all_cases or {}) do if c.exec and c.exec.state == 'Fail' then has_fail = true; break end end; if has_fail then vim.cmd('cq!') end" -c "qa!"
# Run a single test file (useful for debugging)
# Usage: make test-file FILE=tests/e2e/test_rebase.lua
test-file: deps
@if [ -z "$(FILE)" ]; then echo "Usage: make test-file FILE=tests/e2e/test_foo.lua"; exit 1; fi
nvim --headless -u tests/minimal_init.lua -c "lua require('mini.test').setup(); MiniTest.run_file('$(FILE)')" -c "qa!"
# Install test dependencies
deps:
@echo "Checking for mini.nvim..."
@if [ ! -d "$(HOME)/.local/share/nvim/site/pack/deps/start/mini.nvim" ]; then \
echo "Installing mini.nvim..."; \
mkdir -p $(HOME)/.local/share/nvim/site/pack/deps/start; \
git clone --depth 1 https://github.com/echasnovski/mini.nvim \
$(HOME)/.local/share/nvim/site/pack/deps/start/mini.nvim; \
else \
echo "mini.nvim already installed"; \
fi
# Lint with stylua (if installed)
lint:
@if command -v stylua > /dev/null; then \
stylua --check lua/ tests/; \
else \
echo "stylua not installed, skipping lint"; \
fi
# Format with stylua
format:
@if command -v stylua > /dev/null; then \
stylua lua/ tests/; \
else \
echo "stylua not installed"; \
fi
# Record all demos (basics, advanced, forge)
demo:
./scripts/record-demo.sh
# Record individual demos
demo-basics:
./scripts/record-demo.sh basics
demo-advanced:
./scripts/record-demo.sh advanced
demo-forge:
./scripts/record-demo.sh forge
# Clean test artifacts
clean:
rm -rf .tests/
# Setup GitHub account for direnv
setup-gh:
@if [ -f .envrc ]; then \
echo ".envrc already exists. Remove it first if you want to reconfigure."; \
exit 1; \
fi
@echo "Available GitHub accounts:"
@gh auth status 2>&1 | grep "Logged in" | sed 's/.*account / - /' | sed 's/ (.*//'
@echo ""
@read -p "Enter the GitHub account name to use for this project: " account; \
if [ -z "$$account" ]; then \
echo "Error: Account name cannot be empty"; \
exit 1; \
fi; \
if ! gh auth token --user "$$account" > /dev/null 2>&1; then \
echo "Error: Account '$$account' not found. Run 'gh auth login' first."; \
exit 1; \
fi; \
echo "export GH_TOKEN=\$$(gh auth token --user $$account)" > .envrc; \
echo "Created .envrc for account '$$account'"; \
echo "Run 'direnv allow' to activate"