]> CyberLeo.Net >> Repos - FreeBSD/releng/10.0.git/blob - contrib/bmake/unit-tests/Makefile.in
- Copy stable/10 (r259064) to releng/10.0 as part of the
[FreeBSD/releng/10.0.git] / contrib / bmake / unit-tests / Makefile.in
1 # $Id: Makefile.in,v 1.44 2013/08/28 22:09:29 sjg Exp $
2 #
3 # $NetBSD: Makefile,v 1.38 2013/08/28 21:56:50 sjg Exp $
4 #
5 # Unit tests for make(1)
6 # The main targets are:
7
8 # all:  run all the tests
9 # test: run 'all', capture output and compare to expected results
10 # accept: move generated output to expected results
11 #
12 # Adding a test case.  
13 # Each feature should get its own set of tests in its own suitably
14 # named makefile which should be added to SUBFILES to hook it in.
15
16
17 srcdir= @srcdir@
18
19 .MAIN: all
20
21 UNIT_TESTS:= ${srcdir}
22
23 # Simple sub-makefiles - we run them as a black box
24 # keep the list sorted.
25 SUBFILES= \
26         comment \
27         cond1 \
28         error \
29         export \
30         export-all \
31         export-env \
32         doterror \
33         dotwait \
34         forloop \
35         forsubst \
36         hash \
37         misc \
38         moderrs \
39         modmatch \
40         modmisc \
41         modorder \
42         modts \
43         modword \
44         order \
45         phony-end \
46         posix \
47         qequals \
48         sunshcmd \
49         sysv \
50         ternary \
51         unexport \
52         unexport-env \
53         varcmd
54
55 all: ${SUBFILES}
56
57 flags.doterror=
58 flags.order=-j1
59
60 # the tests are actually done with sub-makes.
61 .PHONY: ${SUBFILES}
62 .PRECIOUS: ${SUBFILES}
63 ${SUBFILES}:
64         -@${.MAKE} ${flags.$@:U-k} -f ${UNIT_TESTS}/$@
65
66 clean:
67         rm -f *.out *.fail *.core
68
69 .-include <obj.mk>
70
71 TEST_MAKE?= ${.MAKE}
72 TOOL_SED?= sed
73 TOOL_TR?= tr
74 TOOL_DIFF?= diff
75 DIFF_FLAGS?= @diff_u@
76
77 .if defined(.PARSEDIR)
78 # ensure consistent results from sort(1)
79 LC_ALL= C
80 LANG= C
81 .export LANG LC_ALL
82 .endif
83
84 # The driver.
85 # We always pretend .MAKE was called 'make' 
86 # and strip ${.CURDIR}/ from the output
87 # and replace anything after 'stopped in' with unit-tests
88 # so the results can be compared.
89 test:
90         @echo "${TEST_MAKE} -f ${MAKEFILE} > ${.TARGET}.out 2>&1"
91         @cd ${.OBJDIR} && ${TEST_MAKE} -f ${MAKEFILE} 2>&1 | \
92         ${TOOL_TR} -d '\015' | \
93         ${TOOL_SED} -e 's,^${TEST_MAKE:T:C/\./\\\./g}[^:]*:,make:,' \
94         -e '/stopped/s, /.*, unit-tests,' \
95         -e 's,${.CURDIR:C/\./\\\./g}/,,g' \
96         -e 's,${UNIT_TESTS:C/\./\\\./g}/,,g' > ${.TARGET}.out || { \
97         tail ${.TARGET}.out; mv ${.TARGET}.out ${.TARGET}.fail; exit 1; }
98         ${TOOL_DIFF} ${DIFF_FLAGS} ${UNIT_TESTS}/${.TARGET}.exp ${.TARGET}.out
99
100 accept:
101         mv test.out ${srcdir}/test.exp
102