]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - contrib/bmake/unit-tests/Makefile
Merge bmake-20201117
[FreeBSD/FreeBSD.git] / contrib / bmake / unit-tests / Makefile
1 # $Id: Makefile,v 1.115 2020/11/18 04:01:07 sjg Exp $
2 #
3 # $NetBSD: Makefile,v 1.206 2020/11/18 01:12:00 sjg Exp $
4 #
5 # Unit tests for make(1)
6 #
7 # The main targets are:
8 #
9 # all:
10 #       run all the tests
11 # test:
12 #       run 'all', and compare to expected results
13 # accept:
14 #       move generated output to expected results
15 #
16 # Settable variables
17 #
18 # TEST_MAKE
19 #       The make program to be tested.
20 #
21 #
22 # Adding a test case
23 #
24 # Each feature should get its own set of tests in its own suitably
25 # named makefile (*.mk), with its own set of expected results (*.exp),
26 # and it should be added to the TESTS list.
27 #
28 # A few *.mk files are helper files for other tests (such as include-sub.mk)
29 # and are thus not added to TESTS.  Such files must be ignored in
30 # src/tests/usr.bin/make/t_make.sh.
31 #
32
33 # Each test is in a sub-makefile.
34 # Keep the list sorted.
35 # Any test that is commented out must be ignored in
36 # src/tests/usr.bin/make/t_make.sh as well.
37 #TESTS+=                archive
38 TESTS+=         archive-suffix
39 TESTS+=         cmd-errors
40 TESTS+=         cmd-errors-lint
41 TESTS+=         cmd-interrupt
42 TESTS+=         cmdline
43 TESTS+=         cmdline-undefined
44 TESTS+=         comment
45 TESTS+=         cond-cmp-numeric
46 TESTS+=         cond-cmp-numeric-eq
47 TESTS+=         cond-cmp-numeric-ge
48 TESTS+=         cond-cmp-numeric-gt
49 TESTS+=         cond-cmp-numeric-le
50 TESTS+=         cond-cmp-numeric-lt
51 TESTS+=         cond-cmp-numeric-ne
52 TESTS+=         cond-cmp-string
53 TESTS+=         cond-cmp-unary
54 TESTS+=         cond-func
55 TESTS+=         cond-func-commands
56 TESTS+=         cond-func-defined
57 TESTS+=         cond-func-empty
58 TESTS+=         cond-func-exists
59 TESTS+=         cond-func-make
60 TESTS+=         cond-func-target
61 TESTS+=         cond-late
62 TESTS+=         cond-op
63 TESTS+=         cond-op-and
64 TESTS+=         cond-op-and-lint
65 TESTS+=         cond-op-not
66 TESTS+=         cond-op-or
67 TESTS+=         cond-op-or-lint
68 TESTS+=         cond-op-parentheses
69 TESTS+=         cond-short
70 TESTS+=         cond-token-number
71 TESTS+=         cond-token-plain
72 TESTS+=         cond-token-string
73 TESTS+=         cond-token-var
74 TESTS+=         cond-undef-lint
75 TESTS+=         cond1
76 TESTS+=         counter
77 TESTS+=         counter-append
78 TESTS+=         dep
79 TESTS+=         dep-colon
80 TESTS+=         dep-colon-bug-cross-file
81 TESTS+=         dep-double-colon
82 TESTS+=         dep-double-colon-indep
83 TESTS+=         dep-exclam
84 TESTS+=         dep-none
85 TESTS+=         dep-percent
86 TESTS+=         dep-var
87 TESTS+=         dep-wildcards
88 TESTS+=         depsrc
89 TESTS+=         depsrc-end
90 TESTS+=         depsrc-exec
91 TESTS+=         depsrc-ignore
92 TESTS+=         depsrc-made
93 TESTS+=         depsrc-make
94 TESTS+=         depsrc-meta
95 TESTS+=         depsrc-nometa
96 TESTS+=         depsrc-nometa_cmp
97 TESTS+=         depsrc-nopath
98 TESTS+=         depsrc-notmain
99 TESTS+=         depsrc-optional
100 TESTS+=         depsrc-phony
101 TESTS+=         depsrc-precious
102 TESTS+=         depsrc-recursive
103 TESTS+=         depsrc-silent
104 TESTS+=         depsrc-use
105 TESTS+=         depsrc-usebefore
106 TESTS+=         depsrc-usebefore-double-colon
107 TESTS+=         depsrc-wait
108 TESTS+=         deptgt
109 TESTS+=         deptgt-begin
110 TESTS+=         deptgt-default
111 TESTS+=         deptgt-delete_on_error
112 TESTS+=         deptgt-end
113 TESTS+=         deptgt-end-jobs
114 TESTS+=         deptgt-error
115 TESTS+=         deptgt-ignore
116 TESTS+=         deptgt-interrupt
117 TESTS+=         deptgt-main
118 TESTS+=         deptgt-makeflags
119 TESTS+=         deptgt-no_parallel
120 TESTS+=         deptgt-nopath
121 TESTS+=         deptgt-notparallel
122 TESTS+=         deptgt-objdir
123 TESTS+=         deptgt-order
124 TESTS+=         deptgt-path
125 TESTS+=         deptgt-path-suffix
126 TESTS+=         deptgt-phony
127 TESTS+=         deptgt-precious
128 TESTS+=         deptgt-shell
129 TESTS+=         deptgt-silent
130 TESTS+=         deptgt-stale
131 TESTS+=         deptgt-suffixes
132 TESTS+=         dir
133 TESTS+=         dir-expand-path
134 TESTS+=         directive
135 TESTS+=         directive-dinclude
136 TESTS+=         directive-elif
137 TESTS+=         directive-elifdef
138 TESTS+=         directive-elifmake
139 TESTS+=         directive-elifndef
140 TESTS+=         directive-elifnmake
141 TESTS+=         directive-else
142 TESTS+=         directive-endif
143 TESTS+=         directive-error
144 TESTS+=         directive-export
145 TESTS+=         directive-export-env
146 TESTS+=         directive-export-gmake
147 TESTS+=         directive-export-literal
148 TESTS+=         directive-for
149 TESTS+=         directive-for-generating-endif
150 TESTS+=         directive-hyphen-include
151 TESTS+=         directive-if
152 TESTS+=         directive-if-nested
153 TESTS+=         directive-ifdef
154 TESTS+=         directive-ifmake
155 TESTS+=         directive-ifndef
156 TESTS+=         directive-ifnmake
157 TESTS+=         directive-include
158 TESTS+=         directive-include-fatal
159 TESTS+=         directive-info
160 TESTS+=         directive-sinclude
161 TESTS+=         directive-undef
162 TESTS+=         directive-unexport
163 TESTS+=         directive-unexport-env
164 TESTS+=         directive-warning
165 TESTS+=         dollar
166 TESTS+=         doterror
167 TESTS+=         dotwait
168 TESTS+=         envfirst
169 TESTS+=         error
170 TESTS+=         # escape        # broken by reverting POSIX changes
171 TESTS+=         export
172 TESTS+=         export-all
173 TESTS+=         export-env
174 TESTS+=         export-variants
175 TESTS+=         forloop
176 TESTS+=         forsubst
177 TESTS+=         gnode-submake
178 TESTS+=         hanoi-include
179 TESTS+=         impsrc
180 TESTS+=         include-main
181 TESTS+=         job-flags
182 #TESTS+=                job-output-long-lines
183 TESTS+=         lint
184 TESTS+=         make-exported
185 TESTS+=         moderrs
186 TESTS+=         modmatch
187 TESTS+=         modmisc
188 TESTS+=         modts
189 TESTS+=         modword
190 TESTS+=         objdir-writable
191 TESTS+=         opt
192 TESTS+=         opt-backwards
193 TESTS+=         opt-chdir
194 TESTS+=         opt-debug
195 TESTS+=         opt-debug-all
196 TESTS+=         opt-debug-archive
197 TESTS+=         opt-debug-curdir
198 TESTS+=         opt-debug-cond
199 TESTS+=         opt-debug-dir
200 TESTS+=         opt-debug-errors
201 TESTS+=         opt-debug-file
202 TESTS+=         opt-debug-for
203 TESTS+=         opt-debug-graph1
204 TESTS+=         opt-debug-graph2
205 TESTS+=         opt-debug-graph3
206 TESTS+=         opt-debug-hash
207 #TESTS+=                opt-debug-jobs
208 TESTS+=         opt-debug-lint
209 TESTS+=         opt-debug-loud
210 TESTS+=         opt-debug-meta
211 TESTS+=         opt-debug-making
212 TESTS+=         opt-debug-no-rm
213 TESTS+=         opt-debug-parse
214 TESTS+=         opt-debug-suff
215 TESTS+=         opt-debug-targets
216 TESTS+=         opt-debug-varraw
217 TESTS+=         opt-debug-var
218 TESTS+=         opt-debug-x-trace
219 TESTS+=         opt-define
220 TESTS+=         opt-env
221 TESTS+=         opt-file
222 TESTS+=         opt-ignore
223 TESTS+=         opt-include-dir
224 TESTS+=         opt-jobs
225 TESTS+=         opt-jobs-internal
226 TESTS+=         opt-keep-going
227 TESTS+=         opt-m-include-dir
228 TESTS+=         opt-no-action
229 TESTS+=         opt-no-action-at-all
230 TESTS+=         opt-query
231 TESTS+=         opt-raw
232 TESTS+=         opt-silent
233 TESTS+=         opt-touch
234 TESTS+=         opt-touch-jobs
235 TESTS+=         opt-tracefile
236 TESTS+=         opt-var-expanded
237 TESTS+=         opt-var-literal
238 TESTS+=         opt-warnings-as-errors
239 TESTS+=         opt-where-am-i
240 TESTS+=         opt-x-reduce-exported
241 TESTS+=         order
242 TESTS+=         parse-var
243 TESTS+=         phony-end
244 TESTS+=         posix
245 TESTS+=         # posix1        # broken by reverting POSIX changes
246 TESTS+=         qequals
247 TESTS+=         recursive
248 TESTS+=         sh
249 TESTS+=         sh-dots
250 TESTS+=         sh-jobs
251 TESTS+=         sh-jobs-error
252 TESTS+=         sh-leading-at
253 TESTS+=         sh-leading-hyphen
254 TESTS+=         sh-leading-plus
255 TESTS+=         sh-meta-chars
256 TESTS+=         sh-multi-line
257 TESTS+=         sh-single-line
258 TESTS+=         shell-csh
259 TESTS+=         shell-custom
260 .if exists(/bin/ksh)
261 TESTS+=         shell-ksh
262 .endif
263 TESTS+=         shell-sh
264 TESTS+=         suff-add-later
265 TESTS+=         suff-clear-regular
266 TESTS+=         suff-clear-single
267 TESTS+=         suff-lookup
268 TESTS+=         suff-main
269 TESTS+=         suff-rebuild
270 TESTS+=         suff-self
271 TESTS+=         suff-transform-endless
272 TESTS+=         suff-transform-expand
273 TESTS+=         suff-transform-select
274 TESTS+=         sunshcmd
275 TESTS+=         ternary
276 TESTS+=         unexport
277 TESTS+=         unexport-env
278 TESTS+=         use-inference
279 TESTS+=         var-class
280 TESTS+=         var-class-cmdline
281 TESTS+=         var-class-env
282 TESTS+=         var-class-global
283 TESTS+=         var-class-local
284 TESTS+=         var-class-local-legacy
285 TESTS+=         var-op
286 TESTS+=         var-op-append
287 TESTS+=         var-op-assign
288 TESTS+=         var-op-default
289 TESTS+=         var-op-expand
290 TESTS+=         var-op-shell
291 TESTS+=         var-op-sunsh
292 TESTS+=         var-recursive
293 TESTS+=         varcmd
294 TESTS+=         vardebug
295 TESTS+=         varfind
296 TESTS+=         varmisc
297 TESTS+=         varmod
298 TESTS+=         varmod-assign
299 TESTS+=         varmod-defined
300 TESTS+=         varmod-edge
301 TESTS+=         varmod-exclam-shell
302 TESTS+=         varmod-extension
303 TESTS+=         varmod-gmtime
304 TESTS+=         varmod-hash
305 TESTS+=         varmod-head
306 TESTS+=         varmod-ifelse
307 TESTS+=         varmod-l-name-to-value
308 TESTS+=         varmod-localtime
309 TESTS+=         varmod-loop
310 TESTS+=         varmod-match
311 TESTS+=         varmod-match-escape
312 TESTS+=         varmod-no-match
313 TESTS+=         varmod-order
314 TESTS+=         varmod-order-reverse
315 TESTS+=         varmod-order-shuffle
316 TESTS+=         varmod-path
317 TESTS+=         varmod-quote
318 TESTS+=         varmod-quote-dollar
319 TESTS+=         varmod-range
320 TESTS+=         varmod-remember
321 TESTS+=         varmod-root
322 TESTS+=         varmod-select-words
323 TESTS+=         varmod-shell
324 TESTS+=         varmod-subst
325 TESTS+=         varmod-subst-regex
326 TESTS+=         varmod-sysv
327 TESTS+=         varmod-tail
328 TESTS+=         varmod-to-abs
329 TESTS+=         varmod-to-lower
330 TESTS+=         varmod-to-many-words
331 TESTS+=         varmod-to-one-word
332 TESTS+=         varmod-to-separator
333 TESTS+=         varmod-to-upper
334 TESTS+=         varmod-undefined
335 TESTS+=         varmod-unique
336 TESTS+=         varname
337 TESTS+=         varname-dollar
338 TESTS+=         varname-dot-alltargets
339 TESTS+=         varname-dot-curdir
340 TESTS+=         varname-dot-includes
341 TESTS+=         varname-dot-includedfromdir
342 TESTS+=         varname-dot-includedfromfile
343 TESTS+=         varname-dot-libs
344 TESTS+=         varname-dot-make-dependfile
345 TESTS+=         varname-dot-make-expand_variables
346 TESTS+=         varname-dot-make-exported
347 TESTS+=         varname-dot-make-jobs
348 TESTS+=         varname-dot-make-jobs-prefix
349 TESTS+=         varname-dot-make-level
350 TESTS+=         varname-dot-make-makefile_preference
351 TESTS+=         varname-dot-make-makefiles
352 TESTS+=         varname-dot-make-meta-bailiwick
353 TESTS+=         varname-dot-make-meta-created
354 TESTS+=         varname-dot-make-meta-files
355 TESTS+=         varname-dot-make-meta-ignore_filter
356 TESTS+=         varname-dot-make-meta-ignore_paths
357 TESTS+=         varname-dot-make-meta-ignore_patterns
358 TESTS+=         varname-dot-make-meta-prefix
359 TESTS+=         varname-dot-make-mode
360 TESTS+=         varname-dot-make-path_filemon
361 TESTS+=         varname-dot-make-pid
362 TESTS+=         varname-dot-make-ppid
363 TESTS+=         varname-dot-make-save_dollars
364 TESTS+=         varname-dot-makeoverrides
365 TESTS+=         varname-dot-newline
366 TESTS+=         varname-dot-objdir
367 TESTS+=         varname-dot-parsedir
368 TESTS+=         varname-dot-parsefile
369 TESTS+=         varname-dot-path
370 TESTS+=         varname-dot-shell
371 TESTS+=         varname-dot-targets
372 TESTS+=         varname-empty
373 TESTS+=         varname-make
374 TESTS+=         varname-make_print_var_on_error
375 TESTS+=         varname-make_print_var_on_error-jobs
376 TESTS+=         varname-makefile
377 TESTS+=         varname-makeflags
378 TESTS+=         varname-pwd
379 TESTS+=         varname-vpath
380 TESTS+=         varparse-dynamic
381 TESTS+=         varparse-errors
382 TESTS+=         varparse-mod
383 TESTS+=         varparse-undef-partial
384 TESTS+=         varquote
385
386 # Ideas for more tests:
387 #       char-0020-space.mk
388 #       char-005C-backslash.mk
389 #       escape-cond-str.mk
390 #       escape-cond-func-arg.mk
391 #       escape-cond-func-arg.mk
392 #       escape-varmod.mk
393 #       escape-varmod-define.mk
394 #       escape-varmod-match.mk
395 #       escape-varname.mk
396 #       escape-varassign-varname.mk
397 #       escape-varassign-varname-cmdline.mk
398 #       escape-varassign-value.mk
399 #       escape-varassign-value-cmdline.mk
400 #       escape-dependency-source.mk
401 #       escape-dependency-target.mk
402 #       escape-for-varname.mk
403 #       escape-for-item.mk
404 #       posix-*.mk (see posix.mk and posix1.mk)
405
406 .if ${.OBJDIR} != ${.CURDIR}
407 RO_OBJDIR:=     ${.OBJDIR}/roobj
408 .else
409 RO_OBJDIR:=     ${TMPDIR:U/tmp}/roobj
410 .endif
411 # Additional environment variables for some of the tests.
412 # The base environment is -i PATH="$PATH".
413 ENV.depsrc-optional+=   TZ=UTC
414 ENV.envfirst=           FROM_ENV=value-from-env
415 ENV.objdir-writable+=   RO_OBJDIR=${RO_OBJDIR}
416 ENV.varmisc=            FROM_ENV=env
417 ENV.varmisc+=           FROM_ENV_BEFORE=env
418 ENV.varmisc+=           FROM_ENV_AFTER=env
419 ENV.varmod-localtime+=  TZ=Europe/Berlin
420 ENV.varname-vpath+=     VPATH=varname-vpath.dir:varname-vpath.dir2
421
422 # Override make flags for some of the tests; default is -k.
423 # If possible, write ".MAKEFLAGS: -dv" in the test .mk file instead of
424 # settings FLAGS.test=-dv here, since that is closer to the test code.
425 FLAGS.cond-func-make=   via-cmdline
426 FLAGS.directive-ifmake= first second
427 FLAGS.doterror=         # none, especially not -k
428 FLAGS.varname-empty=    -dv '$${:U}=cmdline-u' '=cmdline-plain'
429
430 # Some tests need extra postprocessing.
431 SED_CMDS.export= \
432         -e '/^[^=_A-Za-z0-9]*=/d'
433 # these all share the same requirement
434 .for t in export-all export-env
435 SED_CMDS.$t= ${SED_CMDS.export}
436 .endfor
437 SED_CMDS.directive-export-gmake= \
438         ${:D dash is a pain } \
439         -e /non-zero/d
440 SED_CMDS.job-output-long-lines= \
441         ${:D Job separators on their own line are ok. } \
442         -e '/^--- job-[ab] ---$$/d' \
443         ${:D Plain output lines are ok as well. } \
444         ${:D They may come in multiples of 1024 or as 10000. } \
445         -e '/^aa*$$/d' \
446         -e '/^bb*$$/d' \
447         ${:D The following lines should rather not occur since the job } \
448         ${:D marker should always be at the beginning of the line. } \
449         -e '/^aa*--- job-b ---$$/d' \
450         -e '/^bb*--- job-a ---$$/d'
451 SED_CMDS.objdir-writable= -e 's,${RO_OBJDIR},OBJDIR/roobj,g'
452 SED_CMDS.opt-debug-graph1= \
453                         -e 's,${.CURDIR},CURDIR,'
454 SED_CMDS.opt-debug-graph1+= \
455                         -e '/Global Variables:/,/Suffixes:/d'
456 SED_CMDS.sh-dots=       -e 's,^.*\.\.\.:.*,<normalized: ...: not found>,'
457 SED_CMDS.opt-debug-jobs=        -e 's,([0-9][0-9]*),(<pid>),'
458 SED_CMDS.opt-debug-jobs+=       -e 's,pid [0-9][0-9]*,pid <pid>,'
459 SED_CMDS.opt-debug-jobs+=       -e 's,Process [0-9][0-9]*,Process <pid>,'
460 SED_CMDS.opt-debug-jobs+=       -e 's,JobFinish: [0-9][0-9]*,JobFinish: <pid>,'
461 # The "-q" may be there or not, see jobs.c, variable shells.
462 SED_CMDS.opt-debug-jobs+=       -e 's,^\(.Command: sh\) -q,\1,'
463 SED_CMDS.var-op-shell+= -e 's,^${.SHELL:T}: ,,'
464 SED_CMDS.var-op-shell+= -e '/command/{ s,^[1-9]: ,,;s,No such.*,not found,; }'
465 SED_CMDS.vardebug= \
466         ${:D canonicalize .SHELL } \
467         -e 's,${.SHELL},</path/to/shell>,'
468 SED_CMDS.varmod-subst-regex+= \
469                         -e 's,\(Regex compilation error:\).*,\1 (details omitted),'
470 SED_CMDS.varmod-edge+=  -e 's, line [0-9]*:, line omitted:,'
471 SED_CMDS.varname-dot-parsedir=  -e '/in some cases/ s,^make: "[^"]*,make: "<normalized>,'
472 SED_CMDS.varname-dot-parsefile= -e '/in some cases/ s,^make: "[^"]*,make: "<normalized>,'
473 SED_CMDS.varname-dot-shell=     -e 's, = /[^ ]*, = (details omitted),g'
474 SED_CMDS.varname-dot-shell+=    -e 's,"/[^" ]*","(details omitted)",g'
475 SED_CMDS.varname-dot-shell+=    -e 's,\[/[^] ]*\],[(details omitted)],g'
476
477 # Some tests need an additional round of postprocessing.
478 POSTPROC.deptgt-suffixes= \
479                         ${TOOL_SED} -n -e '/^\#\*\*\* Suffixes/,/^\#\*/p'
480 POSTPROC.gnode-submake= awk '/Input graph/, /^$$/'
481 POSTPROC.varname-empty= ${TOOL_SED} -n -e '/^Var_Set/p' -e '/^out:/p'
482
483 # Some tests reuse other tests, which makes them unnecessarily fragile.
484 export-all.rawout: export.mk
485 unexport.rawout: export.mk
486 unexport-env.rawout: export.mk
487
488 # End of the configuration section.
489
490 .MAIN: all
491
492 .-include "Makefile.inc"
493 .-include "Makefile.config"
494
495 UNIT_TESTS:=    ${.PARSEDIR}
496 .PATH: ${UNIT_TESTS}
497
498 .if ${USE_ABSOLUTE_TESTNAMES:Uno} == yes
499 OUTFILES=       ${TESTS:@test@${.CURDIR:tA}/${test}.out@}
500 .else
501 OUTFILES=       ${TESTS:=.out}
502 .endif
503
504 all: ${OUTFILES}
505
506 CLEANFILES=             *.rawout *.out *.status *.tmp *.core *.tmp
507 CLEANFILES+=            obj*.[och] lib*.a       # posix1.mk
508 CLEANFILES+=            issue* .[ab]*           # suffixes.mk
509 CLEANDIRS=              dir dummy               # posix1.mk
510
511 clean:
512         rm -f ${CLEANFILES}
513         rm -rf ${CLEANDIRS}
514
515 TEST_MAKE?=     ${.MAKE}
516 TOOL_SED?=      sed
517 TOOL_TR?=       tr
518 TOOL_DIFF?=     diff
519 DIFF_FLAGS?=    -u
520
521 .if defined(.PARSEDIR)
522 # ensure consistent results from sort(1)
523 LC_ALL=         C
524 LANG=           C
525 .export LANG LC_ALL
526 .endif
527
528 .if ${.MAKE.MODE:Unormal:Mmeta} != ""
529 # we don't need the noise
530 _MKMSG_TEST= :
531 .endif
532
533 MAKE_TEST_ENV?= MALLOC_OPTIONS="JA"     # for jemalloc
534
535 # Each test is run in a sub-make, to keep the tests for interfering with
536 # each other, and because they use different environment variables and
537 # command line options.
538 .SUFFIXES: .mk .rawout .out
539 .mk.rawout:
540         @${_MKMSG_TEST:Uecho '#      test '} ${.PREFIX}
541         @set -eu; \
542         cd ${.OBJDIR}; \
543         env -i PATH="$$PATH" ${MAKE_TEST_ENV} ${ENV.${.PREFIX:T}} \
544           ${TEST_MAKE} \
545             -r -C ${.CURDIR} -f ${.IMPSRC} \
546             ${FLAGS.${.PREFIX:T}:U-k} \
547             > ${.TARGET}.tmp 2>&1 \
548         && status=$$? || status=$$?; \
549         echo $$status > ${.TARGET:R}.status
550         @mv ${.TARGET}.tmp ${.TARGET}
551
552 # Postprocess the test output so that the results can be compared.
553 #
554 # always pretend .MAKE was called 'make'
555 _SED_CMDS+=     -e 's,^${TEST_MAKE:T:S,.,\\.,g}[][0-9]*:,make:,'
556 _SED_CMDS+=     -e 's,${TEST_MAKE:S,.,\\.,g},make,'
557 _SED_CMDS+=     -e 's,${TEST_MAKE:T:S,.,\\.,g}[][0-9]* warning,make warning,'
558 _SED_CMDS+=     -e 's,^usage: ${TEST_MAKE:T:S,.,\\.,g} ,usage: make ,'
559 # replace anything after 'stopped in' with unit-tests
560 _SED_CMDS+=     -e '/stopped/s, /.*, unit-tests,'
561 # strip ${.CURDIR}/ from the output
562 _SED_CMDS+=     -e 's,${.CURDIR:S,.,\\.,g}/,,g'
563 _SED_CMDS+=     -e 's,${UNIT_TESTS:S,.,\\.,g}/,,g'
564
565 .rawout.out:
566         @${TOOL_SED} ${_SED_CMDS} ${SED_CMDS.${.PREFIX:T}} \
567           < ${.IMPSRC} > ${.TARGET}.tmp1
568         @${POSTPROC.${.PREFIX:T}:Ucat} < ${.TARGET}.tmp1 > ${.TARGET}.tmp2
569         @rm ${.TARGET}.tmp1
570         @echo "exit status `cat ${.TARGET:R}.status`" >> ${.TARGET}.tmp2
571         @mv ${.TARGET}.tmp2 ${.TARGET}
572
573 # Compare all output files
574 test:   ${OUTFILES} .PHONY
575         @failed= ; \
576         for test in ${TESTS}; do \
577           ${TOOL_DIFF} ${DIFF_FLAGS} ${UNIT_TESTS}/$${test}.exp $${test}.out \
578           || failed="$${failed}$${failed:+ }$${test}" ; \
579         done ; \
580         if [ -n "$${failed}" ]; then \
581           echo "Failed tests: $${failed}" ; false ; \
582         else \
583           echo "All tests passed" ; \
584         fi
585
586 accept:
587         @for test in ${TESTS}; do \
588           cmp -s ${UNIT_TESTS}/$${test}.exp $${test}.out \
589           || { echo "Replacing $${test}.exp" ; \
590                cp $${test}.out ${UNIT_TESTS}/$${test}.exp ; } \
591         done
592
593 .if exists(${TEST_MAKE})
594 ${TESTS:=.rawout}: ${TEST_MAKE}
595 # in meta mode, we *know* if a target script is impacted
596 # by a makefile change.
597 .if ${.MAKE.MODE:Unormal:Mmeta} == ""
598 ${TESTS:=.rawout}: ${.PARSEDIR}/Makefile
599 .endif
600 .endif
601
602 .-include <obj.mk>