diff --git a/backend/Makefile b/backend/Makefile index 609f9ce..5202839 100644 --- a/backend/Makefile +++ b/backend/Makefile @@ -41,6 +41,8 @@ sources = \ src/tcp.cpp \ src/http.cpp +tests = \ + tests/true.cpp target=$(build_dir)/backend @@ -53,6 +55,15 @@ $(obj_dir)/%.o: %.cpp @mkdir -p $(dir $@) $(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: $(CLANG_FORMAT) -style=file -i src/* diff --git a/backend/tests/true.cpp b/backend/tests/true.cpp new file mode 100644 index 0000000..2a1024a --- /dev/null +++ b/backend/tests/true.cpp @@ -0,0 +1,6 @@ +#include + +int main() +{ + assert(true); +}