our
$VERSION
=
'0.001063'
;
sub
complete { 1 }
sub
init {
my
$self
=
shift
;
$self
->SUPER::init();
my
$file
=
delete
$self
->{+FILE} or croak
"'file' is a required attribute"
;
my
$fh
;
if
(
$file
=~ m/\.bz2$/) {
$fh
= IO::Uncompress::Bunzip2->new(
$file
) or
die
"Could not open bz2 file '$file': $Bunzip2Error"
;
}
elsif
(
$file
=~ m/\.gz/) {
$fh
= IO::Uncompress::Gunzip2->new(
$file
) or
die
"Could not open gz file '$file': $GunzipError"
;
}
else
{
$fh
= open_file(
$file
,
'<'
);
}
$self
->{+FILE} = Test2::Harness::Util::File::JSONL->new(
name
=>
$file
,
fh
=>
$fh
,
);
}
sub
poll {
my
$self
=
shift
;
my
(
$max
) =
@_
;
my
@out
;
while
(
my
$line
=
$self
->{+FILE}->read_line) {
my
$watcher
=
delete
$line
->{facet_data}->{harness_watcher};
next
if
$watcher
->{added_by_watcher};
bless
(
$line
->{facet_data}->{harness_run},
'Test2::Harness::Run'
)
if
$line
->{facet_data}->{harness_run};
bless
(
$line
->{facet_data}->{harness_job},
'Test2::Harness::Job'
)
if
$line
->{facet_data}->{harness_job};
if
(
my
$errors
=
$line
->{facet_data}->{errors}) {
@$errors
=
grep
{!
$_
->{from_harness}}
@$errors
;
}
push
@out
=> Test2::Harness::Event->new(
%$line
);
last
if
$max
&&
@out
>=
$max
}
return
@out
;
}
1;