1 1.10 rillig # $NetBSD: opt-jobs-no-action.mk,v 1.10 2022/05/08 06:51:27 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.10 rillig # The '\#' is handled by ParseRawLine. 25 1.1 rillig # The '\n' is handled by Str_Words in Job_ParseShell. 26 1.9 rillig # The '$$' is handled by Var_Subst in ParseDependencyLine. 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.8 rillig check="\# .echoTmpl\n""echo \"%s\"\n" \ 34 1.8 rillig ignore="\# .runIgnTmpl\n""%s\n" \ 35 1.8 rillig errout="\# .runChkTmpl\n""{ %s \n} || exit $$?\n" 36 1.1 rillig 37 1.7 rillig all: explained combined 38 1.7 rillig .ORDER: explained combined 39 1.2 rillig 40 1.2 rillig # Explain the most basic cases in detail. 41 1.7 rillig explained: .PHONY 42 1.7 rillig @+echo hide-from-output 'begin explain' 43 1.7 rillig 44 1.1 rillig # The following command is regular, it is printed twice: 45 1.8 rillig # - first using the template shell.echoTmpl, 46 1.8 rillig # - then using the template shell.runChkTmpl. 47 1.1 rillig false regular 48 1.1 rillig 49 1.1 rillig # The following command is silent, it is printed once, using the 50 1.8 rillig # template shell.runChkTmpl. 51 1.1 rillig @: silent 52 1.1 rillig 53 1.1 rillig # The following command ignores errors, it is printed once, using 54 1.1 rillig # the default template for cmdTemplate, which is "%s\n". 55 1.8 rillig # XXX: Why is it not printed using shell.echoTmpl as well? 56 1.1 rillig # XXX: The '-' should not influence the echoing of the command. 57 1.1 rillig -false ignore-errors 58 1.1 rillig 59 1.1 rillig # The following command ignores the -n command line option, it is 60 1.1 rillig # not handled by the Job module but by the Compat module, see the 61 1.1 rillig # '!silent' in Compat_RunCommand. 62 1.1 rillig +echo run despite the -n option 63 1.1 rillig 64 1.7 rillig @+echo hide-from-output 'end explain' 65 1.7 rillig @+echo hide-from-output 66 1.2 rillig 67 1.3 rillig 68 1.2 rillig # Test all combinations of the 3 RunFlags. 69 1.2 rillig # 70 1.2 rillig # TODO: Closely inspect the output whether it makes sense. 71 1.3 rillig # XXX: silent=no always=no ignerr={no,yes} should be almost the same. 72 1.3 rillig # 73 1.3 rillig SILENT.no= # none 74 1.3 rillig SILENT.yes= @ 75 1.3 rillig ALWAYS.no= # none 76 1.3 rillig ALWAYS.yes= + 77 1.3 rillig IGNERR.no= echo running 78 1.3 rillig IGNERR.yes= -echo running; false 79 1.3 rillig # 80 1.5 rillig combined: combined-begin 81 1.5 rillig 82 1.5 rillig combined-begin: .PHONY 83 1.6 rillig @+echo hide-from-output 'begin combined' 84 1.6 rillig @+echo hide-from-output 85 1.5 rillig 86 1.2 rillig .for silent in no yes 87 1.2 rillig . for always in no yes 88 1.2 rillig . for ignerr in no yes 89 1.5 rillig . for target in combined-silent-${silent}-always-${always}-ignerr-${ignerr} 90 1.5 rillig combined: .WAIT ${target} .WAIT 91 1.5 rillig ${target}: .PHONY 92 1.6 rillig @+echo hide-from-output silent=${silent} always=${always} ignerr=${ignerr} 93 1.2 rillig ${SILENT.${silent}}${ALWAYS.${always}}${IGNERR.${ignerr}} 94 1.6 rillig @+echo hide-from-output 95 1.5 rillig . endfor 96 1.2 rillig . endfor 97 1.2 rillig . endfor 98 1.2 rillig .endfor 99 1.5 rillig 100 1.5 rillig combined: combined-end 101 1.5 rillig combined-end: .PHONY 102 1.6 rillig @+echo hide-from-output 'end combined' 103