Module: kamailio Branch: master Commit: 52c766bf3c54402cf403a58188952968a8520b68 URL: https://github.com/kamailio/kamailio/commit/52c766bf3c54402cf403a58188952968...
Author: Daniel-Constantin Mierla miconda@gmail.com Committer: Daniel-Constantin Mierla miconda@gmail.com Date: 2017-11-19T08:54:25+01:00
test/unit: print same messages when running all or individual unit tests
- some explanatory comments in Makefile
---
Modified: test/unit/Makefile
---
Diff: https://github.com/kamailio/kamailio/commit/52c766bf3c54402cf403a58188952968... Patch: https://github.com/kamailio/kamailio/commit/52c766bf3c54402cf403a58188952968...
---
diff --git a/test/unit/Makefile b/test/unit/Makefile index 83b3dba999..00c2a47c2e 100644 --- a/test/unit/Makefile +++ b/test/unit/Makefile @@ -4,32 +4,37 @@ TESTS_FILES ?= $(wildcard *.sh) TESTS_EXCLUDE ?= TESTS ?= $(filter-out $(patsubst %,%.sh,$(TESTS_EXCLUDE)), $(TESTS_FILES))
+# run all tests all: @for FILE in $(TESTS) ; do \ if [ -f $$FILE ] ; then \ if [ -x $$FILE ] ; then \ - echo "run test `basename $$FILE .sh`:" `head -n 2 "$$FILE" | tail -n 1 | cut -c 3-` ; \ + echo "Run test `basename $$FILE .sh`:" `head -n 2 "$$FILE" | tail -n 1 | cut -c 3-` ; \ ./$$FILE ; \ ret=$$? ; \ - if [ ! "$$ret" -eq 0 ] ; then \ - echo "failed" ; RES=1;\ - fi ; \ + if [ ! "$$ret" -eq 0 ] ; then \ + echo "Test unit file $$FILE: failed" ; \ + else \ + echo "Test unit file $$FILE: ok" ; \ + fi ; \ fi ; \ fi ; \ done ; \ exit $$RES;
+# run one test specified in variable UNIT +# example: make UNIT=1.sh run run: -@if [ -f $(UNIT) ] ; then \ if [ -x $(UNIT) ] ; then \ echo "Run test `basename $(UNIT) .sh`:" `head -n 2 "$(UNIT)" | tail -n 1 | cut -c 3-` ; \ ./$(UNIT) ; \ ret=$$? ; \ - if [ ! "$$ret" -eq 0 ] ; then \ - echo "Test unit file $(UNIT): failed" ; \ - else \ - echo "Test unit file $(UNIT): ok" ; \ - fi ; \ + if [ ! "$$ret" -eq 0 ] ; then \ + echo "Test unit file $(UNIT): failed" ; \ + else \ + echo "Test unit file $(UNIT): ok" ; \ + fi ; \ fi ; \ else \ echo "Test unit file $(UNIT): not found" ; \