Debian Codegraph @

upstream/opensuse-tumbleweed/man3/Test2::Tools::Tester.3pm

raw
1 .\" -*- mode: troff; coding: utf-8 -*-
2 .\" Automatically generated by Pod::Man v6.0.2 (Pod::Simple 3.45)
3 .\"
4 .\" Standard preamble:
5 .\" ========================================================================
6 .de Sp \" Vertical space (when we can't use .PP)
7 .if t .sp .5v
8 .if n .sp
9 ..
10 .de Vb \" Begin verbatim text
11 .ft CW
12 .nf
13 .ne \\$1
14 ..
15 .de Ve \" End verbatim text
16 .ft R
17 .fi
18 ..
19 .\" \*(C` and \*(C' are quotes in nroff, nothing in troff, for use with C<>.
20 .ie n \{\
21 . ds C` ""
22 . ds C' ""
23 'br\}
24 .el\{\
25 . ds C`
26 . ds C'
27 'br\}
28 .\"
29 .\" Escape single quotes in literal strings from groff's Unicode transform.
30 .ie \n(.g .ds Aq \(aq
31 .el .ds Aq '
32 .\"
33 .\" If the F register is >0, we'll generate index entries on stderr for
34 .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index
35 .\" entries marked with X<> in POD. Of course, you'll have to process the
36 .\" output yourself in some meaningful fashion.
37 .\"
38 .\" Avoid warning from groff about undefined register 'F'.
39 .de IX
40 ..
41 .nr rF 0
42 .if \n(.g .if rF .nr rF 1
43 .if (\n(rF:(\n(.g==0)) \{\
44 . if \nF \{\
45 . de IX
46 . tm Index:\\$1\t\\n%\t"\\$2"
47 ..
48 . if !\nF==2 \{\
49 . nr % 0
50 . nr F 2
51 . \}
52 . \}
53 .\}
54 .rr rF
55 .\"
56 .\" Required to disable full justification in groff 1.23.0.
57 .if n .ds AD l
58 .\" ========================================================================
59 .\"
60 .IX Title "Test2::Tools::Tester 3pm"
61 .TH Test2::Tools::Tester 3pm 2026-03-09 "perl v5.42.1" "Perl Programmers Reference Guide"
62 .\" For nroff, turn off justification. Always turn off hyphenation; it makes
63 .\" way too many mistakes in technical documents.
64 .if n .ad l
65 .nh
66 .SH NAME
67 Test2::Tools::Tester \- Tools to help you test other testing tools.
68 .SH DESCRIPTION
69 .IX Header "DESCRIPTION"
70 This is a collection of tools that are useful when testing other test tools.
71 .SH SYNOPSIS
72 .IX Header "SYNOPSIS"
73 .Vb 1
74 \& use Test2::Tools::Tester qw/event_groups filter_events facets/;
75 \&
76 \& use Test2::Tools::Basic qw/plan pass ok/;
77 \& use Test2::Tools::Compare qw/is like/;
78 \&
79 \& my $events = intercept {
80 \& plan 11;
81 \&
82 \& pass(\*(Aqpass\*(Aq);
83 \& ok(1, \*(Aqpass\*(Aq);
84 \&
85 \& is(1, 1, "pass");
86 \& like(1, 1, "pass");
87 \& };
88 \&
89 \& # Grab events generated by tools in Test2::Tools::Basic
90 \& my $basic = filter $events => \*(AqTest2::Tools::Basic\*(Aq;
91 \&
92 \& # Grab events generated by Test2::Tools::Basic;
93 \& my $compare = filter $events => \*(AqTest2::Tools::Compare\*(Aq;
94 \&
95 \& # Grab events generated by tools named \*(Aqok\*(Aq.
96 \& my $oks = filter $events => qr/.*::ok$/;
97 \&
98 \& my $grouped = group_events $events;
99 \& # Breaks events into this structure:
100 \& {
101 \& \*(Aq_\|_NA_\|_\*(Aq => [ ... ],
102 \& \*(AqTest2::Tools::Basic\*(Aq => {
103 \& \*(Aq_\|_ALL_\|_\*(Aq => [ $events\->[0], $events\->[1], $events\->[2] ],
104 \& plan => [ $events\->[0] ],
105 \& pass => [ $events\->[1] ],
106 \& ok => [ $events\->[2] ],
107 \& },
108 \& Test2::Tools::Compare => { ... },
109 \& }
110 \&
111 \& # Get an arrayref of all the assert facets from the list of events.
112 \& my $assert_facets = facets assert => $events;
113 \& # [
114 \& # bless({ details => \*(Aqpass\*(Aq, pass => 1}, \*(AqTest2::EventFacet::Assert\*(Aq),
115 \& # bless({ details => \*(Aqpass\*(Aq, pass => 1}, \*(AqTest2::EventFacet::Assert\*(Aq),
116 \& # ]
117 \&
118 \& # Same, but for info facets
119 \& my $info_facets = facets info => $events;
120 .Ve
121 .SH EXPORTS
122 .IX Header "EXPORTS"
123 No subs are exported by default.
124 .ie n .IP "$array_ref = filter $events => $PACKAGE" 4
125 .el .IP "\f(CW$array_ref\fR = filter \f(CW$events\fR => \f(CW$PACKAGE\fR" 4
126 .IX Item "$array_ref = filter $events => $PACKAGE"
127 .PD 0
128 .ie n .IP "$array_ref = filter $events => $PACKAGE1, $PACKAGE2" 4
129 .el .IP "\f(CW$array_ref\fR = filter \f(CW$events\fR => \f(CW$PACKAGE1\fR, \f(CW$PACKAGE2\fR" 4
130 .IX Item "$array_ref = filter $events => $PACKAGE1, $PACKAGE2"
131 .ie n .IP "$array_ref = filter $events => qr/match/" 4
132 .el .IP "\f(CW$array_ref\fR = filter \f(CW$events\fR => qr/match/" 4
133 .IX Item "$array_ref = filter $events => qr/match/"
134 .ie n .IP "$array_ref = filter $events => qr/match/, $PACKAGE" 4
135 .el .IP "\f(CW$array_ref\fR = filter \f(CW$events\fR => qr/match/, \f(CW$PACKAGE\fR" 4
136 .IX Item "$array_ref = filter $events => qr/match/, $PACKAGE"
137 .PD
138 This function takes an arrayref of events as the first argument. All additional
139 arguments must either be a package name, or a regex. Any event that is
140 generated by a tool in any of the package, or by a tool that matches any of the
141 regexes, will be returned in an arrayref.
142 .ie n .IP "$grouped = group_events($events)" 4
143 .el .IP "\f(CW$grouped\fR = group_events($events)" 4
144 .IX Item "$grouped = group_events($events)"
145 This function iterates all the events in the argument arrayref and splits them
146 into groups. The resulting data structure is:
147 .Sp
148 .Vb 1
149 \& { PACKAGE => { SUBNAME => [ $EVENT1, $EVENT2, ... }}
150 .Ve
151 .Sp
152 If the package of an event is not known it will be put into and arrayref under
153 the \*(Aq_\|_NA_\|_\*(Aq key at the root of the structure. If a sub name is not known it
154 will typically go under the \*(Aq_\|_ANON_\|_\*(Aq key in under the package name.
155 .Sp
156 In addition there is an \*(Aq_\|_ALL_\|_\*(Aq key under each package which stores all of
157 the events sorted into that group.
158 .Sp
159 A more complete example:
160 .Sp
161 .Vb 9
162 \& {
163 \& \*(Aq_\|_NA_\|_\*(Aq => [ $event\->[3] ],
164 \& \*(AqTest2::Tools::Basic\*(Aq => {
165 \& \*(Aq_\|_ALL_\|_\*(Aq => [ $events\->[0], $events\->[1], $events\->[2] ],
166 \& plan => [ $events\->[0] ],
167 \& pass => [ $events\->[1] ],
168 \& ok => [ $events\->[2] ],
169 \& },
170 \& }
171 .Ve
172 .ie n .IP "$arrayref = facets TYPE => $events" 4
173 .el .IP "\f(CW$arrayref\fR = facets TYPE => \f(CW$events\fR" 4
174 .IX Item "$arrayref = facets TYPE => $events"
175 This function will compile a list of all facets of the specified type that are
176 found in the arrayref of events. If the facet has a \f(CW\*(C`Test2::EventFacet::TYPE\*(C'\fR
177 package available then the facet will be constructed into an instance of the
178 class, otherwise it is left as a hashref. Facet Order is preserved.
179 .Sp
180 .Vb 5
181 \& my $assert_facets = facets assert => $events;
182 \& # [
183 \& # bless({ details => \*(Aqpass\*(Aq, pass => 1}, \*(AqTest2::EventFacet::Assert\*(Aq),
184 \& # bless({ details => \*(Aqpass\*(Aq, pass => 1}, \*(AqTest2::EventFacet::Assert\*(Aq),
185 \& # ]
186 .Ve
187 .SH SOURCE
188 .IX Header "SOURCE"
189 The source code repository for Test2\-Suite can be found at
190 \&\fIhttps://github.com/Test\-More/test\-more/\fR.
191 .SH MAINTAINERS
192 .IX Header "MAINTAINERS"
193 .IP "Chad Granum <[email protected]>" 4
194 .IX Item "Chad Granum <[email protected]>"
195 .SH AUTHORS
196 .IX Header "AUTHORS"
197 .IP "Chad Granum <[email protected]>" 4
198 .IX Item "Chad Granum <[email protected]>"
199 .SH COPYRIGHT
200 .IX Header "COPYRIGHT"
201 Copyright Chad Granum <[email protected]>.
202 .PP
203 This program is free software; you can redistribute it and/or
204 modify it under the same terms as Perl itself.
205 .PP
206 See \fIhttp://dev.perl.org/licenses/\fR