opnsense-src/unit-tests/directive-for-errors.mk
Simon J. Gerraty 507951f550 Import bmake-20240430
Intersting/relevant changes since bmake-20240309

ChangeLog since bmake-20240309

2024-04-30  Simon J Gerraty  <sjg@beast.crufty.net>

	* VERSION (_MAKE_VERSION): 20240430
	Merge with NetBSD make, pick up
	o main.c: ensure '.include <makefile>' respects MAKESYSPATH.
	Dir_FindFile will search .CURDIR first unless ".DOTLAST" is seen.

2024-04-28  Simon J Gerraty  <sjg@beast.crufty.net>

	* VERSION (_MAKE_VERSION): 20240428
	Merge with NetBSD make, pick up
	o simplify freeing of lists
	o arch.c: trim pointless comments
	o var.c: delay variable assignments until actually needed
	don't reallocate memory after evaluating an expression, result is
	almost always short-lived.

2024-04-26  Simon J Gerraty  <sjg@beast.crufty.net>

	* VERSION (_MAKE_VERSION): 20240426
	Merge with NetBSD make, pick up
	o job.c: in debug output, print the directory in which a job
	failed at same time as failed target so it is more easily found in
	build log.

2024-04-24  Simon J Gerraty  <sjg@beast.crufty.net>

	* VERSION (_MAKE_VERSION): 20240424
	Merge with NetBSD make, pick up
	o clean up comments, code and tests

2024-04-23  Simon J Gerraty  <sjg@beast.crufty.net>

	* VERSION (_MAKE_VERSION): 20240422
	Merge with NetBSD make, pick up
	o var.c: avoid LazyBuf for :*time modifiers.
	LazyBuf's are not nul terminated so not suitable for passing to
	functions that expect that. These modifiers are used sparingly so
	an extra allocation is not a problem.

2024-04-20  Simon J Gerraty  <sjg@beast.crufty.net>

	* VERSION (_MAKE_VERSION): 20240420
	Merge with NetBSD make, pick up
	o provide more context information for parse/evaluate errors

2024-04-14  Simon J Gerraty  <sjg@beast.crufty.net>

	* VERSION (_MAKE_VERSION): 20240414
	Merge with NetBSD make, pick up
	o parse.c: print -dp debug info earlier so we see which
	.if or .for line is being parsed.

2024-04-04  Simon J Gerraty  <sjg@beast.crufty.net>

	* VERSION (_MAKE_VERSION): 20240404
	Merge with NetBSD make, pick up
	o fix some unit tests for Cygwin
	o parse.c: exit immediately after reading a null byte from a makefile

	* fix generation of bmake.cat1

2024-03-19  Simon J Gerraty  <sjg@beast.crufty.net>

	* VERSION (_MAKE_VERSION): 20240314
	Add/Improve support for Cygwin
	o uname -s output isn't useful so allow configure to
	set FORCE_MAKE_OS - to force the value of .MAKE.OS
	and use Cygwin which matches uname -o
	o fix some unit-tests for Cygwin

	* configure.in: use_makefile=no for Cygwin et al.
	NOTE: bmake does not support Cygwin and likely never will,

mk/ChangeLog since bmake-20240309

2024-04-24  Simon J Gerraty  <sjg@beast.crufty.net>

	* meta.autodep.mk: do not override start_utc

2024-04-18  Simon J Gerraty  <sjg@beast.crufty.net>

	* sys.dirdeps.mk: set defaults for DEP_* at level 0 too.
	These help when first include of Makefile.depend happens in a leaf
	dir.

	* install-mk (MK_VERSION): 20240414

2024-04-09  Simon J Gerraty  <sjg@beast.crufty.net>

	* install-mk (MK_VERSION): 20240408

	* init.mk: allow for _ as well as . to join V
	and Q from QUALIFIED_VAR_LIST and VAR_QUALIFIER_LIST.

	* progs.mk: avoid overlap between PROG_VARS and
	init.mk's QUALIFIED_VAR_LIST since PROG would also
	match its VAR_QUALIFIER_LIST,
	libs.mk does not have the same issue.

	* subdir.mk: _SUBDIRUSE for realinstall should run install
	remove include of ${.CURDIR}/Makefile.inc that can be done via
	local.subdir.mk where needed

	* own.mk: do not conflict with man.mk

2024-03-19  Simon J Gerraty  <sjg@beast.crufty.net>

	* install-mk (MK_VERSION): 20240314

	* add sys/Cygwin.mk from Christian Franke
2024-05-03 15:43:12 -07:00

94 lines
3.3 KiB
Makefile

# $NetBSD: directive-for-errors.mk,v 1.10 2024/04/20 10:18:55 rillig Exp $
#
# Tests for error handling in .for loops.
# A .for directive must be followed by whitespace, everything else results
# in a parse error.
# expect+1: Unknown directive "fori"
.fori in 1 2 3
. warning <${i}>
.endfor
# expect-2: warning: <>
# expect-2: for-less endfor
# A slash is not whitespace, therefore this is not parsed as a .for loop.
#
# XXX: The error message is misleading though. As of 2020-12-31, it says
# 'Unknown directive "for"', but that directive is actually known. This is
# because ForEval does not detect the .for loop as such, so parsing
# continues in ParseLine > ParseDependencyLine > ParseDependency >
# ParseDependencyTargets > ParseErrorNoDependency, and there the directive
# name is parsed a bit differently.
# expect+1: Unknown directive "for"
.for/i in 1 2 3
. warning <${i}>
.endfor
# expect-2: warning: <>
# expect-2: for-less endfor
# Before for.c 1.173 from 2023-05-08, the variable name could be an arbitrary
# word, it only needed to be separated by whitespace. Even '$' and '\' were
# valid variable names, which was not useful in practice.
#
# The '$$' was not replaced with the values '1' or '3' from the .for loop,
# instead it was kept as-is, and when the .info directive expanded its
# argument, each '$$' got replaced with a single '$'. The "long
# expression" ${$} got replaced though, even though this would be a parse
# error everywhere outside a .for loop.
${:U\$}= dollar # see whether the "variable" '$' is local
${:U\\}= backslash # see whether the "variable" '\' is local
# expect+1: invalid character '$' in .for loop variable name
.for $ \ in 1 2 3 4
. info Dollar $$ ${$} $($) and backslash $\ ${\} $(\).
.endfor
# If there are no variables, there is no point in expanding the .for loop
# since this would end up in an endless loop, consuming 0 of the 3 values in
# each iteration.
# expect+1: no iteration variables in for
.for in 1 2 3
# XXX: This should not be reached. It should be skipped, as already done
# when the number of values is not a multiple of the number of variables,
# see below.
. warning Should not be reached.
.endfor
# There are 3 variables and 5 values. These 5 values cannot be split evenly
# among the variables, therefore the loop is not expanded at all, it is
# skipped instead.
# expect+1: Wrong number of words (5) in .for substitution list with 3 variables
.for a b c in 1 2 3 4 5
. warning Should not be reached.
.endfor
# The list of values after the 'in' may be empty, no matter if this emptiness
# comes from an expanded expression or from a syntactically empty line.
.for i in
. info Would be reached if there were items to loop over.
.endfor
# A missing 'in' should parse the .for loop but skip the body.
# expect+1: missing `in' in for
.for i over k
# XXX: As of 2020-12-31, this line is reached once.
. warning Should not be reached.
.endfor
# A malformed modifier should be detected and skip the body of the loop.
#
# XXX: As of 2020-12-31, Var_Subst doesn't report any errors, therefore
# the loop body is expanded as if no error had happened.
# expect+1: while evaluating "${:U3:Z} 4": Unknown modifier "Z"
.for i in 1 2 ${:U3:Z} 4
. warning Should not be reached.
.endfor
# expect-2: warning: Should not be reached.
# expect-3: warning: Should not be reached.
# expect-4: warning: Should not be reached.