Up to [cvs.NetBSD.org] / src / usr.bin / make / unit-tests
Request diff between arbitrary revisions
Keyword substitution: kv
Default branch: MAIN
make: in the debug log, always qualify line number with filename Previously, to find out the filename corresponding to a line number from a 'Parsing' line, it was necessary to find the preceding 'SetFilenameVars' line, which was unnecessarily time-consuming and distracting. The 'filename:line' format matches the one used in PrintStackTrace, and it differs from the one used in PrintLocation, as the former format is more common in other tools. Most of the affected unit tests only use the 'Parsing' lines to give additional context to their debug log, so no structural changes there.
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.
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.
make: provide more context information for parse/evaluate errors
make: do not evaluate indirect modifiers in parse-only mode Discovered by sjg.
make: in parse-only mode, don't evaluate modifiers Previously, the ':S', ':ts', ':tA' and ':from=to' modifiers were evaluated in parse-only mode, unnecessarily. This is only noticeable when an indirect modifier is evaluated in parse-only mode, which is another bug that will be fixed in a follow-up commit.
tests/make: extend test for wrong evaluation in parse-only mode
tests/make: indirect modifiers are evaluated in parse-only mode Found by sjg@.
tests/make: force line-based diagnostics to be listed in the tests This way, contradictions between the intended output and the actual output are closer together and have a better chance of being spotted.
make: avoid trailing whitespace in debug log for variables Since trailing whitespace is invisible, describe the variable value in words to make it visible.
make: fix reported line numbers of continuation lines (since 2002) Previously, multi-line directives like '.info' or '.error' reported the line number of their last line instead of their first line, which is more usual. This also affected the debug log from '-dp'.
make: make debug logging a bit more human-friendly The previous log format "ParseReadLine (%d): '%s'" focused on the implementation, it was not immediately obvious to a casual reader that the number in parentheses was the line number. Additionally, having both a colon and quotes in a log message is uncommon. The quotes have been added in parse.c 1.127 from 2007-01-01. The new log format "Parsing line %d: %s" is meant to be easier readable by humans. The quotes are not needed since ParseReadLine always strips trailing whitespace, leaving no room for ambiguities. The other log messages follow common punctuation rules, which makes the beginning of the line equally unambiguous. Before var.c 1.911 from 2021-04-05, variable assignments were logged with the format "%s:%s = %s", without a space after the colon.
make: use correct plural form in debug message
make: reduce debug logging and memory allocation for ${:U...} Expressions of the form ${:U...} are often generated by .for loops. Since these expressions are not generated knowingly by the make user, do not fill the debug log with them since that would interrupt the normal reading flow of the -dv log for nested expressions.
make: in debug log, add space between scope and variable name Without this space, the debug log looked more like line noise, even though the only punctuation was a single innocent ':'. From a make user's perspective, the variable name is a word of its own and should not be visually glued to its namespace.
make: be more verbose in -dv debug logging The previous log output was too brief to be understandable. Give more hints by describing each part of the expression when evaluating a modifier. Distinguish between parse-only mode and eval mode since in parse-only mode most of the details are irrelevant.
make: remove filler word 'Do' from function names for parsing No functional change, except for debug logging.
make: remove VarFlags from debug logging Before the introduction of ExprDefined, VarFlags contained whether the expression was defined or not, which was useful to know since the final value of the expression depends on this information. The other VarFlags do not influence the evaluation, so there is no point logging them.
make: change debug log for variable evaluation flags to lowercase This makes them easier distinguishable from variable names since the latter are usually uppercase. No functional change outside debug mode.
make: improve error message for unknown modifier Back in 1995, the modifiers were all single-character, and it made sense to print only the first character. Nowadays, with ':S', ':@var@...@', '::=' and several others, a little more context is useful to see where the exact error is. The actual modifier is still guessed, and the guess may be wrong as soon as backslashes get involved, but it is still better than before.
make: rename ExprDefined constants for debug logging
make: update line numbers in expected test output The documentation from the previous commit added a few lines.
make: add more tests for edge cases in evaluating variable expressions As a preparation for refactoring the code around variable expressions, there need to be a few tests for indirect variable modifiers since these were not covered before. Indirect modifiers may include ':ts' and ':tW', which change the interpretation of the variable expression in small details. The scope of these changes is limited to the indirect modifier, any evaluations outside this indirect modifier are unaffected. The changes to the .exp file are mostly line number changes, plus a demonstration of a newly found bug, where an expression is evaluated successfully despite producing a parse error.
make: replace VarExprFlags with VarExprStatus The combination of !VEF_UNDEF && VEF_DEF was not possible, which made it rather strange to model this state as a bit set. The only functional change is the renamed constants in the debug output. Using ENUM_VALUE_RTTI_2 felt like overengineering since it's harder to understand than a simple array of names.
make(1): replace global preserveUndefined with VARE_KEEP_UNDEF Controlling the expansion of variable expressions using a global variable and a VARE flag was inconsistent. Converting the global variable into a flag had to prerequisites: 1. The unintended duplicate variable assignment had to be fixed, as done in parse.c 1.520 from 2020-12-27. Without this fix, it would have been necessary to add more flags to Var_Exists and Var_SetWithFlags, and this would have become too complex. 2. There had to be a unit test demonstrating that VARE_KEEP_DOLLAR only applies to the top-level expression and is not passed to the subexpressions, while VARE_KEEP_UNDEF applies to all subexpressions as well. This test is in var-op-expand.mk 1.10 from 2020-12-28, at least for the ':@word@' modifier. In ParseModifierPartSubst, VARE_KEEP_UNDEF is not passed down either, in the same way.
make(1): split test for indirect modifiers into paragraphs
make(1): add tests for parsing indirect modifiers in nested expressions
make(1): remove dead code from ApplyModifiersIndirect At that point, the expression can never be varUndefined. At the beginning of ParseVarnameLong, the expression is initialized to a simple empty string, and that string is only ever converted to varUndefined at the very end of Var_Parse.
make(1): error out on unknown variable modifiers at parse time Before, make printed an "error message" that did not include the word error and thus was not easily identified as such. This "error message" also did not influence the exit status in the default mode but only in -dL mode. The error message also didn't include any line number information and was thus rude.
make(1): move tests for indirect modifiers around The next commit will error out on unknown modifiers and influence the exit status. The test modmisc.mk contains both parse time tests and run time tests. To prevent the latter from being run, the parse error is moved to varmod-indirect.mk, which only contains parse time tests.
make(1): add test and tutorial for indirect modifiers