opt-jobs-no-action.mk revision 1.1 1 # $NetBSD: opt-jobs-no-action.mk,v 1.1 2020/12/09 00:25:00 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 .MAKEFLAGS: -j1 -n
11
12 # Change the templates for running the commands in jobs mode, to make it
13 # easier to see what actually happens.
14 #
15 # The shell attributes are handled by Job_ParseShell.
16 # The shell attributes 'quiet' and 'echo' don't need a trailing newline,
17 # this is handled by the [0] != '\0' checks in Job_ParseShell.
18 # The '\#' is handled by ParseGetLine.
19 # The '\n' is handled by Str_Words in Job_ParseShell.
20 # The '$$' is handled by Var_Subst in ParseDependency.
21 .SHELL: \
22 name=sh \
23 path=${.SHELL} \
24 quiet="\# .echoOff" \
25 echo="\# .echoOn" \
26 filter="\# .noPrint\n" \
27 check="\# .errOnOrEcho\n""echo \"%s\"\n" \
28 ignore="\# .errOffOrExecIgnore\n""%s\n" \
29 errout="\# .errExit\n""{ %s \n} || exit $$?\n"
30
31 all:
32 # The following command is regular, it is printed twice:
33 # - first using the template shell.errOnOrEcho,
34 # - then using the template shell.errExit.
35 false regular
36
37 # The following command is silent, it is printed once, using the
38 # template shell.errExit.
39 @: silent
40
41 # The following command ignores errors, it is printed once, using
42 # the default template for cmdTemplate, which is "%s\n".
43 # XXX: Why is it not printed using shell.errOnOrEcho as well?
44 # XXX: The '-' should not influence the echoing of the command.
45 -false ignore-errors
46
47 # The following command ignores the -n command line option, it is
48 # not handled by the Job module but by the Compat module, see the
49 # '!silent' in Compat_RunCommand.
50 +echo run despite the -n option
51
52 # TODO: test all 8 combinations of '-', '+', '@'.
53 # TODO: for each of the above test, test '-true' and '-false'.
54 # The code with its many branches feels like a big mess.
55 # See opt-jobs.mk for the corresponding tests without the -n option.
56