Debian Codegraph @

lib/App/Yath/Command/status.pm

raw
1 package App::Yath::Command::status;
2 use strict;
3 use warnings;
4
5 our $VERSION = '1.000179';
6
7 use Term::Table();
8 use File::Spec();
9
10 use Test2::Harness::Runner::State;
11 use Test2::Harness::Util::File::JSON();
12 use Test2::Harness::Util::Queue();
13
14 use parent 'App::Yath::Command::run';
15 use Test2::Harness::Util::HashBase;
16
17 sub group { 'persist' }
18
19 sub summary { "Status info and process lists for the runner" }
20 sub cli_args { "" }
21
22 sub description {
23 return <<" EOT";
24 This command will provide health details and a process list for the runner.
25 EOT
26 }
27
28 sub pfile_params { (no_fatal => 1) }
29
30 sub run {
31 my $self = shift;
32
33 my $data = $self->pfile_data();
34
35 my $state = Test2::Harness::Runner::State->new(
36 workdir => $self->workdir,
37 observe => 1,
38 );
39
40 $state->poll;
41
42 print "\n**** Pending tests: ****\n";
43 my $pending = $state->pending_tasks;
44 for my $run ($state->run, @{$state->pending_runs // []}) {
45 next unless $run;
46 my $run_id =$run->{run_id} or next;
47
48 print "\nRun $run_id:\n";
49 my $pending = $pending->{$run_id} // {};
50 my @tasks;
51 my @check = ($pending);
52 while (my $it = shift @check) {
53 my $ref = ref($it);
54
55 if ($ref eq 'ARRAY') {
56 push @check => @$it;
57 next;
58 }
59
60 if ($ref eq 'HASH') {
61 if ($it->{job_id}) {
62 push @tasks => $it;
63 next;
64 }
65
66 push @check => values %$it;
67 next;
68 }
69 }
70
71 if (!@tasks) {
72 print "--No pending tasks for this run--\n";
73 next;
74 }
75
76 my @rows = map {[$_->{job_id}, $_->{is_try} // $_->{job_try} // 0, $_->{rel_file}, join(', ' => @{$_->{conflicts} // []}), join(', ' => @{$_->{shares} // []})]} @tasks;
77 my $run_table = Term::Table->new(
78 collapse => 1,
79 header => [qw/uuid try test conflicts shares/],
80 rows => [ sort { $a->[2] cmp $b->[2] } @rows ],
81 );
82
83 print "$_\n" for $run_table->render;
84 }
85
86 print "\n**** Runner Stages: ****\n";
87 my $stage_status = $state->stage_readiness // {};
88 my $reload_status = $state->reload_state // {};
89 my $reload_issues = 0;
90
91 my $rows = [];
92 for my $stage (keys %$stage_status) {
93 my $pid = $stage_status->{$stage} ||= '';
94 my $ready = $pid ? 'YES' : 'NO';
95 $pid = 'N/A' if $pid && $pid == 1;
96
97 my $issues = keys %{$reload_status->{$stage}};
98 my $reload = $issues ? 'YES' : 'NO';
99 $reload_issues += $issues;
100
101 push @$rows => [$pid, $stage, $ready, $reload];
102 }
103
104 @$rows = sort { $a->[0] <=> $b->[0] } @$rows;
105
106 my $stage_table = Term::Table->new(
107 collapse => 1,
108 header => [qw/pid stage ready/, 'reload issues'],
109 rows => $rows,
110 );
111 print "$_\n" for $stage_table->render;
112
113 if ($reload_issues) {
114 my %seen;
115 print "\n**** Reload issues: ****\n";
116 for my $stage (sort keys %$reload_status) {
117 for my $file (keys %{$reload_status->{$stage}}) {
118 next if $seen{$file}++;
119 my $data = $reload_status->{$stage}->{$file} or next;
120 print "\n==== SOURCE FILE: $file ====\n";
121 print $data->{error} if $data->{error};
122 print $_ for @{$data->{warnings} // []};
123 }
124 }
125 print "\n";
126 }
127
128 print "\n**** Running tests: ****\n";
129 my $running = $state->running_tasks;
130 my $running_tasks = [values %$running];
131 my @rows = map {[$self->get_job_pid($_->{run_id}, $_->{job_id}) // 'N/A', $_->{job_id}, $_->{is_try} // $_->{job_try} // 0, $_->{rel_file}, join(', ' => @{$_->{conflicts} // []}), join(', ' => @{$_->{shares} // []})]} @$running_tasks;
132 if (@rows) {
133 my $run_table = Term::Table->new(
134 collapse => 1,
135 header => [qw/pid uuid try test conflicts shares/],
136 rows => [ sort { $a->[0] <=> $b->[0] } @rows ],
137 );
138 print "$_\n" for $run_table->render;
139 }
140
141 return 0;
142 }
143
144 1;
145
146 __END__
147
148 =pod
149
150 =encoding UTF-8
151
152 =head1 NAME
153
154 App::Yath::Command::status - Status info and process lists for the runner
155
156 =head1 DESCRIPTION
157
158 This command will provide health details and a process list for the runner.
159
160
161 =head1 USAGE
162
163 $ yath [YATH OPTIONS] status [COMMAND OPTIONS]
164
165 =head2 YATH OPTIONS
166
167 =head3 Developer
168
169 =over 4
170
171 =item --dev-lib
172
173 =item --dev-lib=lib
174
175 =item -D
176
177 =item -D=lib
178
179 =item -Dlib
180
181 =item --no-dev-lib
182
183 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.
184
185 Can be specified multiple times
186
187
188 =back
189
190 =head3 Environment
191
192 =over 4
193
194 =item --persist-dir ARG
195
196 =item --persist-dir=ARG
197
198 =item --no-persist-dir
199
200 Where to find persistence files.
201
202
203 =item --persist-file ARG
204
205 =item --persist-file=ARG
206
207 =item --pfile ARG
208
209 =item --pfile=ARG
210
211 =item --no-persist-file
212
213 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.
214
215
216 =item --project ARG
217
218 =item --project=ARG
219
220 =item --project-name ARG
221
222 =item --project-name=ARG
223
224 =item --no-project
225
226 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.
227
228
229 =back
230
231 =head3 Finder Options
232
233 =over 4
234
235 =item --finder MyFinder
236
237 =item --finder +Test2::Harness::Finder::MyFinder
238
239 =item --no-finder
240
241 Specify what Finder subclass to use when searching for files/processing the file list. Use the "+" prefix to specify a fully qualified namespace, otherwise Test2::Harness::Finder::XXX namespace is assumed.
242
243
244 =back
245
246 =head3 Help and Debugging
247
248 =over 4
249
250 =item --show-opts
251
252 =item --no-show-opts
253
254 Exit after showing what yath thinks your options mean
255
256
257 =item --version
258
259 =item -V
260
261 =item --no-version
262
263 Exit after showing a helpful usage message
264
265
266 =back
267
268 =head3 Plugins
269
270 =over 4
271
272 =item --no-scan-plugins
273
274 =item --no-no-scan-plugins
275
276 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.
277
278
279 =item --plugins PLUGIN
280
281 =item --plugins +App::Yath::Plugin::PLUGIN
282
283 =item --plugins PLUGIN=arg1,arg2,...
284
285 =item --plugin PLUGIN
286
287 =item --plugin +App::Yath::Plugin::PLUGIN
288
289 =item --plugin PLUGIN=arg1,arg2,...
290
291 =item -pPLUGIN
292
293 =item --no-plugins
294
295 Load a yath plugin.
296
297 Can be specified multiple times
298
299
300 =back
301
302 =head2 COMMAND OPTIONS
303
304 =head3 Cover Options
305
306 =over 4
307
308 =item --cover-aggregator ByTest
309
310 =item --cover-aggregator ByRun
311
312 =item --cover-aggregator +Custom::Aggregator
313
314 =item --cover-agg ByTest
315
316 =item --cover-agg ByRun
317
318 =item --cover-agg +Custom::Aggregator
319
320 =item --no-cover-aggregator
321
322 Choose a custom aggregator subclass
323
324
325 =item --cover-class ARG
326
327 =item --cover-class=ARG
328
329 =item --no-cover-class
330
331 Choose a Test2::Plugin::Cover subclass
332
333
334 =item --cover-dirs ARG
335
336 =item --cover-dirs=ARG
337
338 =item --cover-dir ARG
339
340 =item --cover-dir=ARG
341
342 =item --no-cover-dirs
343
344 NO DESCRIPTION - FIX ME
345
346 Can be specified multiple times
347
348
349 =item --cover-exclude-dirs ARG
350
351 =item --cover-exclude-dirs=ARG
352
353 =item --cover-exclude-dir ARG
354
355 =item --cover-exclude-dir=ARG
356
357 =item --no-cover-exclude-dirs
358
359 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.
360
361 Can be specified multiple times
362
363
364 =item --cover-exclude-private
365
366 =item --no-cover-exclude-private
367
368
369
370
371 =item --cover-files
372
373 =item --no-cover-files
374
375 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)
376
377
378 =item --cover-from path/to/log.jsonl
379
380 =item --cover-from http://example.com/coverage
381
382 =item --cover-from path/to/coverage.jsonl
383
384 =item --no-cover-from
385
386 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.
387
388
389 =item --cover-from-type json
390
391 =item --cover-from-type jsonl
392
393 =item --cover-from-type log
394
395 =item --no-cover-from-type
396
397 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.
398
399
400 =item --cover-manager My::Coverage::Manager
401
402 =item --no-cover-manager
403
404 Coverage 'from' manager to use when coverage data does not provide one
405
406
407 =item --cover-maybe-from path/to/log.jsonl
408
409 =item --cover-maybe-from http://example.com/coverage
410
411 =item --cover-maybe-from path/to/coverage.jsonl
412
413 =item --no-cover-maybe-from
414
415 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.
416
417
418 =item --cover-maybe-from-type json
419
420 =item --cover-maybe-from-type jsonl
421
422 =item --cover-maybe-from-type log
423
424 =item --no-cover-maybe-from-type
425
426 Same as "from_type" but for "maybe_from". Defaults to "from_type" if that is specified, otherwise auto-detect
427
428
429 =item --cover-metrics
430
431 =item --no-cover-metrics
432
433
434
435
436 =item --cover-types ARG
437
438 =item --cover-types=ARG
439
440 =item --cover-type ARG
441
442 =item --cover-type=ARG
443
444 =item --no-cover-types
445
446 NO DESCRIPTION - FIX ME
447
448 Can be specified multiple times
449
450
451 =item --cover-write
452
453 =item --cover-write=coverage.jsonl
454
455 =item --cover-write=coverage.json
456
457 =item --no-cover-write
458
459 Create a json or jsonl file of all coverage data seen during the run (This implies --cover-files).
460
461
462 =back
463
464 =head3 Display Options
465
466 =over 4
467
468 =item --color
469
470 =item --no-color
471
472 Turn color on, default is true if STDOUT is a TTY.
473
474
475 =item --hide-runner-output
476
477 =item --no-hide-runner-output
478
479 Hide output from the runner, showing only test output. (See Also truncate_runner_output)
480
481
482 =item --no-final-table
483
484 =item --no-no-final-table
485
486 When printing final results, don't use table-style display
487
488
489 =item --no-wrap
490
491 =item --no-no-wrap
492
493 Do not do fancy text-wrapping, let the terminal handle it
494
495
496 =item --progress
497
498 =item --no-progress
499
500 Toggle progress indicators. On by default if STDOUT is a TTY. You can use --no-progress to disable the 'events seen' counter and buffered event pre-display
501
502
503 =item --quiet
504
505 =item -q
506
507 =item --no-quiet
508
509 Be very quiet.
510
511 Can be specified multiple times
512
513
514 =item --renderers +My::Renderer
515
516 =item --renderers Renderer=arg1,arg2,...
517
518 =item --renderer +My::Renderer
519
520 =item --renderer Renderer=arg1,arg2,...
521
522 =item --no-renderers
523
524 Specify renderers, (Default: "Formatter=Test2"). Use "+" to give a fully qualified module name. Without "+" "Test2::Harness::Renderer::" will be prepended to your argument.
525
526 Can be specified multiple times. If the same key is listed multiple times the value lists will be appended together.
527
528
529 =item --show-times
530
531 =item -T
532
533 =item --no-show-times
534
535 Show the timing data for each job
536
537
538 =item --term-width 80
539
540 =item --term-width 200
541
542 =item --term-size 80
543
544 =item --term-size 200
545
546 =item --no-term-width
547
548 Alternative to setting $TABLE_TERM_SIZE. Setting this will override the terminal width detection to the number of characters specified.
549
550
551 =item --truncate-runner-output
552
553 =item --no-truncate-runner-output
554
555 Only show runner output that was generated after the current command. This is only useful with a persistent runner.
556
557
558 =item --verbose
559
560 =item -v
561
562 =item --no-verbose
563
564 Be more verbose
565
566 Can be specified multiple times
567
568
569 =back
570
571 =head3 Finder Options
572
573 =over 4
574
575 =item --changed path/to/file
576
577 =item --no-changed
578
579 Specify one or more files as having been changed.
580
581 Can be specified multiple times
582
583
584 =item --changed-only
585
586 =item --no-changed-only
587
588 Only search for tests for changed files (Requires a coverage data source, also requires a list of changes either from the --changed option, or a plugin that implements changed_files() or changed_diff())
589
590
591 =item --changes-diff path/to/diff.diff
592
593 =item --no-changes-diff
594
595 Path to a diff file that should be used to find changed files for use with --changed-only. This must be in the same format as `git diff -W --minimal -U1000000`
596
597
598 =item --changes-exclude-file path/to/file
599
600 =item --no-changes-exclude-file
601
602 Specify one or more files to ignore when looking at changes
603
604 Can be specified multiple times
605
606
607 =item --changes-exclude-loads
608
609 =item --no-changes-exclude-loads
610
611 Exclude coverage tests which only load changed files, but never call code from them. (default: off)
612
613
614 =item --changes-exclude-nonsub
615
616 =item --no-changes-exclude-nonsub
617
618 Exclude changes outside of subroutines (perl files only) (default: off)
619
620
621 =item --changes-exclude-opens
622
623 =item --no-changes-exclude-opens
624
625 Exclude coverage tests which only open() changed files, but never call code from them. (default: off)
626
627
628 =item --changes-exclude-pattern '(apple|pear|orange)'
629
630 =item --no-changes-exclude-pattern
631
632 Ignore files matching this pattern when looking for changes. Your pattern will be inserted unmodified into a `$file =~ m/$pattern/` check.
633
634 Can be specified multiple times
635
636
637 =item --changes-filter-file path/to/file
638
639 =item --no-changes-filter-file
640
641 Specify one or more files to check for changes. Changes to other files will be ignored
642
643 Can be specified multiple times
644
645
646 =item --changes-filter-pattern '(apple|pear|orange)'
647
648 =item --no-changes-filter-pattern
649
650 Specify a pattern for change checking. When only running tests for changed files this will limit which files are checked for changes. Only files that match this pattern will be checked. Your pattern will be inserted unmodified into a `$file =~ m/$pattern/` check.
651
652 Can be specified multiple times
653
654
655 =item --changes-include-whitespace
656
657 =item --no-changes-include-whitespace
658
659 Include changed lines that are whitespace only (default: off)
660
661
662 =item --changes-plugin Git
663
664 =item --changes-plugin +App::Yath::Plugin::Git
665
666 =item --no-changes-plugin
667
668 What plugin should be used to detect changed files.
669
670
671 =item --default-at-search ARG
672
673 =item --default-at-search=ARG
674
675 =item --no-default-at-search
676
677 Specify the default file/dir search when 'AUTHOR_TESTING' is set. Defaults to './xt'. The default AT search is only used if no files were specified at the command line
678
679 Can be specified multiple times
680
681
682 =item --default-search ARG
683
684 =item --default-search=ARG
685
686 =item --no-default-search
687
688 Specify the default file/dir search. defaults to './t', './t2', and 'test.pl'. The default search is only used if no files were specified at the command line
689
690 Can be specified multiple times
691
692
693 =item --durations file.json
694
695 =item --durations http://example.com/durations.json
696
697 =item --no-durations
698
699 Point at a json file or url which has a hash of relative test filenames as keys, and 'SHORT', 'MEDIUM', or 'LONG' as values. This will override durations listed in the file headers. An exception will be thrown if the durations file or url does not work.
700
701
702 =item --durations-threshold ARG
703
704 =item --durations-threshold=ARG
705
706 =item --Dt ARG
707
708 =item --Dt=ARG
709
710 =item --no-durations-threshold
711
712 Only fetch duration data if running at least this number of tests. Default (-j value + 1)
713
714
715 =item --exclude-file t/nope.t
716
717 =item --no-exclude-file
718
719 Exclude a file from testing
720
721 Can be specified multiple times
722
723
724 =item --exclude-list file.txt
725
726 =item --exclude-list http://example.com/exclusions.txt
727
728 =item --no-exclude-list
729
730 Point at a file or url which has a new line separated list of test file names to exclude from testing. Starting a line with a '#' will comment it out (for compatibility with Test2::Aggregate list files).
731
732 Can be specified multiple times
733
734
735 =item --exclude-pattern t/nope.t
736
737 =item --no-exclude-pattern
738
739 Exclude a pattern from testing, matched using m/$PATTERN/
740
741 Can be specified multiple times
742
743
744 =item --extension ARG
745
746 =item --extension=ARG
747
748 =item --ext ARG
749
750 =item --ext=ARG
751
752 =item --no-extension
753
754 Specify valid test filename extensions, default: t and t2
755
756 Can be specified multiple times
757
758
759 =item --maybe-durations file.json
760
761 =item --maybe-durations http://example.com/durations.json
762
763 =item --no-maybe-durations
764
765 Point at a json file or url which has a hash of relative test filenames as keys, and 'SHORT', 'MEDIUM', or 'LONG' as values. This will override durations listed in the file headers. An exception will be thrown if the durations file or url does not work.
766
767
768 =item --no-long
769
770 =item --no-no-long
771
772 Do not run tests that have their duration flag set to 'LONG'
773
774
775 =item --only-long
776
777 =item --no-only-long
778
779 Only run tests that have their duration flag set to 'LONG'
780
781
782 =item --rerun
783
784 =item --rerun=path/to/log.jsonl
785
786 =item --rerun=plugin_specific_string
787
788 =item --no-rerun
789
790 Re-Run tests from a previous run from a log file (or last log file). Plugins can intercept this, such as YathUIDB which will grab a run UUID and derive tests to re-run from that.
791
792
793 =item --rerun-all
794
795 =item --rerun-all=path/to/log.jsonl
796
797 =item --rerun-all=plugin_specific_string
798
799 =item --no-rerun-all
800
801 Re-Run all tests from a previous run from a log file (or last log file). Plugins can intercept this, such as YathUIDB which will grab a run UUID and derive tests to re-run from that.
802
803
804 =item --rerun-failed
805
806 =item --rerun-failed=path/to/log.jsonl
807
808 =item --rerun-failed=plugin_specific_string
809
810 =item --no-rerun-failed
811
812 Re-Run failed tests from a previous run from a log file (or last log file). Plugins can intercept this, such as YathUIDB which will grab a run UUID and derive tests to re-run from that.
813
814
815 =item --rerun-missed
816
817 =item --rerun-missed=path/to/log.jsonl
818
819 =item --rerun-missed=plugin_specific_string
820
821 =item --no-rerun-missed
822
823 Run missed tests from a previously aborted/stopped run from a log file (or last log file). Plugins can intercept this, such as YathUIDB which will grab a run UUID and derive tests to re-run from that.
824
825
826 =item --rerun-modes failed,missed,...
827
828 =item --rerun-modes all
829
830 =item --rerun-modes failed
831
832 =item --rerun-modes missed
833
834 =item --rerun-modes passed
835
836 =item --rerun-modes retried
837
838 =item --rerun-mode failed,missed,...
839
840 =item --rerun-mode all
841
842 =item --rerun-mode failed
843
844 =item --rerun-mode missed
845
846 =item --rerun-mode passed
847
848 =item --rerun-mode retried
849
850 =item --no-rerun-modes
851
852 Pick which test categories to run
853
854 Can be specified multiple times
855
856
857 =item --rerun-passed
858
859 =item --rerun-passed=path/to/log.jsonl
860
861 =item --rerun-passed=plugin_specific_string
862
863 =item --no-rerun-passed
864
865 Re-Run passed tests from a previous run from a log file (or last log file). Plugins can intercept this, such as YathUIDB which will grab a run UUID and derive tests to re-run from that.
866
867
868 =item --rerun-plugin Foo
869
870 =item --rerun-plugin +App::Yath::Plugin::Foo
871
872 =item --no-rerun-plugin
873
874 What plugin(s) should be used for rerun (will fallback to other plugins if the listed ones decline the value, this is just used to set an order of priority)
875
876 Can be specified multiple times
877
878
879 =item --rerun-retried
880
881 =item --rerun-retried=path/to/log.jsonl
882
883 =item --rerun-retried=plugin_specific_string
884
885 =item --no-rerun-retried
886
887 Re-Run retried tests from a previous run from a log file (or last log file). Plugins can intercept this, such as YathUIDB which will grab a run UUID and derive tests to re-run from that.
888
889
890 =item --search ARG
891
892 =item --search=ARG
893
894 =item --no-search
895
896 List of tests and test directories to use instead of the default search paths. Typically these can simply be listed as command line arguments without the --search prefix.
897
898 Can be specified multiple times
899
900
901 =item --show-changed-files
902
903 =item --no-show-changed-files
904
905 Print a list of changed files if any are found
906
907
908 =back
909
910 =head3 Formatter Options
911
912 =over 4
913
914 =item --formatter ARG
915
916 =item --formatter=ARG
917
918 =item --no-formatter
919
920 NO DESCRIPTION - FIX ME
921
922
923 =item --qvf
924
925 =item --no-qvf
926
927 [Q]uiet, but [V]erbose on [F]ailure. Hide all output from tests when they pass, except to say they passed. If a test fails then ALL output from the test is verbosely output.
928
929
930 =item --show-job-end
931
932 =item --no-show-job-end
933
934 Show output when a job ends. (Default: on)
935
936
937 =item --show-job-info
938
939 =item --no-show-job-info
940
941 Show the job configuration when a job starts. (Default: off, unless -vv)
942
943
944 =item --show-job-launch
945
946 =item --no-show-job-launch
947
948 Show output for the start of a job. (Default: off unless -v)
949
950
951 =item --show-run-info
952
953 =item --no-show-run-info
954
955 Show the run configuration when a run starts. (Default: off, unless -vv)
956
957
958 =back
959
960 =head3 Git Options
961
962 =over 4
963
964 =item --git-change-base master
965
966 =item --git-change-base HEAD^
967
968 =item --git-change-base df22abe4
969
970 =item --no-git-change-base
971
972 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.
973
974
975 =back
976
977 =head3 Help and Debugging
978
979 =over 4
980
981 =item --dummy
982
983 =item -d
984
985 =item --no-dummy
986
987 Dummy run, do not actually execute anything
988
989 Can also be set with the following environment variables: C<T2_HARNESS_DUMMY>
990
991
992 =item --help
993
994 =item -h
995
996 =item --no-help
997
998 exit after showing help information
999
1000
1001 =item --interactive
1002
1003 =item -i
1004
1005 =item --no-interactive
1006
1007 Use interactive mode, 1 test at a time, stdin forwarded to it
1008
1009
1010 =item --keep-dirs
1011
1012 =item --keep_dir
1013
1014 =item -k
1015
1016 =item --no-keep-dirs
1017
1018 Do not delete directories when done. This is useful if you want to inspect the directories used for various commands.
1019
1020
1021 =item --procname-prefix ARG
1022
1023 =item --procname-prefix=ARG
1024
1025 =item --no-procname-prefix
1026
1027 Add a prefix to all proc names (as seen by ps).
1028
1029
1030 =item --summary
1031
1032 =item --summary=/path/to/summary.json
1033
1034 =item --no-summary
1035
1036 Write out a summary json file, if no path is provided 'summary.json' will be used. The .json extension is added automatically if omitted.
1037
1038
1039 =back
1040
1041 =head3 Logging Options
1042
1043 =over 4
1044
1045 =item --bzip2
1046
1047 =item --bz2
1048
1049 =item --bzip2_log
1050
1051 =item -B
1052
1053 =item --no-bzip2
1054
1055 Use bzip2 compression when writing the log. This option implies -L. The .bz2 prefix is added to log file name for you
1056
1057
1058 =item --gzip
1059
1060 =item --gz
1061
1062 =item --gzip_log
1063
1064 =item -G
1065
1066 =item --no-gzip
1067
1068 Use gzip compression when writing the log. This option implies -L. The .gz prefix is added to log file name for you
1069
1070
1071 =item --log
1072
1073 =item -L
1074
1075 =item --no-log
1076
1077 Turn on logging
1078
1079
1080 =item --log-dir ARG
1081
1082 =item --log-dir=ARG
1083
1084 =item --no-log-dir
1085
1086 Specify a log directory. Will fall back to the system temp dir.
1087
1088
1089 =item --log-file ARG
1090
1091 =item --log-file=ARG
1092
1093 =item -F ARG
1094
1095 =item -F=ARG
1096
1097 =item --no-log-file
1098
1099 Specify the name of the log file. This option implies -L.
1100
1101
1102 =item --log-file-format ARG
1103
1104 =item --log-file-format=ARG
1105
1106 =item --lff ARG
1107
1108 =item --lff=ARG
1109
1110 =item --no-log-file-format
1111
1112 Specify the format for automatically-generated log files. Overridden by --log-file, if given. This option implies -L (Default: \$YATH_LOG_FILE_FORMAT, if that is set, or else "%!P%Y-%m-%d~%H:%M:%S~%!U~%!p.jsonl"). This is a string in which percent-escape sequences will be replaced as per POSIX::strftime. The following special escape sequences are also replaced: (%!P : Project name followed by a ~, if a project is defined, otherwise empty string) (%!U : the unique test run ID) (%!p : the process ID) (%!S : the number of seconds since local midnight UTC)
1113
1114 Can also be set with the following environment variables: C<YATH_LOG_FILE_FORMAT>, C<TEST2_HARNESS_LOG_FORMAT>
1115
1116
1117 =back
1118
1119 =head3 Notification Options
1120
1121 =over 4
1122
1123 =item --notify-email [email protected]
1124
1125 =item --no-notify-email
1126
1127 Email the test results to the specified email address(es)
1128
1129 Can be specified multiple times
1130
1131
1132 =item --notify-email-fail [email protected]
1133
1134 =item --no-notify-email-fail
1135
1136 Email failing results to the specified email address(es)
1137
1138 Can be specified multiple times
1139
1140
1141 =item --notify-email-from [email protected]
1142
1143 =item --no-notify-email-from
1144
1145 If any email is sent, this is who it will be from
1146
1147
1148 =item --notify-email-owner
1149
1150 =item --no-notify-email-owner
1151
1152 Email the owner of broken tests files upon failure. Add `# HARNESS-META-OWNER [email protected]` to the top of a test file to give it an owner
1153
1154
1155 =item --notify-no-batch-email
1156
1157 =item --no-notify-no-batch-email
1158
1159 Usually owner failures are sent as a single batch at the end of testing. Toggle this to send failures as they happen.
1160
1161
1162 =item --notify-no-batch-slack
1163
1164 =item --no-notify-no-batch-slack
1165
1166 Usually owner failures are sent as a single batch at the end of testing. Toggle this to send failures as they happen.
1167
1168
1169 =item --notify-slack '#foo'
1170
1171 =item --notify-slack '@bar'
1172
1173 =item --no-notify-slack
1174
1175 Send results to a slack channel and/or user
1176
1177 Can be specified multiple times
1178
1179
1180 =item --notify-slack-fail '#foo'
1181
1182 =item --notify-slack-fail '@bar'
1183
1184 =item --no-notify-slack-fail
1185
1186 Send failing results to a slack channel and/or user
1187
1188 Can be specified multiple times
1189
1190
1191 =item --notify-slack-owner
1192
1193 =item --no-notify-slack-owner
1194
1195 Send slack notifications to the slack channels/users listed in test meta-data when tests fail.
1196
1197
1198 =item --notify-slack-url https://hooks.slack.com/...
1199
1200 =item --no-notify-slack-url
1201
1202 Specify an API endpoint for slack webhook integrations
1203
1204
1205 =item --notify-text ARG
1206
1207 =item --notify-text=ARG
1208
1209 =item --message ARG
1210
1211 =item --message=ARG
1212
1213 =item --msg ARG
1214
1215 =item --msg=ARG
1216
1217 =item --no-notify-text
1218
1219 Add a custom text snippet to email/slack notifications
1220
1221
1222 =item --notify-text-module ARG
1223
1224 =item --notify-text-module=ARG
1225
1226 =item --message_module ARG
1227
1228 =item --message_module=ARG
1229
1230 =item --no-notify-text-module
1231
1232 Use the specified module to generate messages for emails and/or slack.
1233
1234
1235 =back
1236
1237 =head3 Run Options
1238
1239 =over 4
1240
1241 =item --author-testing
1242
1243 =item -A
1244
1245 =item --no-author-testing
1246
1247 This will set the AUTHOR_TESTING environment to true
1248
1249
1250 =item --dbi-profiling
1251
1252 =item --no-dbi-profiling
1253
1254 Use Test2::Plugin::DBIProfile to collect database profiling data
1255
1256
1257 =item --env-var VAR=VAL
1258
1259 =item -EVAR=VAL
1260
1261 =item -E VAR=VAL
1262
1263 =item --no-env-var
1264
1265 Set environment variables to set when each test is run.
1266
1267 Can be specified multiple times
1268
1269
1270 =item --event-uuids
1271
1272 =item --uuids
1273
1274 =item --no-event-uuids
1275
1276 Use Test2::Plugin::UUID inside tests (default: on)
1277
1278
1279 =item --fields name:details
1280
1281 =item --fields JSON_STRING
1282
1283 =item -f name:details
1284
1285 =item -f JSON_STRING
1286
1287 =item --no-fields
1288
1289 Add custom data to the harness run
1290
1291 Can be specified multiple times
1292
1293
1294 =item --input ARG
1295
1296 =item --input=ARG
1297
1298 =item --no-input
1299
1300 Input string to be used as standard input for ALL tests. See also: --input-file
1301
1302
1303 =item --input-file ARG
1304
1305 =item --input-file=ARG
1306
1307 =item --no-input-file
1308
1309 Use the specified file as standard input to ALL tests
1310
1311
1312 =item --io-events
1313
1314 =item --no-io-events
1315
1316 Use Test2::Plugin::IOEvents inside tests to turn all prints into test2 events (default: off)
1317
1318
1319 =item --link 'https://travis.work/builds/42'
1320
1321 =item --link 'https://jenkins.work/job/42'
1322
1323 =item --link 'https://buildbot.work/builders/foo/builds/42'
1324
1325 =item --no-link
1326
1327 Provide one or more links people can follow to see more about this run.
1328
1329 Can be specified multiple times
1330
1331
1332 =item --load ARG
1333
1334 =item --load=ARG
1335
1336 =item --load-module ARG
1337
1338 =item --load-module=ARG
1339
1340 =item -m ARG
1341
1342 =item -m=ARG
1343
1344 =item --no-load
1345
1346 Load a module in each test (after fork). The "import" method is not called.
1347
1348 Can be specified multiple times
1349
1350
1351 =item --load-import Module
1352
1353 =item --load-import Module=import_arg1,arg2,...
1354
1355 =item --loadim Module
1356
1357 =item --loadim Module=import_arg1,arg2,...
1358
1359 =item -M Module
1360
1361 =item -M Module=import_arg1,arg2,...
1362
1363 =item --no-load-import
1364
1365 Load a module in each test (after fork). Import is called.
1366
1367 Can be specified multiple times. If the same key is listed multiple times the value lists will be appended together.
1368
1369
1370 =item --mem-usage
1371
1372 =item --no-mem-usage
1373
1374 Use Test2::Plugin::MemUsage inside tests (default: on)
1375
1376
1377 =item --retry ARG
1378
1379 =item --retry=ARG
1380
1381 =item -r ARG
1382
1383 =item -r=ARG
1384
1385 =item --no-retry
1386
1387 Run any jobs that failed a second time. NOTE: --retry=1 means failing tests will be attempted twice!
1388
1389
1390 =item --retry-isolated
1391
1392 =item --retry-iso
1393
1394 =item --no-retry-isolated
1395
1396 If true then any job retries will be done in isolation (as though -j1 was set)
1397
1398
1399 =item --run-id
1400
1401 =item --id
1402
1403 =item --no-run-id
1404
1405 Set a specific run-id. (Default: a UUID)
1406
1407
1408 =item --test-args ARG
1409
1410 =item --test-args=ARG
1411
1412 =item --no-test-args
1413
1414 Arguments to pass in as @ARGV for all tests that are run. These can be provided easier using the '::' argument separator.
1415
1416 Can be specified multiple times
1417
1418
1419 =item --stream
1420
1421 =item --no-stream
1422
1423 Use the stream formatter (default is on)
1424
1425
1426 =item --tap
1427
1428 =item --TAP
1429
1430 =item ----no-stream
1431
1432 =item --no-tap
1433
1434 The TAP format is lossy and clunky. Test2::Harness normally uses a newer streaming format to receive test results. There are old/legacy tests where this causes problems, in which case setting --TAP or --no-stream can help.
1435
1436
1437 =back
1438
1439 =head3 YathUI Options
1440
1441 =over 4
1442
1443 =item --yathui-api-key ARG
1444
1445 =item --yathui-api-key=ARG
1446
1447 =item --no-yathui-api-key
1448
1449 Yath-UI API key. This is not necessary if your Yath-UI instance is set to single-user
1450
1451
1452 =item --yathui-coverage
1453
1454 =item --no-yathui-coverage
1455
1456 Poll coverage data from Yath-UI to determine what tests should be run for changed files
1457
1458
1459 =item --yathui-durations
1460
1461 =item --no-yathui-durations
1462
1463 Poll duration data from Yath-UI to help order tests efficiently
1464
1465
1466 =item --yathui-grace
1467
1468 =item --no-yathui-grace
1469
1470 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.
1471
1472
1473 =item --yathui-long-duration 10
1474
1475 =item --no-yathui-long-duration
1476
1477 Minimum duration length (seconds) before a test goes from MEDIUM to LONG
1478
1479
1480 =item --yathui-medium-duration 5
1481
1482 =item --no-yathui-medium-duration
1483
1484 Minimum duration length (seconds) before a test goes from SHORT to MEDIUM
1485
1486
1487 =item --yathui-mode summary
1488
1489 =item --yathui-mode qvf
1490
1491 =item --yathui-mode qvfd
1492
1493 =item --yathui-mode complete
1494
1495 =item --no-yathui-mode
1496
1497 Set the upload mode (default 'qvfd')
1498
1499
1500 =item --yathui-project ARG
1501
1502 =item --yathui-project=ARG
1503
1504 =item --no-yathui-project
1505
1506 The Yath-UI project for your test results
1507
1508
1509 =item --yathui-retry
1510
1511 =item --no-yathui-retry
1512
1513 How many times to try an operation before giving up
1514
1515 Can be specified multiple times
1516
1517
1518 =item --yathui-upload
1519
1520 =item --no-yathui-upload
1521
1522 Upload the log to Yath-UI
1523
1524
1525 =item --yathui-url http://my-yath-ui.com/...
1526
1527 =item --uri http://my-yath-ui.com/...
1528
1529 =item --no-yathui-url
1530
1531 Yath-UI url
1532
1533
1534 =back
1535
1536 =head3 NO CATEGORY - FIX ME
1537
1538 =over 4
1539
1540 =item --check-reload-state
1541
1542 =item --no-check-reload-state
1543
1544 Abort the run if there are unfixes reload errors and show a confirmation dialogue for unfixed reload warnings.
1545
1546
1547 =back
1548
1549 =head1 SOURCE
1550
1551 The source code repository for Test2-Harness can be found at
1552 F<http://github.com/Test-More/Test2-Harness/>.
1553
1554 =head1 MAINTAINERS
1555
1556 =over 4
1557
1558 =item Chad Granum E<lt>[email protected]<gt>
1559
1560 =back
1561
1562 =head1 AUTHORS
1563
1564 =over 4
1565
1566 =item Chad Granum E<lt>[email protected]<gt>
1567
1568 =back
1569
1570 =head1 COPYRIGHT
1571
1572 Copyright 2026 Chad Granum E<lt>[email protected]<gt>.
1573
1574 This program is free software; you can redistribute it and/or
1575 modify it under the same terms as Perl itself.
1576
1577 See F<http://dev.perl.org/licenses/>
1578
1579 =cut
1580