Debian Codegraph @

lib/App/Yath/Command/auditor.pm

raw
1 package App::Yath::Command::auditor;
2 use strict;
3 use warnings;
4
5 our $VERSION = '1.000179';
6
7 use File::Spec;
8 use Scalar::Util qw/blessed/;
9
10 use App::Yath::Util qw/isolate_stdout/;
11
12 use Test2::Harness::Util::JSON qw/decode_json encode_json/;
13 use Test2::Harness::Util qw/mod2file/;
14
15 use Test2::Harness::Run;
16 use Test2::Harness::Stall::Trace qw/install_trace_handler/;
17
18 use parent 'App::Yath::Command';
19 use Test2::Harness::Util::HashBase;
20
21 sub internal_only { 1 }
22 sub summary { "For internal use only" }
23 sub name { 'auditor' }
24
25 sub run {
26 my $self = shift;
27 my ($auditor_class, $run_id, %args) = @{$self->{+ARGS}};
28
29 my $name = 'yath-auditor';
30 $name = "$args{procname_prefix}-${name}" if $args{procname_prefix};
31 $0 = $name;
32
33 my $fh = isolate_stdout();
34
35 install_trace_handler($args{stall_dir}) if $args{stall_dir};
36
37 require(mod2file($auditor_class));
38
39 my $auditor = $auditor_class->new(
40 %args,
41 run_id => $run_id,
42 action => sub { print $fh defined($_[0]) ? blessed($_[0]) ? $_[0]->as_json . "\n" : encode_json($_[0]) . "\n" : "null\n" },
43 );
44
45 local $SIG{PIPE} = 'IGNORE';
46 my $ok = eval { $auditor->process(); 1 };
47 my $err = $@;
48
49 eval { $auditor->finish(); 1 } or warn $@;
50
51 die $err unless $ok;
52
53 return 0;
54 }
55
56 1;
57
58 __END__
59
60 =pod
61
62 =encoding UTF-8
63
64 =head1 NAME
65
66 App::Yath::Command::auditor - For internal use only
67
68 =head1 DESCRIPTION
69
70 No Description
71
72 =head1 USAGE
73
74 $ yath [YATH OPTIONS] auditor [COMMAND OPTIONS]
75
76 =head2 YATH OPTIONS
77
78 =head3 Developer
79
80 =over 4
81
82 =item --dev-lib
83
84 =item --dev-lib=lib
85
86 =item -D
87
88 =item -D=lib
89
90 =item -Dlib
91
92 =item --no-dev-lib
93
94 Add paths to @INC before loading ANYTHING. This is what you use if you are developing yath or yath plugins to make sure the yath script finds the local code instead of the installed versions of the same code. You can provide an argument (-Dfoo) to provide a custom path, or you can just use -D without and arg to add lib, blib/lib and blib/arch.
95
96 Can be specified multiple times
97
98
99 =back
100
101 =head3 Environment
102
103 =over 4
104
105 =item --persist-dir ARG
106
107 =item --persist-dir=ARG
108
109 =item --no-persist-dir
110
111 Where to find persistence files.
112
113
114 =item --persist-file ARG
115
116 =item --persist-file=ARG
117
118 =item --pfile ARG
119
120 =item --pfile=ARG
121
122 =item --no-persist-file
123
124 Where to find the persistence file. The default is /{system-tempdir}/project-yath-persist.json. If no project is specified then it will fall back to the current directory. If the current directory is not writable it will default to /tmp/yath-persist.json which limits you to one persistent runner on your system.
125
126
127 =item --project ARG
128
129 =item --project=ARG
130
131 =item --project-name ARG
132
133 =item --project-name=ARG
134
135 =item --no-project
136
137 This lets you provide a label for your current project/codebase. This is best used in a .yath.rc file. This is necessary for a persistent runner.
138
139
140 =back
141
142 =head3 Help and Debugging
143
144 =over 4
145
146 =item --show-opts
147
148 =item --no-show-opts
149
150 Exit after showing what yath thinks your options mean
151
152
153 =item --version
154
155 =item -V
156
157 =item --no-version
158
159 Exit after showing a helpful usage message
160
161
162 =back
163
164 =head3 Plugins
165
166 =over 4
167
168 =item --no-scan-plugins
169
170 =item --no-no-scan-plugins
171
172 Normally yath scans for and loads all App::Yath::Plugin::* modules in order to bring in command-line options they may provide. This flag will disable that. This is useful if you have a naughty plugin that is loading other modules when it should not.
173
174
175 =item --plugins PLUGIN
176
177 =item --plugins +App::Yath::Plugin::PLUGIN
178
179 =item --plugins PLUGIN=arg1,arg2,...
180
181 =item --plugin PLUGIN
182
183 =item --plugin +App::Yath::Plugin::PLUGIN
184
185 =item --plugin PLUGIN=arg1,arg2,...
186
187 =item -pPLUGIN
188
189 =item --no-plugins
190
191 Load a yath plugin.
192
193 Can be specified multiple times
194
195
196 =back
197
198 =head2 COMMAND OPTIONS
199
200 =head3 Cover Options
201
202 =over 4
203
204 =item --cover-aggregator ByTest
205
206 =item --cover-aggregator ByRun
207
208 =item --cover-aggregator +Custom::Aggregator
209
210 =item --cover-agg ByTest
211
212 =item --cover-agg ByRun
213
214 =item --cover-agg +Custom::Aggregator
215
216 =item --no-cover-aggregator
217
218 Choose a custom aggregator subclass
219
220
221 =item --cover-class ARG
222
223 =item --cover-class=ARG
224
225 =item --no-cover-class
226
227 Choose a Test2::Plugin::Cover subclass
228
229
230 =item --cover-dirs ARG
231
232 =item --cover-dirs=ARG
233
234 =item --cover-dir ARG
235
236 =item --cover-dir=ARG
237
238 =item --no-cover-dirs
239
240 NO DESCRIPTION - FIX ME
241
242 Can be specified multiple times
243
244
245 =item --cover-exclude-dirs ARG
246
247 =item --cover-exclude-dirs=ARG
248
249 =item --cover-exclude-dir ARG
250
251 =item --cover-exclude-dir=ARG
252
253 =item --no-cover-exclude-dirs
254
255 Directory to leave out of file coverage and coverage metrics, along with everything under it at any depth. May be specified multiple times. Wildcards are expanded when the option is parsed, so a pattern matching nothing excludes nothing. Values are word-split first, so a path containing whitespace must be quoted or backslash-escaped. A resolved path may not contain a comma.
256
257 Can be specified multiple times
258
259
260 =item --cover-exclude-private
261
262 =item --no-cover-exclude-private
263
264
265
266
267 =item --cover-files
268
269 =item --no-cover-files
270
271 Use Test2::Plugin::Cover to collect coverage data for what files are touched by what tests. Unlike Devel::Cover this has very little performance impact (About 4% difference)
272
273
274 =item --cover-from path/to/log.jsonl
275
276 =item --cover-from http://example.com/coverage
277
278 =item --cover-from path/to/coverage.jsonl
279
280 =item --no-cover-from
281
282 This can be a test log, a coverage dump (old style json or new jsonl format), or a url to any of the previous. Tests will not be run if the file/url is invalid.
283
284
285 =item --cover-from-type json
286
287 =item --cover-from-type jsonl
288
289 =item --cover-from-type log
290
291 =item --no-cover-from-type
292
293 File type for coverage source. Usually it can be detected, but when it cannot be you should specify. "json" is old style single-blob coverage data, "jsonl" is the new by-test style, "log" is a logfile from a previous run.
294
295
296 =item --cover-manager My::Coverage::Manager
297
298 =item --no-cover-manager
299
300 Coverage 'from' manager to use when coverage data does not provide one
301
302
303 =item --cover-maybe-from path/to/log.jsonl
304
305 =item --cover-maybe-from http://example.com/coverage
306
307 =item --cover-maybe-from path/to/coverage.jsonl
308
309 =item --no-cover-maybe-from
310
311 This can be a test log, a coverage dump (old style json or new jsonl format), or a url to any of the previous. Tests will continue even if the coverage file/url is invalid.
312
313
314 =item --cover-maybe-from-type json
315
316 =item --cover-maybe-from-type jsonl
317
318 =item --cover-maybe-from-type log
319
320 =item --no-cover-maybe-from-type
321
322 Same as "from_type" but for "maybe_from". Defaults to "from_type" if that is specified, otherwise auto-detect
323
324
325 =item --cover-metrics
326
327 =item --no-cover-metrics
328
329
330
331
332 =item --cover-types ARG
333
334 =item --cover-types=ARG
335
336 =item --cover-type ARG
337
338 =item --cover-type=ARG
339
340 =item --no-cover-types
341
342 NO DESCRIPTION - FIX ME
343
344 Can be specified multiple times
345
346
347 =item --cover-write
348
349 =item --cover-write=coverage.jsonl
350
351 =item --cover-write=coverage.json
352
353 =item --no-cover-write
354
355 Create a json or jsonl file of all coverage data seen during the run (This implies --cover-files).
356
357
358 =back
359
360 =head3 Git Options
361
362 =over 4
363
364 =item --git-change-base master
365
366 =item --git-change-base HEAD^
367
368 =item --git-change-base df22abe4
369
370 =item --no-git-change-base
371
372 Find files changed by all commits in the current branch from most recent stopping when a commit is found that is also present in the history of the branch/commit specified as the change base.
373
374
375 =back
376
377 =head3 Help and Debugging
378
379 =over 4
380
381 =item --dummy
382
383 =item -d
384
385 =item --no-dummy
386
387 Dummy run, do not actually execute anything
388
389 Can also be set with the following environment variables: C<T2_HARNESS_DUMMY>
390
391
392 =item --help
393
394 =item -h
395
396 =item --no-help
397
398 exit after showing help information
399
400
401 =item --interactive
402
403 =item -i
404
405 =item --no-interactive
406
407 Use interactive mode, 1 test at a time, stdin forwarded to it
408
409
410 =item --keep-dirs
411
412 =item --keep_dir
413
414 =item -k
415
416 =item --no-keep-dirs
417
418 Do not delete directories when done. This is useful if you want to inspect the directories used for various commands.
419
420
421 =item --procname-prefix ARG
422
423 =item --procname-prefix=ARG
424
425 =item --no-procname-prefix
426
427 Add a prefix to all proc names (as seen by ps).
428
429
430 =back
431
432 =head3 YathUI Options
433
434 =over 4
435
436 =item --yathui-api-key ARG
437
438 =item --yathui-api-key=ARG
439
440 =item --no-yathui-api-key
441
442 Yath-UI API key. This is not necessary if your Yath-UI instance is set to single-user
443
444
445 =item --yathui-grace
446
447 =item --no-yathui-grace
448
449 If yath cannot connect to yath-ui it normally throws an error, use this to make it fail gracefully. You get a warning, but things keep going.
450
451
452 =item --yathui-long-duration 10
453
454 =item --no-yathui-long-duration
455
456 Minimum duration length (seconds) before a test goes from MEDIUM to LONG
457
458
459 =item --yathui-medium-duration 5
460
461 =item --no-yathui-medium-duration
462
463 Minimum duration length (seconds) before a test goes from SHORT to MEDIUM
464
465
466 =item --yathui-mode summary
467
468 =item --yathui-mode qvf
469
470 =item --yathui-mode qvfd
471
472 =item --yathui-mode complete
473
474 =item --no-yathui-mode
475
476 Set the upload mode (default 'qvfd')
477
478
479 =item --yathui-project ARG
480
481 =item --yathui-project=ARG
482
483 =item --no-yathui-project
484
485 The Yath-UI project for your test results
486
487
488 =item --yathui-retry
489
490 =item --no-yathui-retry
491
492 How many times to try an operation before giving up
493
494 Can be specified multiple times
495
496
497 =item --yathui-url http://my-yath-ui.com/...
498
499 =item --uri http://my-yath-ui.com/...
500
501 =item --no-yathui-url
502
503 Yath-UI url
504
505
506 =back
507
508 =head1 SOURCE
509
510 The source code repository for Test2-Harness can be found at
511 F<http://github.com/Test-More/Test2-Harness/>.
512
513 =head1 MAINTAINERS
514
515 =over 4
516
517 =item Chad Granum E<lt>[email protected]<gt>
518
519 =back
520
521 =head1 AUTHORS
522
523 =over 4
524
525 =item Chad Granum E<lt>[email protected]<gt>
526
527 =back
528
529 =head1 COPYRIGHT
530
531 Copyright 2026 Chad Granum E<lt>[email protected]<gt>.
532
533 This program is free software; you can redistribute it and/or
534 modify it under the same terms as Perl itself.
535
536 See F<http://dev.perl.org/licenses/>
537
538 =cut
539