From 33fcbdeef12b2831cff2dc6eee7c5b48e34d0851 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Karel=20Ko=C4=8D=C3=AD?= Date: Thu, 17 Nov 2016 17:57:20 +0100 Subject: Add tests target and some fixes For now only cppcheck is implemented. --- Makefile | 5 +++++ configure | 4 ++++ src/args_parser.c | 2 +- src/utils.c | 1 + tests/tests.mk | 16 ++++++++++++++++ 5 files changed, 27 insertions(+), 1 deletion(-) create mode 100644 tests/tests.mk diff --git a/Makefile b/Makefile index 780c5d4..a0d7c21 100644 --- a/Makefile +++ b/Makefile @@ -48,6 +48,8 @@ help: @echo " docs - Build html documentation" @echo " serve-docs - Start html server with documentation on localhost:8000" @echo " clean-docs - Removes generated documentation" + @echo " tests - Executes all tests" + @echo " help-test - Prints help for all implemented tests" @echo "Some enviroment variables to be defined:" @echo " Q - Define emty to show executed commands" @@ -80,6 +82,9 @@ distclean:: clean clean-docs @echo " CLEAN configuration" $(Q)$(RM) $(O)/.config +# Include test targets +include tests/tests.mk + ## Building targets ## ifeq (,$(filter clean distclean help docs serve-docs clean-docs \ ,$(MAKECMDGOALS))) # Ignore build targets if goal is not building diff --git a/configure b/configure index 6f8044b..61d988c 100755 --- a/configure +++ b/configure @@ -17,6 +17,8 @@ LFLAGS:::T:F INSTALL:install::T:F GZIP:gzip::T:F DOT:dot::T:F +CPPCHECK:cppcheck::T:F +VALGRIND:valgrind::T:F MKDOCS:mkdocs::T:F" ############################################################################ # TODO add options to fine tune installation directories @@ -45,6 +47,8 @@ print_help() { echo " INSTALL Copy files and set attributes." echo " GZIP Compress file." echo " DOT Directed graphs drawing program." + echo " CPPCHECK Tool for static code analysis." + echo " VALGRIND Suite for debugging and profiling programs." echo " MKDOCS Project documentation generator." echo echo "GEML version $GEML_VERSION" diff --git a/src/args_parser.c b/src/args_parser.c index be55e43..0de5ca2 100644 --- a/src/args_parser.c +++ b/src/args_parser.c @@ -26,7 +26,7 @@ #include "io.h" const char *help_text = - "Usage: geml [OPTIONS]... INPUT_FILE\n" + "Usage: geml [OPTION]... INPUT_FILE\n" " General extendable macro language processing tool.\n" "\n" "Options:\n" diff --git a/src/utils.c b/src/utils.c index c545961..c52ed2f 100644 --- a/src/utils.c +++ b/src/utils.c @@ -62,6 +62,7 @@ void print_message(const char *file, const int line, enum Verbosity level, const va_list args; va_start(args, msg); vfprintf(stderr, msg, args); + va_end(args); fputs("\n", stderr); } diff --git a/tests/tests.mk b/tests/tests.mk new file mode 100644 index 0000000..33bc1e4 --- /dev/null +++ b/tests/tests.mk @@ -0,0 +1,16 @@ +# vim:ts=4:sw=4:noexpandtab + +.PHONY: help-test +help-test:: + @echo "General extendable macro language make test targets:" + @echo " tests - Executes all tests" + @echo " help-test - Prits help for all implemented tests" + @echo " cppcheck - Executes cppcheck on all compilled sources" + +.PHONY: tests +tests: cppcheck + +.PHONY: +cppcheck: $(CSRC) + @echo " CPPCHECK" + $(Q)$(CPPCHECK) --enable=all --std=c11 --error-exitcode=1 $(CSRC) -- cgit v1.2.3