Home | History | Annotate | Line # | Download | only in unit-tests
Makefile revision 1.11.2.1
      1 # $Id: Makefile,v 1.11.2.1 2004/05/10 15:23:47 tron Exp $
      2 #
      3 # Unit tests for make(1)
      4 # The main targets are:
      5 # 
      6 # all:	run all the tests
      7 # test:	run 'all', capture output and compare to expected results
      8 # accept: move generated output to expected results
      9 #
     10 # Adding a test case.  
     11 # Each feature should get its own set of tests in its own suitably
     12 # named makefile which should be added to SUBFILES to hook it in.
     13 # 
     14 
     15 .MAIN: all
     16 
     17 UNIT_TESTS:= ${.PARSEDIR}
     18 
     19 # Simple sub-makefiles - we run them as a black box
     20 # keep the list sorted.
     21 SUBFILES= \
     22 	cond1 \
     23 	modmatch \
     24 	modts \
     25 	modword \
     26 	ternary \
     27 	varcmd
     28 
     29 all: ${SUBFILES}
     30 
     31 # the tests are actually done with sub-makes.
     32 .PHONY: ${SUBFILES}
     33 ${SUBFILES}:
     34 	@${.MAKE} -k -f ${UNIT_TESTS}/$@
     35 
     36 clean:
     37 	rm -f *.out *.fail *.core
     38 
     39 .include <bsd.obj.mk>
     40 
     41 TEST_MAKE?= ${MAKE}
     42 
     43 # The driver.
     44 # We always pretend .MAKE was called 'make' 
     45 # and strip ${.CURDIR}/ from the output
     46 # so the results can be compared.
     47 test:
     48 	@echo "${TEST_MAKE} -f ${MAKEFILE} > ${.TARGET}.out 2>&1"
     49 	@cd ${.OBJDIR} && ${TEST_MAKE} -f ${MAKEFILE} 2>&1 | \
     50 	sed -e 's,^${TEST_MAKE:T}:,make:,' -e 's,${.CURDIR}/,,g' > ${.TARGET}.out || { \
     51 	tail ${.TARGET}.out; mv ${.TARGET}.out ${.TARGET}.fail; exit 1; }
     52 	diff -u ${UNIT_TESTS}/${.TARGET}.exp ${.TARGET}.out
     53 
     54 accept:
     55 	mv test.out ${.CURDIR}/test.exp
     56 
     57