test1712: introduce mode=warn

Use the mode="warn" attribute if the output curl warning output, as it
then makes the check without newlines and the prefix to better handle
that the lines may wrap at different points depending on the lengths of
the lines and terminal width.
This commit is contained in:
Daniel Stenberg 2026-02-22 12:18:39 +01:00
parent 4c5a9208f5
commit f88bc5cc59
No known key found for this signature in database
GPG key ID: 5CC908FDB71E12C2
3 changed files with 15 additions and 2 deletions

View file

@ -712,12 +712,17 @@ server is used), if `nonewline` is set, we cut off the trailing newline of
this given data before comparing with the one actually sent by the client The
`<strip>` and `<strippart>` rules are applied before comparisons are made.
### `<stderr [mode="text"] [nonewline="yes"] [crlf="yes|headers"]>`
### `<stderr [mode="text/warn"] [nonewline="yes"] [crlf="yes|headers"]>`
This verifies that this data was passed to stderr.
Use the mode="text" attribute if the output is in text mode on platforms that
have a text/binary difference.
Use the mode="warn" attribute if the output curl warning output, as it then
makes the check without newlines and the prefix to better handle that the
lines may wrap at different points depending on the lengths of the lines and
terminal width.
`crlf=yes` forces the newlines to become CRLF even if not written so in the
test.

View file

@ -53,7 +53,7 @@ Content-Type: application/x-www-form-urlencoded
'arg-with-quote'
</protocol>
<stderr mode="text">
<stderr mode="warn">
Warning: %LOGDIR/config:1 Option 'data' uses argument with leading single quote.%SP
Warning: It is probably a mistake. Consider double quotes.
</stderr>

View file

@ -1346,6 +1346,14 @@ sub singletest_check {
normalize_text(\@validstderr);
normalize_text(\@actual);
}
if($filemode && ($filemode eq "warn")) {
map { 's/Warning: //' } (@validstderr);
map { 's/\r//' } (@validstderr);
map { 's/\n/ /' } (@validstderr);
map { 's/Warning: //' } (@actual);
map { 's/\r//' } (@actual);
map { 's/\n/ /' } (@actual);
}
if($hash{'nonewline'}) {
# Yes, we must cut off the final newline from the final line