瀏覽代碼

test/unit: Makefile option to run individual test unit

- head parameter swapped to work on bsd/darwin
Daniel-Constantin Mierla 11 年之前
父節點
當前提交
84d00119fa
共有 1 個文件被更改,包括 21 次插入1 次删除
  1. 21 1
      test/unit/Makefile

+ 21 - 1
test/unit/Makefile

@@ -1,8 +1,11 @@
+# Makefile for running test unit
+#
+
 all:
 	-@for FILE in $(wildcard *.sh) ; do \
 		if [ -f $$FILE ] ; then \
 			if [ -x $$FILE ] ; then \
-				echo "run test `basename $$FILE .sh`:" `head "$$FILE" -n 2 | 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 \
@@ -11,3 +14,20 @@ all:
 			fi ; \
 		fi ; \
 	done ;
+
+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 ; \
+		fi ; \
+	else \
+		echo "Test unit file $(UNIT): not found" ; \
+	fi ;
+