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