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