runtests: remove "has_textaware"

All sections defined with the mode="text" attribute now get line endings
normalized so that comparisons become line ending agnostic. Removes the
previous problem of figuring out how exactly different Windows
environments should be treated in this regard.

Closes #14717
This commit is contained in:
Daniel Stenberg 2024-08-29 16:00:21 +02:00
parent eeb7c12807
commit 3cf45fedc4
No known key found for this signature in database
GPG Key ID: 5CC908FDB71E12C2

View File

@ -132,9 +132,6 @@ my $ftp_ipv6; # set if FTP server has IPv6 support
my $resolver; # name of the resolver backend (for human presentation)
my $has_textaware; # set if running on a system that has a text mode concept
# on files. Windows for example
my %skipped; # skipped{reason}=counter, reasons for skip
my @teststat; # teststat[testnum]=reason, reasons for skip
my %disabled_keywords; # key words of tests to skip
@ -539,7 +536,6 @@ sub checksystemfeatures {
# This is a Windows MinGW build or native build, we need to use
# Windows-style path.
$pwd = sys_native_current_path();
$has_textaware = 1;
$feature{"win32"} = 1;
# set if built with MinGW (as opposed to MinGW-w64)
$feature{"MinGW"} = 1 if ($curl =~ /-pc-mingw32/);
@ -1199,6 +1195,12 @@ sub singletest_count {
return 0;
}
# Make sure all line endings in the array are the same: CRLF
sub normalize_text {
my ($ref) = @_;
s/\r\n/\n/g for @$ref;
s/\n/\r\n/g for @$ref;
}
#######################################################################
# Verify test succeeded
@ -1257,12 +1259,9 @@ sub singletest_check {
# get the mode attribute
my $filemode=$hash{'mode'};
if($filemode && ($filemode eq "text") && $has_textaware) {
# text mode when running on Windows: fix line endings
s/\r\n/\n/g for @validstdout;
s/\n/\r\n/g for @validstdout;
s/\r\n/\n/g for @actual;
s/\n/\r\n/g for @actual;
if($filemode && ($filemode eq "text")) {
normalize_text(\@validstdout);
normalize_text(\@actual);
}
if($hash{'nonewline'}) {
@ -1315,12 +1314,11 @@ sub singletest_check {
# text mode check in hyper-mode. Sometimes necessary if the stderr
# data *looks* like HTTP and thus has gotten CRLF newlines
# mistakenly
s/\r\n/\n/g for @validstderr;
normalize_text(\@validstderr);
}
if($filemode && ($filemode eq "text") && $has_textaware) {
# text mode when running on Windows: fix line endings
s/\r\n/\n/g for @validstderr;
s/\n/\r\n/g for @validstderr;
if($filemode && ($filemode eq "text")) {
normalize_text(\@validstderr);
normalize_text(\@actual);
}
if($hash{'nonewline'}) {
@ -1412,10 +1410,8 @@ sub singletest_check {
my %replycheckpartattr = getpartattr("reply", "datacheck".$partsuffix);
# get the mode attribute
my $filemode=$replycheckpartattr{'mode'};
if($filemode && ($filemode eq "text") && $has_textaware) {
# text mode when running on Windows: fix line endings
s/\r\n/\n/g for @replycheckpart;
s/\n/\r\n/g for @replycheckpart;
if($filemode && ($filemode eq "text")) {
normalize_text(\@replycheckpart);
}
if($replycheckpartattr{'nonewline'}) {
# Yes, we must cut off the final newline from the final line
@ -1442,10 +1438,8 @@ sub singletest_check {
}
# get the mode attribute
my $filemode=$replyattr{'mode'};
if($filemode && ($filemode eq "text") && $has_textaware) {
# text mode when running on Windows: fix line endings
s/\r\n/\n/g for @reply;
s/\n/\r\n/g for @reply;
if($filemode && ($filemode eq "text")) {
normalize_text(\@reply);
}
if($replyattr{'crlf'} ||
($feature{"hyper"} && ($keywords{"HTTP"}
@ -1457,6 +1451,12 @@ sub singletest_check {
if(!$replyattr{'nocheck'} && (@reply || $replyattr{'sendzero'})) {
# verify the received data
my @out = loadarray($CURLOUT);
# get the mode attribute
my $filemode=$replyattr{'mode'};
if($filemode && ($filemode eq "text")) {
normalize_text(\@out);
}
$res = compare($runnerid, $testnum, $testname, "data", \@out, \@reply);
if ($res) {
return -1;
@ -1586,10 +1586,9 @@ sub singletest_check {
my @stripfilepar = getpart("verify", "stripfile".$partsuffix);
my $filemode=$hash{'mode'};
if($filemode && ($filemode eq "text") && $has_textaware) {
# text mode when running on Windows: fix line endings
s/\r\n/\n/g for @outfile;
s/\n/\r\n/g for @outfile;
if($filemode && ($filemode eq "text")) {
normalize_text(\@outfile);
normalize_text(\@generated);
}
if($hash{'crlf'} ||
($feature{"hyper"} && ($keywords{"HTTP"}