From: j8takagi Date: Tue, 30 Nov 2010 15:15:23 +0000 (+0900) Subject: テスト用のMakefileを整理 X-Git-Tag: v0.1p15~23 X-Git-Url: https://j8takagi.net/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=80a7b6329c3177a0e4050d88406b0bd12fa66ac4;p=YACASL2.git テスト用のMakefileを整理 --- diff --git a/test/Makefile.TESTGROUPS.mk b/test/Makefile.TESTGROUPS.mk index 6e32f36..37ec308 100644 --- a/test/Makefile.TESTGROUPS.mk +++ b/test/Makefile.TESTGROUPS.mk @@ -11,16 +11,20 @@ TESTS = `ls | grep "^[^A-Z].*"` LOGFILE = Test.log .PHONY: all check checkeach report clean cleanall prepare create + check: checkeach report + checkeach: @rm -f $(LOGFILE) @for target in $(TESTS); do \ $(MAKE) check -C $$target; \ done + $(LOGFILE): @for target in $(TESTS); do \ cat <$$target/report.txt >>$(LOGFILE) || echo $$target ": no report" >>$(LOGFILE); \ done + report: $(LOGFILE) @success=`grep "Success" $(LOGFILE) | wc -l`; \ all=`cat $(LOGFILE) | wc -l`; \ @@ -28,14 +32,18 @@ report: $(LOGFILE) if test $$success -eq $$all; then \ echo "$(GROUPNAME): All tests are succeded."; \ fi + clean: @for target in $(TESTS); do $(MAKE) clean -C $$target; done @rm -f $(LOGFILE) + cleanall: @for target in $(TESTS); do $(MAKE) cleanall -C $$target; done @rm -f $(LOGFILE) + prepare: @for target in $(TESTS) ; do $(MAKE) prepare -C $$target ; done + create: ifndef UNITNAME @echo "no test created. set UNITNAME" diff --git a/test/TEST.mk b/test/TEST.mk index dc64dcb..753f6c0 100644 --- a/test/TEST.mk +++ b/test/TEST.mk @@ -14,20 +14,28 @@ DIFF_FILE = diff.txt REPORT_FILE = report.txt TEST0_FILE = 0.txt TEST1_FILE = 1.txt -.PHPNY: check prepare clean cleanall + +.PHONY: check prepare clean cleanall + check: clean $(REPORT_FILE) + prepare: cleanall $(TEST0_FILE) + clean: @rm -f $(TEST1_FILE) $(DIFF_FILE) $(REPORT_FILE) $(ERR_FILE) + cleanall: clean @rm -f $(TEST0_FILE) + ifndef MAINTARGET_OVERRIDE $(TEST0_FILE) $(TEST1_FILE): @echo $(CMD) >$@; \ $(CMD) >>$@ 2>$(ERR_FILE); \ if test -s $(ERR_FILE); then cat $(ERR_FILE) >>$@; else rm -f $(ERR_FILE); fi endif + $(DIFF_FILE): $(TEST1_FILE) @-diff -c $(TEST0_FILE) $(TEST1_FILE) >$@ 2>&1 + $(REPORT_FILE): $(DIFF_FILE) @if test ! -s $^; then echo "$(UNITNAME): Test Success $(DATE)" >>$@; rm -f $^; else echo "$(UNITNAME): Test Failure $(DATE)" >>$@; fi;