1*954401e6SSimon J. Gerraty# $NetBSD: opt-jobs-no-action.mk,v 1.10 2022/05/08 06:51:27 rillig Exp $ 206b9b3e0SSimon J. Gerraty# 306b9b3e0SSimon J. Gerraty# Tests for the combination of the options -j and -n, which prints the 406b9b3e0SSimon J. Gerraty# commands instead of actually running them. 506b9b3e0SSimon J. Gerraty# 606b9b3e0SSimon J. Gerraty# The format of the output differs from the output of only the -n option, 706b9b3e0SSimon J. Gerraty# without the -j. This is because all this code is implemented twice, once 806b9b3e0SSimon J. Gerraty# in compat.c and once in job.c. 906b9b3e0SSimon J. Gerraty# 1006b9b3e0SSimon J. Gerraty# See also: 1106b9b3e0SSimon J. Gerraty# opt-jobs.mk 1206b9b3e0SSimon J. Gerraty# The corresponding tests without the -n option 1306b9b3e0SSimon J. Gerraty# opt-no-action-combined.mk 1406b9b3e0SSimon J. Gerraty# The corresponding tests without the -j option 1506b9b3e0SSimon J. Gerraty 1606b9b3e0SSimon J. Gerraty.MAKEFLAGS: -j1 -n 1706b9b3e0SSimon J. Gerraty 1806b9b3e0SSimon J. Gerraty# Change the templates for running the commands in jobs mode, to make it 1906b9b3e0SSimon J. Gerraty# easier to see what actually happens. 2006b9b3e0SSimon J. Gerraty# 2106b9b3e0SSimon J. Gerraty# The shell attributes are handled by Job_ParseShell. 2206b9b3e0SSimon J. Gerraty# The shell attributes 'quiet' and 'echo' don't need a trailing newline, 2306b9b3e0SSimon J. Gerraty# this is handled by the [0] != '\0' checks in Job_ParseShell. 24*954401e6SSimon J. Gerraty# The '\#' is handled by ParseRawLine. 2506b9b3e0SSimon J. Gerraty# The '\n' is handled by Str_Words in Job_ParseShell. 26b0c40a00SSimon J. Gerraty# The '$$' is handled by Var_Subst in ParseDependencyLine. 2706b9b3e0SSimon J. Gerraty.SHELL: \ 2806b9b3e0SSimon J. Gerraty name=sh \ 2906b9b3e0SSimon J. Gerraty path=${.SHELL} \ 3006b9b3e0SSimon J. Gerraty quiet="\# .echoOff" \ 3106b9b3e0SSimon J. Gerraty echo="\# .echoOn" \ 3206b9b3e0SSimon J. Gerraty filter="\# .noPrint\n" \ 3306b9b3e0SSimon J. Gerraty check="\# .echoTmpl\n""echo \"%s\"\n" \ 3406b9b3e0SSimon J. Gerraty ignore="\# .runIgnTmpl\n""%s\n" \ 3506b9b3e0SSimon J. Gerraty errout="\# .runChkTmpl\n""{ %s \n} || exit $$?\n" 3606b9b3e0SSimon J. Gerraty 3706b9b3e0SSimon J. Gerratyall: explained combined 3806b9b3e0SSimon J. Gerraty.ORDER: explained combined 3906b9b3e0SSimon J. Gerraty 4006b9b3e0SSimon J. Gerraty# Explain the most basic cases in detail. 4106b9b3e0SSimon J. Gerratyexplained: .PHONY 4206b9b3e0SSimon J. Gerraty @+echo hide-from-output 'begin explain' 4306b9b3e0SSimon J. Gerraty 4406b9b3e0SSimon J. Gerraty # The following command is regular, it is printed twice: 4506b9b3e0SSimon J. Gerraty # - first using the template shell.echoTmpl, 4606b9b3e0SSimon J. Gerraty # - then using the template shell.runChkTmpl. 4706b9b3e0SSimon J. Gerraty false regular 4806b9b3e0SSimon J. Gerraty 4906b9b3e0SSimon J. Gerraty # The following command is silent, it is printed once, using the 5006b9b3e0SSimon J. Gerraty # template shell.runChkTmpl. 5106b9b3e0SSimon J. Gerraty @: silent 5206b9b3e0SSimon J. Gerraty 5306b9b3e0SSimon J. Gerraty # The following command ignores errors, it is printed once, using 5406b9b3e0SSimon J. Gerraty # the default template for cmdTemplate, which is "%s\n". 5506b9b3e0SSimon J. Gerraty # XXX: Why is it not printed using shell.echoTmpl as well? 5606b9b3e0SSimon J. Gerraty # XXX: The '-' should not influence the echoing of the command. 5706b9b3e0SSimon J. Gerraty -false ignore-errors 5806b9b3e0SSimon J. Gerraty 5906b9b3e0SSimon J. Gerraty # The following command ignores the -n command line option, it is 6006b9b3e0SSimon J. Gerraty # not handled by the Job module but by the Compat module, see the 6106b9b3e0SSimon J. Gerraty # '!silent' in Compat_RunCommand. 6206b9b3e0SSimon J. Gerraty +echo run despite the -n option 6306b9b3e0SSimon J. Gerraty 6406b9b3e0SSimon J. Gerraty @+echo hide-from-output 'end explain' 6506b9b3e0SSimon J. Gerraty @+echo hide-from-output 6606b9b3e0SSimon J. Gerraty 6706b9b3e0SSimon J. Gerraty 6806b9b3e0SSimon J. Gerraty# Test all combinations of the 3 RunFlags. 6906b9b3e0SSimon J. Gerraty# 7006b9b3e0SSimon J. Gerraty# TODO: Closely inspect the output whether it makes sense. 7106b9b3e0SSimon J. Gerraty# XXX: silent=no always=no ignerr={no,yes} should be almost the same. 7206b9b3e0SSimon J. Gerraty# 7306b9b3e0SSimon J. GerratySILENT.no= # none 7406b9b3e0SSimon J. GerratySILENT.yes= @ 7506b9b3e0SSimon J. GerratyALWAYS.no= # none 7606b9b3e0SSimon J. GerratyALWAYS.yes= + 7706b9b3e0SSimon J. GerratyIGNERR.no= echo running 7806b9b3e0SSimon J. GerratyIGNERR.yes= -echo running; false 7906b9b3e0SSimon J. Gerraty# 8006b9b3e0SSimon J. Gerratycombined: combined-begin 8106b9b3e0SSimon J. Gerraty 8206b9b3e0SSimon J. Gerratycombined-begin: .PHONY 8306b9b3e0SSimon J. Gerraty @+echo hide-from-output 'begin combined' 8406b9b3e0SSimon J. Gerraty @+echo hide-from-output 8506b9b3e0SSimon J. Gerraty 8606b9b3e0SSimon J. Gerraty.for silent in no yes 8706b9b3e0SSimon J. Gerraty. for always in no yes 8806b9b3e0SSimon J. Gerraty. for ignerr in no yes 8906b9b3e0SSimon J. Gerraty. for target in combined-silent-${silent}-always-${always}-ignerr-${ignerr} 9006b9b3e0SSimon J. Gerratycombined: .WAIT ${target} .WAIT 9106b9b3e0SSimon J. Gerraty${target}: .PHONY 9206b9b3e0SSimon J. Gerraty @+echo hide-from-output silent=${silent} always=${always} ignerr=${ignerr} 9306b9b3e0SSimon J. Gerraty ${SILENT.${silent}}${ALWAYS.${always}}${IGNERR.${ignerr}} 9406b9b3e0SSimon J. Gerraty @+echo hide-from-output 9506b9b3e0SSimon J. Gerraty. endfor 9606b9b3e0SSimon J. Gerraty. endfor 9706b9b3e0SSimon J. Gerraty. endfor 9806b9b3e0SSimon J. Gerraty.endfor 9906b9b3e0SSimon J. Gerraty 10006b9b3e0SSimon J. Gerratycombined: combined-end 10106b9b3e0SSimon J. Gerratycombined-end: .PHONY 10206b9b3e0SSimon J. Gerraty @+echo hide-from-output 'end combined' 103