add tests

This commit is contained in:
sfja 2026-03-23 19:27:09 +01:00
parent 2db3c32093
commit 452262effd
2 changed files with 17 additions and 0 deletions

View File

@ -41,6 +41,8 @@ sources = \
src/tcp.cpp \ src/tcp.cpp \
src/http.cpp src/http.cpp
tests = \
tests/true.cpp
target=$(build_dir)/backend target=$(build_dir)/backend
@ -53,6 +55,15 @@ $(obj_dir)/%.o: %.cpp
@mkdir -p $(dir $@) @mkdir -p $(dir $@)
$(CXX) $< -c -o $@ -MMD -MP $(CXXFLAGS) $(CXX) $< -c -o $@ -MMD -MP $(CXXFLAGS)
test: $(sources:%.cpp=$(obj_dir)/%.o) run_tests
run_tests: $(tests:tests/%.cpp=$(build_dir)/tests/test_%)
printf "%s\n" $2 | xargs -I % sh -c 'echo "- %..." && ./% && echo "- %: OK" || echo "- %: FAILED" && exit 1'
$(build_dir)/tests/test_%: tests/%.cpp
@mkdir -p $(dir $@)
$(CXX) $< -o $@ -MMD -MP $(CXXFLAGS)
format: format:
$(CLANG_FORMAT) -style=file -i src/* $(CLANG_FORMAT) -style=file -i src/*

6
backend/tests/true.cpp Normal file
View File

@ -0,0 +1,6 @@
#include <cassert>
int main()
{
assert(true);
}