Debian Codegraph @

lib/Test2/Harness/Run.pm

raw
1 package Test2::Harness::Run;
2 use strict;
3 use warnings;
4
5 our $VERSION = '1.000179';
6
7 use Carp qw/croak/;
8
9 use File::Spec;
10
11 use Test2::Harness::Util::HashBase qw{
12 <run_id
13
14 <env_vars <author_testing <unsafe_inc
15
16 <links
17
18 <event_uuids
19 <use_stream
20 <mem_usage
21 <io_events
22
23 <dbi_profiling
24
25 <input <input_file <test_args
26
27 <load <load_import
28
29 <fields <meta
30
31 <retry <retry_isolated
32 };
33
34 sub init {
35 my $self = shift;
36
37 croak "run_id is required"
38 unless $self->{+RUN_ID};
39 }
40
41 sub run_dir {
42 my $self = shift;
43 my ($workdir) = @_;
44 return File::Spec->catfile($workdir, $self->{+RUN_ID});
45 }
46
47 sub TO_JSON { +{ %{$_[0]} } }
48
49 sub queue_item {
50 my $self = shift;
51 my ($plugins) = @_;
52
53 croak "a plugins arrayref is required" unless $plugins;
54
55 my $out = {%$self};
56
57 my $meta = $out->{+META} //= {};
58 my $fields = $out->{+FIELDS} //= [];
59 for my $p (@$plugins) {
60 $p->inject_run_data(meta => $meta, fields => $fields, run => $self);
61 }
62
63 return $out;
64 }
65
66 1;
67
68 __END__
69
70
71 =pod
72
73 =encoding UTF-8
74
75 =head1 NAME
76
77 Test2::Harness::Run - Representation of a set of tests to run, and their
78 options.
79
80 =head1 DESCRIPTION
81
82 =head1 ATTRIBUTES
83
84 These are set at construction time and cannot be modified.
85
86 See L<App::Yath::Options::Run> for more documentation on these.
87
88 =head2 FROM OPTIONS
89
90 =over 4
91
92 =item $bool = $run->author_testing
93
94 =item $hashref = $run->env_vars
95
96 =item $bool = $run->event_uuids
97
98 =item $arrayref = $run->fields
99
100 =item $string = $run->input
101
102 =item $path = $run->input_file
103
104 =item $bool = $run->io_events
105
106 =item $arrayref = $run->links
107
108 =item $arrayref = $run->load
109
110 =item $hashref = $run->load_import
111
112 =item $bool = $run->mem_usage
113
114 =item $int = $run->retry
115
116 =item $bool = $run->retry_isolated
117
118 =item $string = $run->run_id
119
120 =item $arrayref = $run->test_args
121
122 =item $bool = $run->unsafe_inc
123
124 =item $bool = $run->use_stream
125
126 =back
127
128 =head2 OTHER
129
130 =over 4
131
132 =item $hashref = $run->meta
133
134 meta-data plugins may have attached.
135
136 =back
137
138 =head1 METHODS
139
140 =over 4
141
142 =item $path = $run->run_dir($workdir)
143
144 Returns the path C<"$workdir/$run_id">.
145
146 =item $hashref = $run->queue_item(\@PLUGINS)
147
148 Gets the queue item that represents this object.
149
150 =back
151
152 =head1 SOURCE
153
154 The source code repository for Test2-Harness can be found at
155 F<http://github.com/Test-More/Test2-Harness/>.
156
157 =head1 MAINTAINERS
158
159 =over 4
160
161 =item Chad Granum E<lt>[email protected]<gt>
162
163 =back
164
165 =head1 AUTHORS
166
167 =over 4
168
169 =item Chad Granum E<lt>[email protected]<gt>
170
171 =back
172
173 =head1 COPYRIGHT
174
175 Copyright 2020 Chad Granum E<lt>[email protected]<gt>.
176
177 This program is free software; you can redistribute it and/or
178 modify it under the same terms as Perl itself.
179
180 See F<http://dev.perl.org/licenses/>
181
182 =cut