Home | History | Annotate | Download | only in unit-tests
History log of /src/usr.bin/make/unit-tests/moderrs.mk
RevisionDateAuthorComments
 1.47  28-Jun-2025  rillig make: consistently use double quotes in error messages

Previously, some error messages used single quotes, very few used
backticks or parentheses, most already used double quotes.

While here, reword a few error messages to be clearer or more consistent
with related error messages.
 1.46  30-Mar-2025  rillig make: let the ":t" modifiers fall back to the ":from=to" modifier

Suggested by https://bugs.freebsd.org/285726.

This means that the ":t" modifiers cannot have future extensions that
include a "=", as that may break existing code.
 1.45  29-Mar-2025  rillig make: add ":" to error message about unknown modifier

In the manual page, the modifiers are listed with a preceding ":", so
use the same pattern in the error message. This removes an inconsistency
between the error messages "Unknown modifier" and "Bad modifier".
 1.44  29-Mar-2025  rillig make: stop parsing after seeing an unknown modifier in an expression

Previously, after an expression such as ${VAR:Z::::}, make detected the
unknown modifier ":Z" and then continued parsing, which produced
unnecessary follow-up error messages. It was also necessary to
distinguish the error cases when logging the result of an applied
modifier in -dv mode.

Unify the error handling cases of a syntax error, an evaluation error
and an unknown modifier, to avoid the unnecessary follow-up error
messages.

The test in varmod-edge.mk now produces ":}" from the erroneous
expression, which may be misleading and thus will be looked at in a
follow-up commit.

The general idea of this patch was reviewed by sjg, I made a few
nonsubstantial changes after the review.
 1.43  29-Mar-2025  rillig make: fix error message for unclosed expression

Even in an unclosed expression such as "${VAR:from=to", the modifier
":from=to" needs to be recognized as such, instead of giving an error
message about an "Unknown modifier ":from=to"".
 1.42  29-Mar-2025  rillig make: add more details to error message about unfinished modifier

These details allow to quickly see the place where the syntax error is,
based on the surrounding lines from the stack trace.
 1.41  29-Aug-2024  rillig make: reduce line length in error messages

The error messages for deeply nested parse errors were hard to decipher,
due to the large amount of text. Split these messages into individual
lines, just as in the backtrace for .include files and .for loops. This
unified backtrace makes the output more uniform.
 1.40  20-Jul-2024  rillig make: don't run erroneous commands in compat mode

When there is a parse or evaluation error in an expression that becomes
part of the command, don't run that command, as the result of the failed
evaluation typically contains garbage characters. Skip the remaining
commands from that target as well, as they may depend on the erroneous
command.
 1.39  20-Jul-2024  rillig tests/make: remove redundant context information

The affected target is already mentioned in the line containing the
error message.
 1.38  05-Jul-2024  rillig make: in error messages for anonymous variables, log the value
 1.37  05-Jul-2024  rillig make: error out on unclosed expressions during parse time

In exchange, this adds location information.

For unnamed expressions, the value is no longer printed. This will be
added back in a follow-up commit.
 1.36  05-Jul-2024  rillig tests/make: add expected messages for "Unclosed expression"
 1.35  04-Jul-2024  rillig make: error out on the "Bad modifier" error message

Previously, the "Bad modifier" error message did not affect make's exit
status. As a side effect, this kind of error now gets more context
information.
 1.34  04-Jul-2024  rillig make: add more context information to error messages

In case of a parse error or evaluation error, print the variable value
in addition to the variable name, to see the effects of previous
expression modifiers.

In nested make calls, print the current directory at the bottom of a
stack trace, as that information is otherwise hard to get in a parallel
build spanning multiple directories.
 1.33  30-Jun-2024  rillig make: error out on some more syntax errors

Previously, these errors only produced a message on stderr. They only
affected make's exit status when they were evaluated at parse time, but
not when evaluating the commands for a specific target right before
executing them.

The affected syntax errors are:
* invalid regular expressions in the ':C' modifier
* out-of-range references to regex groups in the ':C' modifier
* unfinished modifiers
 1.32  30-Jun-2024  rillig tests/make: replace 'want' comments with 'expect' directives

The 'want' comments needed to be cross-checked manually, which was
error-prone, as can be seen in the "Unknown modifier" messages that got
out of sync.
 1.31  19-Nov-2023  rillig branches: 1.31.2;
tests/make: replace 'variable expressions' with 'expressions'
 1.30  21-Jun-2021  rillig tests/make: remove unnecessary -dL from moderrs.mk

It was only needed for the test for unmatched subexpressions in the
modifier ':C'. That test has been moved to varmod-subst-regex.mk.
 1.29  21-Jun-2021  rillig tests/make: move and extend test for unmatched '\1' in ':C'

This test lived together with a few unrelated tests in moderrs.mk, it is
better placed in varmod-subst-regex.mk though.

While here, extend, document and explain the test since its purpose was
not obvious from reading the code alone.
 1.28  21-Jun-2021  sjg Do not report unmatched regex subexpressions

It is not always an error for a subexpression to have not matched,
since the regex library can/does not convey how many matches are
expected, only report an error if opts.strict (-dL)

Reviewed by: christos
 1.27  23-Feb-2021  rillig make: add test for confusing error message for bad modifier

In the expression ${:U}, the variable name is empty. Since these
expressions are generated by .for loops, the error messages for them
must not end with a trailing space. Putting the variable name in quotes
helps against that.
 1.26  23-Feb-2021  rillig make: improve error message for unclosed modifier

Replace "variable specification" with the more modern "variable
expression", reduce the number of parentheses, output more than a single
character for modifiers, make it obvious that in expressions such as
${:Serror}, the "" means a variable name.
 1.25  15-Nov-2020  rillig make(1): update and add comments in tests

As a result of the new comments, some line numbers have changed in the
output of the tests. No other changes.
 1.24  01-Nov-2020  rillig make(1): treat malformed :range, :ts and :[...] as errors

Before, integer overflow in the :[1..2] modifier had not been detected,
and the actual behavior varied between ILP64 and LP64I32 machines.

Before, the :ts modifier accepted character literals like \012345 and
\x1F600, which don't fit in a single character and were thus truncated.

Before, the :range modifier issued an "Unknown modifier" error message
for :range=x, which was not quite correct. The error message in this
case is now "Invalid number".
 1.23  01-Nov-2020  rillig make(1): demonstrate parsing bugs in test moderrs.mk

When a malformed variable expression is parsed, the remaining part of
the expression is passed unmodified to the output. This is unexpected
and wrong.
 1.22  01-Nov-2020  rillig make(1): renumber the tests in moderrs.mk, remove duplicates
 1.21  01-Nov-2020  rillig make(1): make test names in moderrs.mk more descriptive
 1.20  01-Nov-2020  rillig make(1): precisely describe the expected output in the test moderrs.mk

By making "want:" the same length as "make:", the remaining text in
these lines can be compared easily.
 1.19  01-Nov-2020  rillig make(1): separate sections of moderrs.mk with empty lines
 1.18  01-Nov-2020  rillig make(1): add section headings to the test moderrs.mk
 1.17  24-Oct-2020  rillig make(1): use consistent indentation in variable assignments

Initial work by "pkglint -F *.mk", manually adjusted in a few places.
 1.16  24-Oct-2020  rillig make(1): use consistent RCS Id in test files
 1.15  25-Aug-2020  rillig make(1): move test for the ::= modifier to varmod-assign
 1.14  09-Aug-2020  rillig make(1): improve test for undefined subexpression in :C modifier

In the previous test output, it was unnecessarily hard to see what
happens because of the many empty strings. Enclosing the capturing
groups in parentheses helps against this.
 1.13  09-Aug-2020  rillig make(1): add test for undefined subexpression in the :C modifier
 1.12  08-Aug-2020  rillig make(1): improve error message in case of unfinished modifiers

The previous error message "Unclosed substitution" was wrong for several
reasons.

It is not about "unclosed", but about "unfinished" since in the
:@var@...@ modifier the missing '@' does not really close anything.

The word "substitution" may have originated in a time where :S and
:from=to were the only modifiers, and these were indeed substitutions,
but several other modifiers aren't.

The :S and :C modifiers allow an arbitrary delimiter, therefore it is
helpful to enclose the delimiter in quotes, just in case someone chooses
')' or '{' or even ' ' as delimiter.
 1.11  31-Jul-2020  rillig make(1): remove outdated comment from unit test

It had indeed been undefined behavior and was fixed in var.c r1.359 today
in the morning.
 1.10  31-Jul-2020  rillig make(1): add test for parsing an incomplete :t modifier

This looks a lot like undefined behavior, just like in :S and :C before.
 1.9  31-Jul-2020  rillig make(1): fix undefined behavior when parsing malformed :C modifier

Same as in the :S modifier.
 1.8  29-Jul-2020  rillig make(1): fix segfault when evaluating ${::=value}

The bug had been in the handling of the SysV modifier for many years, but
it had not been triggered since the "parsing position for the next
modifier" had been initialized to a non-NULL pointer.

In var.v r1.350, this pointer had been initialized to NULL instead since
every ApplyModifier function must set it in every case where it returns
anything except "default_case".

There might have been a slight chance of tricking make to output a wrong
error message, but nothing worse.
 1.7  29-Jul-2020  rillig make(1): add enough tests to cover the ApplyModifier functions

Only a few return statements are still missing from the code coverage.

In ApplyModifier_Assign, the test for an empty variable name is skipped
for now since it segfaults.

In ApplyModifier_SysV after the second ParseModifierPart, the branch for
the missing delimiter is not reached since this case is already checked
for in the first part of the function. To trigger this branch, a
specially crafted, unrealistic string needs to be created, and that's too
complicated for the moment.
 1.6  29-Jul-2020  rillig make(1): add unit tests for parse errors in modifiers
 1.5  28-Jul-2020  rillig make(1): add test for modifier part with unbalanced braces
 1.4  26-Jul-2020  rillig make(1): add tests for :!...! parse errors
 1.3  26-Jul-2020  rillig make(1): add test for missing input validation in :[123] modifier
 1.2  26-Jul-2020  rillig make(1): add test about missing delimiters in :@ modifier

These error conditions have been broken since var.c 1.236 on 2020-07-03.
 1.1  21-Aug-2014  apb Give each group of tests its own output file.

* Rename each sub-makefile to *.mk;
* Add a *.exp file of expected output for each sub-makefile;
* Remove test.exp, which is replaced by all the other *.exp files.
* Use suffix rules to generate *.rawout and *.out files for
each test case.
* Rewrite the test and accept targets to adapt to the new way.

The old (now removed) test.exp file is almost identical to the
concatenation (in the correct order) of all the new *.exp files. There
are expected differences in makefile names embedded in the output, and
the new "exit status" lines. Some old "*** Error code 1 (ignored)"
lines are also removed (replaced by new "exit status 1" lines).
 1.31.2.2  02-Aug-2025  perseant Sync with HEAD
 1.31.2.1  01-Jul-2024  perseant Sync with HEAD.

RSS XML Feed