mirror of
https://github.com/curl/curl.git
synced 2025-09-15 16:42:41 +03:00
runtests: move showdiff into runtests.pl
It's not used anywhere else.
This commit is contained in:
parent
20fa5b74a5
commit
a8706fd8d0
|
@ -31,16 +31,15 @@ BEGIN {
|
||||||
use base qw(Exporter);
|
use base qw(Exporter);
|
||||||
|
|
||||||
our @EXPORT = qw(
|
our @EXPORT = qw(
|
||||||
getpartattr
|
|
||||||
getpart
|
|
||||||
partexists
|
|
||||||
loadtest
|
|
||||||
fulltest
|
|
||||||
striparray
|
|
||||||
compareparts
|
compareparts
|
||||||
writearray
|
fulltest
|
||||||
|
getpart
|
||||||
|
getpartattr
|
||||||
loadarray
|
loadarray
|
||||||
showdiff
|
loadtest
|
||||||
|
partexists
|
||||||
|
striparray
|
||||||
|
writearray
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -356,44 +355,5 @@ sub loadarray {
|
||||||
return @array;
|
return @array;
|
||||||
}
|
}
|
||||||
|
|
||||||
# Given two array references, this function will store them in two temporary
|
|
||||||
# files, run 'diff' on them, store the result and return the diff output!
|
|
||||||
|
|
||||||
sub showdiff {
|
|
||||||
my ($logdir, $firstref, $secondref)=@_;
|
|
||||||
|
|
||||||
my $file1="$logdir/check-generated";
|
|
||||||
my $file2="$logdir/check-expected";
|
|
||||||
|
|
||||||
open(my $temp, ">", "$file1") || die "Failure writing diff file";
|
|
||||||
for(@$firstref) {
|
|
||||||
my $l = $_;
|
|
||||||
$l =~ s/\r/[CR]/g;
|
|
||||||
$l =~ s/\n/[LF]/g;
|
|
||||||
$l =~ s/([^\x20-\x7f])/sprintf "%%%02x", ord $1/eg;
|
|
||||||
print $temp $l;
|
|
||||||
print $temp "\n";
|
|
||||||
}
|
|
||||||
close($temp) || die "Failure writing diff file";
|
|
||||||
|
|
||||||
open($temp, ">", "$file2") || die "Failure writing diff file";
|
|
||||||
for(@$secondref) {
|
|
||||||
my $l = $_;
|
|
||||||
$l =~ s/\r/[CR]/g;
|
|
||||||
$l =~ s/\n/[LF]/g;
|
|
||||||
$l =~ s/([^\x20-\x7f])/sprintf "%%%02x", ord $1/eg;
|
|
||||||
print $temp $l;
|
|
||||||
print $temp "\n";
|
|
||||||
}
|
|
||||||
close($temp) || die "Failure writing diff file";
|
|
||||||
my @out = `diff -u $file2 $file1 2>/dev/null`;
|
|
||||||
|
|
||||||
if(!$out[0]) {
|
|
||||||
@out = `diff -c $file2 $file1 2>/dev/null`;
|
|
||||||
}
|
|
||||||
|
|
||||||
return @out;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
1;
|
1;
|
||||||
|
|
|
@ -297,6 +297,47 @@ sub cleardir {
|
||||||
return $done;
|
return $done;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#######################################################################
|
||||||
|
# Given two array references, this function will store them in two temporary
|
||||||
|
# files, run 'diff' on them, store the result and return the diff output!
|
||||||
|
sub showdiff {
|
||||||
|
my ($logdir, $firstref, $secondref)=@_;
|
||||||
|
|
||||||
|
my $file1="$logdir/check-generated";
|
||||||
|
my $file2="$logdir/check-expected";
|
||||||
|
|
||||||
|
open(my $temp, ">", "$file1") || die "Failure writing diff file";
|
||||||
|
for(@$firstref) {
|
||||||
|
my $l = $_;
|
||||||
|
$l =~ s/\r/[CR]/g;
|
||||||
|
$l =~ s/\n/[LF]/g;
|
||||||
|
$l =~ s/([^\x20-\x7f])/sprintf "%%%02x", ord $1/eg;
|
||||||
|
print $temp $l;
|
||||||
|
print $temp "\n";
|
||||||
|
}
|
||||||
|
close($temp) || die "Failure writing diff file";
|
||||||
|
|
||||||
|
open($temp, ">", "$file2") || die "Failure writing diff file";
|
||||||
|
for(@$secondref) {
|
||||||
|
my $l = $_;
|
||||||
|
$l =~ s/\r/[CR]/g;
|
||||||
|
$l =~ s/\n/[LF]/g;
|
||||||
|
$l =~ s/([^\x20-\x7f])/sprintf "%%%02x", ord $1/eg;
|
||||||
|
print $temp $l;
|
||||||
|
print $temp "\n";
|
||||||
|
}
|
||||||
|
close($temp) || die "Failure writing diff file";
|
||||||
|
my @out = `diff -u $file2 $file1 2>/dev/null`;
|
||||||
|
|
||||||
|
if(!$out[0]) {
|
||||||
|
@out = `diff -c $file2 $file1 2>/dev/null`;
|
||||||
|
}
|
||||||
|
|
||||||
|
return @out;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
#######################################################################
|
#######################################################################
|
||||||
# compare test results with the expected output, we might filter off
|
# compare test results with the expected output, we might filter off
|
||||||
# some pattern that is allowed to differ, output test results
|
# some pattern that is allowed to differ, output test results
|
||||||
|
|
Loading…
Reference in New Issue
Block a user