-
Notifications
You must be signed in to change notification settings - Fork 203
Expand file tree
/
Copy pathMakefile
More file actions
60 lines (52 loc) · 2.02 KB
/
Copy pathMakefile
File metadata and controls
60 lines (52 loc) · 2.02 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
.PHONY: check format test test-cov clean help
# Default target
all: format check test
# Detect if the required dev tools are already available; otherwise run via Nix.
ifeq (,$(shell command -v busted >/dev/null 2>&1 && command -v luacheck >/dev/null 2>&1 && echo ok))
NIX_PREFIX := nix develop .\#ci -c
else
NIX_PREFIX :=
endif
# Check for syntax errors
check:
@echo "Checking Lua files for syntax errors..."
$(NIX_PREFIX) find lua -name "*.lua" -type f -exec lua -e "assert(loadfile('{}'))" \;
@echo "Running luacheck..."
$(NIX_PREFIX) luacheck lua/ tests/ --no-unused-args --no-max-line-length
# Format all files
format:
nix fmt
# Run tests (fast, no coverage)
test:
@echo "Running all tests (no coverage)..."
@TEST_FILES=$$(find tests -type f \( -name "*_test.lua" -o -name "*_spec.lua" \) | sort); \
if [ -n "$$TEST_FILES" ]; then \
$(NIX_PREFIX) sh -c 'export LUA_PATH="./lua/?.lua;./lua/?/init.lua;./?.lua;./?/init.lua;$$LUA_PATH"; busted -v "$$@"' -- $$TEST_FILES; \
else \
echo "No test files found"; \
fi
# Run tests with coverage
# (Generates luacov.stats.out and luacov.report.out)
test-cov:
@echo "Running all tests with coverage..."
@TEST_FILES=$$(find tests -type f \( -name "*_test.lua" -o -name "*_spec.lua" \) | sort); \
if [ -n "$$TEST_FILES" ]; then \
$(NIX_PREFIX) sh -c 'export LUA_PATH="./lua/?.lua;./lua/?/init.lua;./?.lua;./?/init.lua;$$LUA_PATH"; busted --coverage -v "$$@"' -- $$TEST_FILES; \
$(NIX_PREFIX) luacov; \
else \
echo "No test files found"; \
fi
# Clean generated files
clean:
@echo "Cleaning generated files..."
@rm -f luacov.report.out luacov.stats.out
@rm -f lcov.info tests/lcov.info
# Print available commands
help:
@echo "Available commands:"
@echo " make check - Check for syntax errors"
@echo " make format - Format all files (uses nix fmt or stylua)"
@echo " make test - Run tests (fast, no coverage)"
@echo " make test-cov - Run tests with coverage (luacov)"
@echo " make clean - Clean generated files"
@echo " make help - Print this help message"