Commit Graph

31 Commits

Author SHA1 Message Date
rillig da2f1f9711 tests/make: replace 'variable expressions' with 'expressions' 2023-11-19 22:32:44 +00:00
rillig fcb4d29810 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.
2021-06-21 08:28:37 +00:00
rillig 69b903452e 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.
2021-06-21 08:17:39 +00:00
sjg af2dd17048 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
2021-06-21 04:24:17 +00:00
rillig 3429dfe6ac 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.
2021-02-23 16:04:16 +00:00
rillig 985b27d91a 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.
2021-02-23 15:56:29 +00:00
rillig 7c69bb8eca 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.
2020-11-15 20:20:58 +00:00
rillig 480f175d0a 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".
2020-11-01 14:36:25 +00:00
rillig 4d77f4ef94 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.
2020-11-01 10:56:08 +00:00
rillig e415fa14ba make(1): renumber the tests in moderrs.mk, remove duplicates 2020-11-01 10:53:58 +00:00
rillig 87f799f9fd make(1): make test names in moderrs.mk more descriptive 2020-11-01 10:52:09 +00:00
rillig 598a8d140a 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.
2020-11-01 10:50:22 +00:00
rillig 897c76e5e1 make(1): separate sections of moderrs.mk with empty lines 2020-11-01 10:46:34 +00:00
rillig 79ecbf9746 make(1): add section headings to the test moderrs.mk 2020-11-01 10:12:38 +00:00
rillig e4ca099e63 make(1): use consistent indentation in variable assignments
Initial work by "pkglint -F *.mk", manually adjusted in a few places.
2020-10-24 08:50:17 +00:00
rillig 6e02019ca4 make(1): use consistent RCS Id in test files 2020-10-24 08:34:59 +00:00
rillig b8d9af4f48 make(1): move test for the ::= modifier to varmod-assign 2020-08-25 20:49:40 +00:00
rillig cc53a52313 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.
2020-08-09 15:15:29 +00:00
rillig 02fe5d23ee make(1): add test for undefined subexpression in the :C modifier 2020-08-09 15:03:25 +00:00
rillig b1ac54abf1 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.
2020-08-08 13:27:42 +00:00
rillig cab5d20b66 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.
2020-07-31 15:16:05 +00:00
rillig 8ee0af961f make(1): add test for parsing an incomplete :t modifier
This looks a lot like undefined behavior, just like in :S and :C before.
2020-07-31 13:49:25 +00:00
rillig 0da408536e make(1): fix undefined behavior when parsing malformed :C modifier
Same as in the :S modifier.
2020-07-31 13:30:09 +00:00
rillig 9f877327f0 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.
2020-07-29 20:33:38 +00:00
rillig 169ec192ac 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.
2020-07-29 19:48:33 +00:00
rillig f129c52737 make(1): add unit tests for parse errors in modifiers 2020-07-29 18:48:47 +00:00
rillig bc52d07148 make(1): add test for modifier part with unbalanced braces 2020-07-28 00:13:29 +00:00
rillig 9a9cf6b25b make(1): add tests for :!...! parse errors 2020-07-26 14:39:46 +00:00
rillig cd185c3b0e make(1): add test for missing input validation in :[123] modifier 2020-07-26 14:16:45 +00:00
rillig 2ae9c85a43 make(1): add test about missing delimiters in :@ modifier
These error conditions have been broken since var.c 1.236 on 2020-07-03.
2020-07-26 10:04:06 +00:00
apb b9dad2e00f 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).
2014-08-21 13:44:51 +00:00