Debian Codegraph @

lib/App/Yath/Command/run.pm

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