Home | History | Annotate | Line # | Download | only in unit-tests
Makefile revision 1.11
      1  1.11  sjg # $Id: Makefile,v 1.11 2004/02/20 09:03:26 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.11  sjg # Each feature should get its own set of tests in its own suitably
     12  1.11  sjg # named makefile which should be added to SUBFILES to hook it in.
     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.11  sjg # Simple sub-makefiles - we run them as a black box
     20  1.11  sjg # keep the list sorted.
     21  1.11  sjg SUBFILES= \
     22  1.11  sjg 	modmatch \
     23  1.11  sjg 	modts \
     24  1.11  sjg 	modword \
     25  1.11  sjg 	ternary \
     26  1.11  sjg 	varcmd
     27  1.11  sjg 
     28  1.11  sjg all: ${SUBFILES}
     29  1.11  sjg 
     30  1.11  sjg # the tests are actually done with sub-makes.
     31  1.11  sjg .PHONY: ${SUBFILES}
     32  1.11  sjg ${SUBFILES}:
     33   1.9  sjg 	@${.MAKE} -k -f ${UNIT_TESTS}/$@
     34   1.9  sjg 
     35   1.1  sjg clean:
     36   1.1  sjg 	rm -f *.out *.fail *.core
     37   1.1  sjg 
     38   1.1  sjg .include <bsd.obj.mk>
     39   1.1  sjg 
     40   1.1  sjg TEST_MAKE?= ${MAKE}
     41   1.1  sjg 
     42  1.11  sjg # The driver.
     43  1.11  sjg # We always pretend .MAKE was called 'make' so the results
     44  1.11  sjg # can be compared.
     45   1.1  sjg test:
     46   1.1  sjg 	@echo "${TEST_MAKE} -f ${MAKEFILE} > ${.TARGET}.out 2>&1"
     47   1.6  sjg 	@cd ${.OBJDIR} && ${TEST_MAKE} -f ${MAKEFILE} 2>&1 | \
     48   1.2  sjg 	sed 's,^${TEST_MAKE:T}:,make:,' > ${.TARGET}.out || { \
     49   1.1  sjg 	tail ${.TARGET}.out; mv ${.TARGET}.out ${.TARGET}.fail; exit 1; }
     50   1.7  sjg 	diff -u ${UNIT_TESTS}/${.TARGET}.exp ${.TARGET}.out
     51   1.1  sjg 
     52   1.1  sjg accept:
     53   1.1  sjg 	mv test.out ${.CURDIR}/test.exp
     54   1.1  sjg 
     55