This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Upgrade to Test::Harness 3.13
[perl5.git] / lib / TAP / Parser / Scheduler / Job.pm
CommitLineData
f7c69158
NC
1package TAP::Parser::Scheduler::Job;
2
3use strict;
4use vars qw($VERSION);
5use Carp;
6
7=head1 NAME
8
9TAP::Parser::Scheduler::Job - A single testing job.
10
11=head1 VERSION
12
13Version 3.13
14
15=cut
16
17$VERSION = '3.13';
18
19=head1 SYNOPSIS
20
21 use TAP::Parser::Scheduler::Job;
22
23=head1 DESCRIPTION
24
25Represents a single test 'job'.
26
27=head1 METHODS
28
29=head2 Class Methods
30
31=head3 C<new>
32
33 my $job = TAP::Parser::Scheduler::Job->new(
34 $name, $desc
35 );
36
37Returns a new C<TAP::Parser::Scheduler::Job> object.
38
39=cut
40
41sub new {
42 my ( $class, $name, $desc, @ctx ) = @_;
43 return bless {
44 filename => $name,
45 description => $desc,
46 context => \@ctx,
47 }, $class;
48}
49
50=head3 C<on_finish>
51
52Register a closure to be called when this job is destroyed.
53
54=cut
55
56sub on_finish {
57 my ( $self, $cb ) = @_;
58 $self->{on_finish} = $cb;
59}
60
61=head3 C<finish>
62
63Called when a job is complete to unlock it.
64
65=cut
66
67sub finish {
68 my $self = shift;
69 if ( my $cb = $self->{on_finish} ) {
70 $cb->($self);
71 }
72}
73
74=head3 C<filename>
75
76=head3 C<description>
77
78=head3 C<context>
79
80=cut
81
82sub filename { shift->{filename} }
83sub description { shift->{description} }
84sub context { @{ shift->{context} } }
85
86=head3 C<as_array_ref>
87
88For backwards compatibility in callbacks.
89
90=cut
91
92sub as_array_ref {
93 my $self = shift;
94 return [ $self->filename, $self->description, $self->context ];
95}
96
97=head3 C<is_spinner>
98
99Returns false indicating that this is a real job rather than a
100'spinner'. Spinners are returned when the scheduler still has pending
101jobs but can't (because of locking) return one right now.
102
103=cut
104
105sub is_spinner {0}
106
1071;