mirror of
https://github.com/freebsd/freebsd-src
synced 2024-07-22 10:48:02 +00:00
ee914ef902
Lots more unit tests and code cleanup Relevant changes from ChangeLog o job.c: Print -de error information when running multiple jobs o var.c: only report error for unmatched regex subexpression when linting (-dL) since we cannot tell when an unmatched subexpression is an expected result. reduce memory allocations in the modifiers ':D' and ':U' reduce memory allocation and strlen calls in modifier ':from=to' in the ':Q' modifier, only allocate memory if necessary improve performance for LazyBuf reduce debug logging and memory allocation for ${:U...} reduce verbosity of the -dv debug logging for standard cases fix double varname expansion in the variable modifier '::=' o var.c: avoid evaluating many modifiers in parse only mode in strict mode (-dL) many variable references are parsed twice, the first time just to report parse errors early, so we want to avoid side effects and wasted effort to the extent possible.
103 lines
3 KiB
Makefile
103 lines
3 KiB
Makefile
# $NetBSD: opt-jobs-no-action.mk,v 1.9 2021/04/04 09:58:51 rillig Exp $
|
|
#
|
|
# Tests for the combination of the options -j and -n, which prints the
|
|
# commands instead of actually running them.
|
|
#
|
|
# The format of the output differs from the output of only the -n option,
|
|
# without the -j. This is because all this code is implemented twice, once
|
|
# in compat.c and once in job.c.
|
|
#
|
|
# See also:
|
|
# opt-jobs.mk
|
|
# The corresponding tests without the -n option
|
|
# opt-no-action-combined.mk
|
|
# The corresponding tests without the -j option
|
|
|
|
.MAKEFLAGS: -j1 -n
|
|
|
|
# Change the templates for running the commands in jobs mode, to make it
|
|
# easier to see what actually happens.
|
|
#
|
|
# The shell attributes are handled by Job_ParseShell.
|
|
# The shell attributes 'quiet' and 'echo' don't need a trailing newline,
|
|
# this is handled by the [0] != '\0' checks in Job_ParseShell.
|
|
# The '\#' is handled by ParseGetLine.
|
|
# The '\n' is handled by Str_Words in Job_ParseShell.
|
|
# The '$$' is handled by Var_Subst in ParseDependencyLine.
|
|
.SHELL: \
|
|
name=sh \
|
|
path=${.SHELL} \
|
|
quiet="\# .echoOff" \
|
|
echo="\# .echoOn" \
|
|
filter="\# .noPrint\n" \
|
|
check="\# .echoTmpl\n""echo \"%s\"\n" \
|
|
ignore="\# .runIgnTmpl\n""%s\n" \
|
|
errout="\# .runChkTmpl\n""{ %s \n} || exit $$?\n"
|
|
|
|
all: explained combined
|
|
.ORDER: explained combined
|
|
|
|
# Explain the most basic cases in detail.
|
|
explained: .PHONY
|
|
@+echo hide-from-output 'begin explain'
|
|
|
|
# The following command is regular, it is printed twice:
|
|
# - first using the template shell.echoTmpl,
|
|
# - then using the template shell.runChkTmpl.
|
|
false regular
|
|
|
|
# The following command is silent, it is printed once, using the
|
|
# template shell.runChkTmpl.
|
|
@: silent
|
|
|
|
# The following command ignores errors, it is printed once, using
|
|
# the default template for cmdTemplate, which is "%s\n".
|
|
# XXX: Why is it not printed using shell.echoTmpl as well?
|
|
# XXX: The '-' should not influence the echoing of the command.
|
|
-false ignore-errors
|
|
|
|
# The following command ignores the -n command line option, it is
|
|
# not handled by the Job module but by the Compat module, see the
|
|
# '!silent' in Compat_RunCommand.
|
|
+echo run despite the -n option
|
|
|
|
@+echo hide-from-output 'end explain'
|
|
@+echo hide-from-output
|
|
|
|
|
|
# Test all combinations of the 3 RunFlags.
|
|
#
|
|
# TODO: Closely inspect the output whether it makes sense.
|
|
# XXX: silent=no always=no ignerr={no,yes} should be almost the same.
|
|
#
|
|
SILENT.no= # none
|
|
SILENT.yes= @
|
|
ALWAYS.no= # none
|
|
ALWAYS.yes= +
|
|
IGNERR.no= echo running
|
|
IGNERR.yes= -echo running; false
|
|
#
|
|
combined: combined-begin
|
|
|
|
combined-begin: .PHONY
|
|
@+echo hide-from-output 'begin combined'
|
|
@+echo hide-from-output
|
|
|
|
.for silent in no yes
|
|
. for always in no yes
|
|
. for ignerr in no yes
|
|
. for target in combined-silent-${silent}-always-${always}-ignerr-${ignerr}
|
|
combined: .WAIT ${target} .WAIT
|
|
${target}: .PHONY
|
|
@+echo hide-from-output silent=${silent} always=${always} ignerr=${ignerr}
|
|
${SILENT.${silent}}${ALWAYS.${always}}${IGNERR.${ignerr}}
|
|
@+echo hide-from-output
|
|
. endfor
|
|
. endfor
|
|
. endfor
|
|
.endfor
|
|
|
|
combined: combined-end
|
|
combined-end: .PHONY
|
|
@+echo hide-from-output 'end combined'
|