Update bmake to version 20180919
[freebsd.git] / usr.bin / bmake / unit-tests / Makefile
1 # This is a generated file, do NOT edit!
2 # See contrib/bmake/bsd.after-import.mk
3 #
4 # $FreeBSD$
5
6 SRCTOP?= ${.CURDIR:H:H:H}
7
8 # $Id: Makefile.in,v 1.49 2018/09/21 21:39:05 sjg Exp $
9 #
10 # $NetBSD: Makefile,v 1.53 2018/05/24 00:25:44 christos Exp $
11 #
12 # Unit tests for make(1)
13 # The main targets are:
14
15 # all:  run all the tests
16 # test: run 'all', and compare to expected results
17 # accept: move generated output to expected results
18 #
19 # Adding a test case.  
20 # Each feature should get its own set of tests in its own suitably
21 # named makefile (*.mk), with its own set of expected results (*.exp),
22 # and it should be added to the TESTNAMES list.
23
24
25 srcdir= ${SRCTOP}/contrib/bmake/unit-tests
26
27 .MAIN: all
28
29 UNIT_TESTS:= ${srcdir}
30 .PATH: ${UNIT_TESTS}
31
32 # Each test is in a sub-makefile.
33 # Keep the list sorted.
34 TESTNAMES= \
35         comment \
36         cond1 \
37         cond2 \
38         error \
39         export \
40         export-all \
41         export-env \
42         doterror \
43         dotwait \
44         forloop \
45         forsubst \
46         hash \
47         misc \
48         moderrs \
49         modmatch \
50         modmisc \
51         modorder \
52         modts \
53         modword \
54         order \
55         posix \
56         qequals \
57         sunshcmd \
58         sysv \
59         ternary \
60         unexport \
61         unexport-env \
62         varcmd \
63         varmisc \
64         varquote \
65         varshell
66
67 # these tests were broken by referting POSIX chanegs
68 STRICT_POSIX_TESTS = \
69         escape \
70         impsrc \
71         phony-end \
72         posix1 \
73         suffixes
74
75 # Override make flags for certain tests
76 flags.doterror=
77 flags.order=-j1
78
79 OUTFILES= ${TESTNAMES:S/$/.out/}
80
81 all: ${OUTFILES}
82
83 CLEANFILES += *.rawout *.out *.status *.tmp *.core *.tmp
84 CLEANFILES += obj*.[och] lib*.a         # posix1.mk
85 CLEANFILES += issue* .[ab]*             # suffixes.mk
86 CLEANRECURSIVE += dir dummy             # posix1.mk
87
88 clean:
89         rm -f ${CLEANFILES}
90 .if !empty(CLEANRECURSIVE)
91         rm -rf ${CLEANRECURSIVE}
92 .endif
93
94 TEST_MAKE?= ${.MAKE}
95 TOOL_SED?= sed
96 TOOL_TR?= tr
97 TOOL_DIFF?= diff
98 DIFF_FLAGS?= -u
99
100 .if defined(.PARSEDIR)
101 # ensure consistent results from sort(1)
102 LC_ALL= C
103 LANG= C
104 .export LANG LC_ALL
105 .endif
106
107 # some tests need extra post-processing
108 SED_CMDS.varshell = -e 's,^[a-z]*sh: ,,' \
109         -e '/command/s,No such.*,not found,'
110
111 # the tests are actually done with sub-makes.
112 .SUFFIXES: .mk .rawout .out
113 .mk.rawout:
114         @echo ${TEST_MAKE} ${flags.${.TARGET:R}:U-k} -f ${.IMPSRC}
115         -@cd ${.OBJDIR} && \
116         { ${TEST_MAKE} ${flags.${.TARGET:R}:U-k} -f ${.IMPSRC} \
117           2>&1 ; echo $$? >${.TARGET:R}.status ; } > ${.TARGET}.tmp
118         @mv ${.TARGET}.tmp ${.TARGET}
119
120 # We always pretend .MAKE was called 'make' 
121 # and strip ${.CURDIR}/ from the output
122 # and replace anything after 'stopped in' with unit-tests
123 # so the results can be compared.
124 .rawout.out:
125         @echo postprocess ${.TARGET}
126         @${TOOL_SED} -e 's,^${TEST_MAKE:T:C/\./\\\./g}[][0-9]*:,make:,' \
127           -e 's,${TEST_MAKE:C/\./\\\./g},make,' \
128           -e '/stopped/s, /.*, unit-tests,' \
129           -e 's,${.CURDIR:C/\./\\\./g}/,,g' \
130           -e 's,${UNIT_TESTS:C/\./\\\./g}/,,g' ${SED_CMDS.${.TARGET:T:R}} \
131           < ${.IMPSRC} > ${.TARGET}.tmp
132         @echo "exit status `cat ${.TARGET:R}.status`" >> ${.TARGET}.tmp
133         @mv ${.TARGET}.tmp ${.TARGET}
134
135 # Compare all output files
136 test:   ${OUTFILES} .PHONY
137         @failed= ; \
138         for test in ${TESTNAMES}; do \
139           ${TOOL_DIFF} ${DIFF_FLAGS} ${UNIT_TESTS}/$${test}.exp $${test}.out \
140           || failed="$${failed}$${failed:+ }$${test}" ; \
141         done ; \
142         if [ -n "$${failed}" ]; then \
143           echo "Failed tests: $${failed}" ; false ; \
144         else \
145           echo "All tests passed" ; \
146         fi
147
148 accept:
149         @for test in ${TESTNAMES}; do \
150           cmp -s ${UNIT_TESTS}/$${test}.exp $${test}.out \
151           || { echo "Replacing $${test}.exp" ; \
152                cp $${test}.out ${UNIT_TESTS}/$${test}.exp ; } \
153         done
154
155 .if exists(${TEST_MAKE})
156 ${TESTNAMES:S/$/.rawout/}: ${TEST_MAKE}
157 .endif
158
159 .sinclude <bsd.obj.mk>