opt-jobs-no-action.mk revision 1.6 1 # $NetBSD: opt-jobs-no-action.mk,v 1.6 2020/12/09 08:18:35 rillig Exp $
2 #
3 # Tests for the combination of the options -j and -n, which prints the
4 # commands instead of actually running them.
5 #
6 # The format of the output differs from the output of only the -n option,
7 # without the -j. This is because all this code is implemented twice, once
8 # in compat.c and once in job.c.
9 #
10 # See also:
11 # opt-jobs.mk
12 # The corresponding tests without the -n option
13 # opt-no-action-combined.mk
14 # The corresponding tests without the -j option
15
16 .MAKEFLAGS: -j1 -n
17
18 # Change the templates for running the commands in jobs mode, to make it
19 # easier to see what actually happens.
20 #
21 # The shell attributes are handled by Job_ParseShell.
22 # The shell attributes 'quiet' and 'echo' don't need a trailing newline,
23 # this is handled by the [0] != '\0' checks in Job_ParseShell.
24 # The '\#' is handled by ParseGetLine.
25 # The '\n' is handled by Str_Words in Job_ParseShell.
26 # The '$$' is handled by Var_Subst in ParseDependency.
27 .SHELL: \
28 name=sh \
29 path=${.SHELL} \
30 quiet="\# .echoOff" \
31 echo="\# .echoOn" \
32 filter="\# .noPrint\n" \
33 check="\# .errOnOrEcho\n""echo \"%s\"\n" \
34 ignore="\# .errOffOrExecIgnore\n""%s\n" \
35 errout="\# .errExit\n""{ %s \n} || exit $$?\n"
36
37 all: documented combined
38 .ORDER: documented combined
39
40 # Explain the most basic cases in detail.
41 documented: .PHONY
42 # The following command is regular, it is printed twice:
43 # - first using the template shell.errOnOrEcho,
44 # - then using the template shell.errExit.
45 false regular
46
47 # The following command is silent, it is printed once, using the
48 # template shell.errExit.
49 @: silent
50
51 # The following command ignores errors, it is printed once, using
52 # the default template for cmdTemplate, which is "%s\n".
53 # XXX: Why is it not printed using shell.errOnOrEcho as well?
54 # XXX: The '-' should not influence the echoing of the command.
55 -false ignore-errors
56
57 # The following command ignores the -n command line option, it is
58 # not handled by the Job module but by the Compat module, see the
59 # '!silent' in Compat_RunCommand.
60 +echo run despite the -n option
61
62 @+echo
63
64
65 # Test all combinations of the 3 RunFlags.
66 #
67 # TODO: Closely inspect the output whether it makes sense.
68 # XXX: silent=no always=no ignerr={no,yes} should be almost the same.
69 #
70 SILENT.no= # none
71 SILENT.yes= @
72 ALWAYS.no= # none
73 ALWAYS.yes= +
74 IGNERR.no= echo running
75 IGNERR.yes= -echo running; false
76 #
77 combined: combined-begin
78
79 combined-begin: .PHONY
80 @+echo hide-from-output 'begin combined'
81 @+echo hide-from-output
82
83 .for silent in no yes
84 . for always in no yes
85 . for ignerr in no yes
86 . for target in combined-silent-${silent}-always-${always}-ignerr-${ignerr}
87 combined: .WAIT ${target} .WAIT
88 ${target}: .PHONY
89 @+echo hide-from-output silent=${silent} always=${always} ignerr=${ignerr}
90 ${SILENT.${silent}}${ALWAYS.${always}}${IGNERR.${ignerr}}
91 @+echo hide-from-output
92 . endfor
93 . endfor
94 . endfor
95 .endfor
96
97 combined: combined-end
98 combined-end: .PHONY
99 @+echo hide-from-output 'end combined'
100