our
$VERSION
=
'0.001063'
;
-_complete
-job_id
-run_id
-dir
-keep_dir
-last_poll
}
;
sub
init {
my
$self
=
shift
;
$self
->SUPER::init();
croak
"'job_id' is a required attribute"
unless
$self
->{+JOB_ID};
croak
"'run_id' is a required attribute"
unless
$self
->{+RUN_ID};
my
$dir
=
$self
->{+DIR} or croak
"'dir' is a required attribute"
;
unless
(blessed(
$dir
) &&
$dir
->isa(
'Test2::Harness::Job::Dir'
)) {
croak
"'dir' must be a valid directory"
unless
-d
$dir
;
$dir
=
$self
->{+DIR} = Test2::Harness::Job::Dir->new(
job_root
=>
$dir
,
run_id
=>
$self
->{+RUN_ID},
job_id
=>
$self
->{+JOB_ID},
);
}
}
sub
poll {
my
$self
=
shift
;
my
(
$max
) =
@_
;
$self
->{+LAST_POLL} =
time
;
return
if
$self
->{+_COMPLETE};
my
@events
=
$self
->{+DIR}->poll(
$max
);
return
@events
;
}
sub
set_runner_exited {
my
$self
=
shift
;
my
$dir
=
$self
->{+DIR} or
return
;
$dir
->set_runner_exited(
$_
[1]);
}
sub
set_complete {
my
$self
=
shift
;
$self
->{+_COMPLETE} = 1;
my
$job_root
=
$self
->{+DIR}->job_root;
delete
$self
->{+DIR};
remove_tree(
$job_root
, {
safe
=> 1,
keep_root
=> 0})
unless
$self
->{+KEEP_DIR};
return
$self
->{+_COMPLETE};
}
sub
complete {
my
$self
=
shift
;
return
$self
->{+_COMPLETE};
}
1;