|
CC ?= gcc
|
|
CFLAGS ?= -Wall -Wextra -pedantic -std=c11 -O2
|
|
CFLAGS += -I../src/libtikker/include -I../src/third_party -Iunit
|
|
LDFLAGS := -L../build/lib -ltikker -lsqlite3 -lm
|
|
|
|
UNIT_TESTS := $(wildcard unit/test_*.c)
|
|
UNIT_TARGETS := $(UNIT_TESTS:unit/test_%.c=unit/test_%)
|
|
INTEGRATION_TESTS := $(wildcard integration/test_*.c)
|
|
INTEGRATION_TARGETS := $(INTEGRATION_TESTS:integration/test_%.c=integration/test_%)
|
|
|
|
.PHONY: test unit integration clean help
|
|
|
|
test: unit integration
|
|
@echo "✓ All tests completed"
|
|
|
|
unit: $(UNIT_TARGETS)
|
|
@echo "Running unit tests..."
|
|
@for test in $(UNIT_TARGETS); do \
|
|
if [ -f $$test ]; then \
|
|
$$test || exit 1; \
|
|
fi; \
|
|
done
|
|
@echo "✓ Unit tests passed"
|
|
|
|
integration: $(INTEGRATION_TARGETS)
|
|
@echo "Running integration tests..."
|
|
@for test in $(INTEGRATION_TARGETS); do \
|
|
if [ -f $$test ]; then \
|
|
$$test || exit 1; \
|
|
fi; \
|
|
done
|
|
@echo "✓ Integration tests passed"
|
|
|
|
unit/test_%: unit/test_%.c
|
|
@echo "Building test: $@"
|
|
@$(CC) $(CFLAGS) $< -o $@ $(LDFLAGS)
|
|
|
|
integration/test_%: integration/test_%.c
|
|
@echo "Building integration test: $@"
|
|
@$(CC) $(CFLAGS) $< -o $@ $(LDFLAGS)
|
|
|
|
clean:
|
|
@rm -f unit/test_*
|
|
@rm -f integration/test_*
|
|
@find . -name "*.o" -delete
|
|
@echo "✓ Tests cleaned"
|
|
|
|
help:
|
|
@echo "Test suite targets:"
|
|
@echo " make test - Run all tests"
|
|
@echo " make unit - Run unit tests"
|
|
@echo " make integration - Run integration tests"
|
|
@echo " make clean - Remove test artifacts"
|