Source

trac-dvbcronrecording-plugin / GNUmakefile

Diff from to

File GNUmakefile

 check:
 	PYTHONPATH=src \
 	python src/tests/computer_test.py -vv $(CHECK)
-test_%:
-	@ func1=`grep "def $@" src/tests/computer_test.py \
+test_%:        # run a single unittest by giving the function name
+	@ for filename in src/tests/*_test.py ; do : \
+	;  class=`basename $$filename .py` \
+	;  func1=`grep "def $@" $$filename \
 	    | sed -e "s/.*def  *//" -e "s/[(].*//" -e q` \
-	; func2=`grep "def $@" src/tests/computer_tests.py \
-	    | sed -e "s/.*def  *//" -e "s/[(].*//" -e q` \
-	; if test -n "$$func1" \
-	; then echo $(MAKE) check CHECK=DvbComputerTests.$$func1 \
-	;           $(MAKE) check CHECK=DvbComputerTests.$$func1 \
-	; elif test -n "$$func2" \
-	; then echo $(MAKE) checks CHECK=DvbGeneratedTests.$$func2 \
-	;           $(MAKE) checks CHECK=DvbGeneratedTests.$$func2 \
-	; else echo "unknown $@"; exit 1 \
+	;  test -n "$$func1" && break \
+	; done \
+	; if test -n "$check" ; then : \
+	;   echo "PYTHONPATH=src  \\" \
+	;   echo "python $$filename $$class.$$func1" \
+	;   echo "" \
+	;         PYTHONPATH=src \
+	          python $$filename "$$class.$$func1" \
+	; else : \
+	    echo "not found $@ in src/tests"; exit 1 \
 	; fi
+testlist:      # show available unittest function names (for test_%)
+	@ for filename in src/tests/*_test.py ; do : \
+	;  class=`basename $$filename .py` \
+	;  echo "$$class:" \
+	;  cat $$filename \
+	     | sed -e "/^ *def test_/!d" -e "s/.*def  *//" -e "s/[(].*//" \
+	           -e "s/^/  /" \
+	; done 
+help:          # shows this help
+	@ cat $(MAKEFILE_LIST) | sed -e "/^[.a-z][-a-z0-9 _%]*:/!d" -e "s|: |:        |"
 
 genchecks:
 	PYTHONPATH=src \