Home | History | Annotate | Line # | Download | only in unit-tests
Makefile revision 1.7
      1  1.7  sjg # $Id: Makefile,v 1.7 2003/08/08 06:42:38 sjg Exp $
      2  1.1  sjg #
      3  1.1  sjg # Unit tests for make(1)
      4  1.1  sjg # The main targets are:
      5  1.1  sjg # 
      6  1.1  sjg # all:	run all the tests
      7  1.1  sjg # test:	run 'all', capture output and compare to expected results
      8  1.1  sjg # accept: move generated output to expected results
      9  1.1  sjg #
     10  1.1  sjg # Adding a test case.  
     11  1.1  sjg # Each feature should get its own set of tests which should be hooked
     12  1.1  sjg # into the 'all' target.
     13  1.1  sjg # 
     14  1.1  sjg 
     15  1.1  sjg .MAIN: all
     16  1.1  sjg 
     17  1.7  sjg UNIT_TESTS:= ${.PARSEDIR}
     18  1.7  sjg 
     19  1.5  sjg all: mod-ts varcmd
     20  1.1  sjg 
     21  1.1  sjg LIST= one two three
     22  1.1  sjg LIST+= four five six
     23  1.1  sjg 
     24  1.1  sjg FU_mod-ts = a / b / cool
     25  1.1  sjg 
     26  1.1  sjg mod-ts:
     27  1.3  sjg 	@echo 'LIST="${LIST}"'
     28  1.3  sjg 	@echo 'LIST:ts,="${LIST:ts,}"'
     29  1.3  sjg 	@echo 'LIST:ts/:tu="${LIST:ts/:tu}"'
     30  1.3  sjg 	@echo 'LIST:tu:ts/="${LIST:tu:ts/}"'
     31  1.3  sjg 	@echo 'LIST:ts:="${LIST:ts:}"'
     32  1.3  sjg 	@echo 'LIST:ts="${LIST:ts}"'
     33  1.3  sjg 	@echo 'LIST:ts:S/two/2/="${LIST:ts:S/two/2/}"'
     34  1.3  sjg 	@echo 'LIST:S/two/2/:ts="${LIST:S/two/2/:ts}"'
     35  1.3  sjg 	@echo 'LIST:ts/:S/two/2/="${LIST:ts/:S/two/2/}"'
     36  1.4  sjg 	@echo "Pretend the '/' in '/n' etc. below are back-slashes."
     37  1.4  sjg 	@echo 'LIST:ts/n="${LIST:ts\n}"'
     38  1.4  sjg 	@echo 'LIST:ts/t="${LIST:ts\t}"'
     39  1.4  sjg 	@echo 'LIST:ts/012:tu="${LIST:ts\012:tu}"'
     40  1.3  sjg 	@echo 'LIST:tx="${LIST:tx}"'
     41  1.6  sjg 	@echo 'LIST:ts/x:tu="${LIST:ts\x:tu}"'
     42  1.3  sjg 	@echo 'FU_$@="${FU_${@:ts}:ts}"'
     43  1.3  sjg 	@echo 'FU_$@:ts:T="${FU_${@:ts}:ts:T}" == cool?'
     44  1.1  sjg 
     45  1.5  sjg .PHONY: varcmd
     46  1.5  sjg varcmd:
     47  1.7  sjg 	@${.MAKE} -f ${UNIT_TESTS}/varcmd
     48  1.5  sjg 
     49  1.1  sjg clean:
     50  1.1  sjg 	rm -f *.out *.fail *.core
     51  1.1  sjg 
     52  1.1  sjg .include <bsd.obj.mk>
     53  1.1  sjg 
     54  1.1  sjg TEST_MAKE?= ${MAKE}
     55  1.1  sjg 
     56  1.1  sjg # here is the driver
     57  1.1  sjg test:
     58  1.1  sjg 	@echo "${TEST_MAKE} -f ${MAKEFILE} > ${.TARGET}.out 2>&1"
     59  1.6  sjg 	@cd ${.OBJDIR} && ${TEST_MAKE} -f ${MAKEFILE} 2>&1 | \
     60  1.2  sjg 	sed 's,^${TEST_MAKE:T}:,make:,' > ${.TARGET}.out || { \
     61  1.1  sjg 	tail ${.TARGET}.out; mv ${.TARGET}.out ${.TARGET}.fail; exit 1; }
     62  1.7  sjg 	diff -u ${UNIT_TESTS}/${.TARGET}.exp ${.TARGET}.out
     63  1.1  sjg 
     64  1.1  sjg accept:
     65  1.1  sjg 	mv test.out ${.CURDIR}/test.exp
     66  1.1  sjg 
     67