Simplified the code to read from the compression I/O in the test suite helper.

This commit is contained in:
依瑪貓 2022-03-19 09:38:15 +08:00
parent 716af0bc85
commit a7143ec9e3

View File

@ -234,12 +234,7 @@ sub read_file($) {
open $FH, $file or die this_file . ": $file: $!"; open $FH, $file or die this_file . ": $file: $!";
$gz = IO::Uncompress::Gunzip->new($FH) $gz = IO::Uncompress::Gunzip->new($FH)
or die this_file . ": $file: $IO::Uncompress::Gunzip::GunzipError"; or die this_file . ": $file: $IO::Uncompress::Gunzip::GunzipError";
while (1) { $content = join "", <$gz>;
($gz->read($_, 10240) != -1)
or die this_file . ": $file: $IO::Uncompress::Gunzip::GunzipError";
$content .= $_;
last if length $_ < 10240;
}
$gz->close or die this_file . ": $file: $IO::Uncompress::Gunzip::GunzipError"; $gz->close or die this_file . ": $file: $IO::Uncompress::Gunzip::GunzipError";
return $content; return $content;
@ -263,12 +258,7 @@ sub read_file($) {
open $FH, $file or die this_file . ": $file: $!"; open $FH, $file or die this_file . ": $file: $!";
$bz = IO::Uncompress::Bunzip2->new($FH) $bz = IO::Uncompress::Bunzip2->new($FH)
or die this_file . ": $file: $IO::Uncompress::Bunzip2::Bunzip2Error"; or die this_file . ": $file: $IO::Uncompress::Bunzip2::Bunzip2Error";
while (1) { $content = join "", <$bz>;
($bz->read($_, 10240) != -1)
or die this_file . ": $file: $IO::Uncompress::Bunzip2::Bunzip2Error";
$content .= $_;
last if length $_ < 10240;
}
$bz->close or die this_file . ": $file: $IO::Uncompress::Bunzip2::Bunzip2Error"; $bz->close or die this_file . ": $file: $IO::Uncompress::Bunzip2::Bunzip2Error";
return $content; return $content;
@ -293,12 +283,7 @@ sub read_file($) {
$xz = IO::Uncompress::UnXz->new($FH) $xz = IO::Uncompress::UnXz->new($FH)
or die this_file . ": $file: $IO::Uncompress::UnXz::UnXzError"; or die this_file . ": $file: $IO::Uncompress::UnXz::UnXzError";
while (1) { $content = join "", <$xz>;
($xz->read($_, 10240) != -1)
or die this_file . ": $file: $IO::Uncompress::UnXz::UnXzError";
$content .= $_;
last if length $_ < 10240;
}
$xz->close or die this_file . ": $file: $IO::Uncompress::UnXz::UnXzError"; $xz->close or die this_file . ": $file: $IO::Uncompress::UnXz::UnXzError";
return $content; return $content;