Debian Codegraph @

lib/App/Yath/Command/test.pm

raw
1 package App::Yath::Command::test;
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::Event;
11 use Test2::Harness::Util::Queue;
12 use Test2::Harness::Util::File::JSON;
13 use Test2::Harness::IPC;
14 use Test2::Harness::Util::IPC qw/USE_P_GROUPS/;
15
16 use Test2::Harness::Runner::State;
17
18 use Test2::Harness::Stall::Capture();
19 use Test2::Harness::Stall::Detector();
20 use Test2::Harness::Stall::Report();
21
22 use Test2::Harness::Util::JSON qw/encode_json decode_json JSON/;
23 use Test2::Harness::Util qw/mod2file open_file chmod_tmp/;
24 use Test2::Util::Table qw/table/;
25
26 use Test2::Harness::Util::Term qw/USE_ANSI_COLOR/;
27
28 use File::Spec;
29 use Fcntl();
30 use Errno();
31
32 use Time::HiRes qw/sleep time/;
33 use List::Util qw/sum max min/;
34 use Carp qw/croak/;
35
36 use parent 'App::Yath::Command';
37 use Test2::Harness::Util::HashBase qw/
38 <runner_pid +ipc +signal
39
40 +run <run_id
41
42 +auditor_reader
43 +collector_writer
44 +renderer_reader
45 +auditor_writer
46
47 +renderers
48 +logger
49 +last_log
50
51 +tests_seen
52 +asserts_seen
53
54 +run_queue
55 +tasks_queue
56 +state
57
58 +stall_detector
59
60 <cleanup_subs
61
62 <final_data
63 /;
64
65 include_options(
66 'App::Yath::Options::Debug',
67 'App::Yath::Options::Display',
68 'App::Yath::Options::Finder',
69 'App::Yath::Options::Logging',
70 'App::Yath::Options::PreCommand',
71 'App::Yath::Options::Run',
72 'App::Yath::Options::Runner',
73 'App::Yath::Options::Workspace',
74 'App::Yath::Options::Collector',
75 );
76
77 sub MAX_ATTACH() { 1_048_576 }
78
79 sub group { ' test' }
80
81 sub summary { "Run tests" }
82 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]' }
83
84 sub description {
85 return <<" EOT";
86 This yath command (which is also the default command) will run all the test
87 files for the current project. If no test files are specified this command will
88 look for the 't', and 't2' directories, as well as the 'test.pl' file.
89
90 This command is always recursive when given directories.
91
92 This command will add 'lib', 'blib/arch' and 'blib/lib' to the perl path for
93 you by default (after any -I's). You can specify -l if you just want lib, -b if
94 you just want the blib paths. If you specify both -l and -b both will be added
95 in the order you specify (order relative to any -I options will also be
96 preserved. If you do not specify they will be added in this order: -I's, lib,
97 blib/lib, blib/arch. You can also add --no-lib and --no-blib to avoid both.
98
99 Any command line argument that is not an option will be treated as a test file
100 or directory of test files to be run.
101
102 If you wish to specify the ARGV for tests you may append them after '::'. This
103 is mainly useful for Test::Class::Moose and similar tools. EVERY test run will
104 get the same ARGV.
105 EOT
106 }
107
108 sub spawn_args {
109 my $self = shift;
110 my ($settings) = @_;
111
112 my @out;
113
114 if ($ENV{T2_DEVEL_COVER} && $ENV{T2_COVER_SELF}) {
115 push @out => '-MDevel::Cover=-silent,1,+ignore,^t/,+ignore,^t2/,+ignore,^xt,+ignore,^test.pl';
116 }
117
118 my $plugins = $settings->harness->plugins;
119 if (@$plugins) {
120 push @out => $_->spawn_args($settings) for grep { $_->can('spawn_args') } @$plugins;
121 }
122
123 return @out;
124 }
125
126 sub init {
127 my $self = shift;
128 $self->SUPER::init() if $self->can('SUPER::init');
129
130 $self->{+TESTS_SEEN} //= 0;
131 $self->{+ASSERTS_SEEN} //= 0;
132
133 $self->{+CLEANUP_SUBS} = [];
134 }
135
136 sub _resize_pipe {
137 return unless defined &Fcntl::F_SETPIPE_SZ;
138 my ($fh) = @_;
139
140 # 1mb if we can
141 my $size = 1024 * 1024 * 1;
142
143 # On linux systems lets go for the smaller of the two between 1mb and
144 # system max.
145 if (-e '/proc/sys/fs/pipe-max-size') {
146 open(my $max, '<', '/proc/sys/fs/pipe-max-size');
147 chomp(my $val = <$max>);
148 close($max);
149 $size = min($size, $val);
150 }
151
152 fcntl($fh, Fcntl::F_SETPIPE_SZ(), $size);
153 }
154
155 sub auditor_reader {
156 my $self = shift;
157 return $self->{+AUDITOR_READER} if $self->{+AUDITOR_READER};
158 pipe($self->{+AUDITOR_READER}, $self->{+COLLECTOR_WRITER}) or die "Could not create pipe: $!";
159 _resize_pipe($self->{+COLLECTOR_WRITER});
160 return $self->{+AUDITOR_READER};
161 }
162
163 sub collector_writer {
164 my $self = shift;
165 return $self->{+COLLECTOR_WRITER} if $self->{+COLLECTOR_WRITER};
166 pipe($self->{+AUDITOR_READER}, $self->{+COLLECTOR_WRITER}) or die "Could not create pipe: $!";
167 _resize_pipe($self->{+COLLECTOR_WRITER});
168 return $self->{+COLLECTOR_WRITER};
169 }
170
171 sub renderer_reader {
172 my $self = shift;
173 return $self->{+RENDERER_READER} if $self->{+RENDERER_READER};
174 pipe($self->{+RENDERER_READER}, $self->{+AUDITOR_WRITER}) or die "Could not create pipe: $!";
175 _resize_pipe($self->{+AUDITOR_WRITER});
176 return $self->{+RENDERER_READER};
177 }
178
179 sub auditor_writer {
180 my $self = shift;
181 return $self->{+AUDITOR_WRITER} if $self->{+AUDITOR_WRITER};
182 pipe($self->{+RENDERER_READER}, $self->{+AUDITOR_WRITER}) or die "Could not create pipe: $!";
183 _resize_pipe($self->{+AUDITOR_WRITER});
184 return $self->{+AUDITOR_WRITER};
185 }
186
187 sub workdir {
188 my $self = shift;
189 $self->settings->workspace->workdir;
190 }
191
192 sub ipc {
193 my $self = shift;
194 return $self->{+IPC} //= Test2::Harness::IPC->new(
195 handlers => {
196 INT => sub { $self->handle_sig(@_) },
197 TERM => sub { $self->handle_sig(@_) },
198 }
199 );
200 }
201
202 sub handle_sig {
203 my $self = shift;
204 my ($sig) = @_;
205
206 eval { $_->signal($sig) } for grep { $_->can('signal') } @{$self->renderers};
207
208 print STDERR "\nCaught SIG$sig, forwarding signal to child processes...\n";
209 $self->ipc->killall($sig);
210
211 if ($self->{+SIGNAL}) {
212 print STDERR "\nSecond signal ($self->{+SIGNAL} followed by $sig), exiting now without waiting\n";
213 exit 1;
214 }
215
216 $self->{+SIGNAL} = $sig;
217 }
218
219 sub monitor_preloads { 0 }
220
221 sub run {
222 my $self = shift;
223
224 my $settings = $self->settings;
225 my $plugins = $self->settings->harness->plugins;
226
227 if ($self->start()) {
228 $self->render();
229 $self->stop();
230
231 my $final_data = $self->{+FINAL_DATA} or die "Final data never received from auditor!\n";
232 my $pass = $self->{+TESTS_SEEN} && $final_data->{pass};
233 $self->render_final_data($final_data);
234 $self->produce_summary($pass);
235
236 if (@$plugins) {
237 my %args = (
238 settings => $settings,
239 final_data => $final_data,
240 pass => $pass ? 1 : 0,
241 tests_seen => $self->{+TESTS_SEEN} // 0,
242 asserts_seen => $self->{+ASSERTS_SEEN} // 0,
243 );
244 $_->finish(%args) for @$plugins;
245 }
246
247 return $pass ? 0 : 1;
248 }
249
250 $self->stop();
251
252 return 1;
253 }
254
255 sub DESTROY {
256 my $self = shift;
257
258 local ($?, $!, $@, $_);
259
260 my $cleanup = delete $self->{+CLEANUP_SUBS} or return;
261 for my $sub (@$cleanup) {
262 eval { $sub->(); 1 } or warn $@;
263 }
264 }
265
266 sub write_test_info {
267 my $self = shift;
268
269 return if $ENV{TEST2_HARNESS_NO_WRITE_TEST_INFO};
270
271 my $info_file = "./.test_info.$$.json";
272
273 my $workdir = $self->workdir;
274 Test2::Harness::Util::File::JSON->new(name => $info_file)->write({
275 workdir => $self->workdir,
276 job_count => $self->job_count,
277 });
278
279 push @{$self->{+CLEANUP_SUBS}} => sub {
280 return unless -e $info_file;
281 return unless Test2::Harness::Util::File::JSON->new(name => $info_file)->read->{workdir} eq $workdir;
282 unlink($info_file) or die "Could not unlink info file: $!";
283 };
284
285 $ENV{TEST2_HARNESS_NO_WRITE_TEST_INFO} = 1;
286 }
287
288 sub start {
289 my $self = shift;
290
291 $self->ipc->start();
292 $self->parse_args;
293
294 # Before anything is spawned: an unparseable value croaks, and dying out of
295 # start_auditor would leave the runner and collector already running.
296 $self->stall_detector;
297 $self->write_settings_to($self->workdir, 'settings.json');
298
299 $self->write_test_info();
300 my $pop = $self->populate_queue();
301 $self->terminate_queue();
302
303 return unless $pop;
304
305 $self->setup_plugins();
306 $self->setup_resources();
307
308 $self->start_runner(jobs_todo => $pop);
309 $self->start_collector();
310 $self->start_auditor();
311
312 return 1;
313 }
314
315 sub render {
316 my $self = shift;
317
318 my $ipc = $self->ipc;
319 my $settings = $self->settings;
320 my $renderers = $self->renderers;
321 my $logger = $self->logger;
322 my $plugins = $self->settings->harness->plugins;
323
324 my $handle_plugins = [grep { $_->can('handle_event') } @$plugins];
325 my $annotate_plugins = [grep { $_->can('annotate_event') } @$plugins];
326
327 # render results from log
328 my $reader = $self->renderer_reader();
329 $reader->blocking(0);
330 my $buffer;
331 while (1) {
332 return if $self->{+SIGNAL};
333 $_->step for @{$renderers};
334 $self->check_stall();
335
336 # A non-blocking handle returns undef both when no data has arrived
337 # yet and when the writers are all gone; only errno tells them apart.
338 # Clear it first: a read answered from PerlIO's cached EOF flag issues
339 # no syscall and leaves whatever errno step() or wait() above set.
340 # Do not use eof(), it reports true for an empty pipe whose writer is
341 # still alive.
342 $! = 0;
343 my $line = <$reader>;
344 unless(defined $line) {
345 last unless $!{EAGAIN} || $!{EWOULDBLOCK} || $!{EINTR};
346
347 $ipc->wait() if $ipc;
348 sleep 0.02;
349 next;
350 }
351
352 if ($buffer) {
353 $line = $buffer . $line;
354 $buffer = undef;
355 }
356
357 unless (substr($line, -1, 1) eq "\n") {
358 $buffer //= "";
359 $buffer .= $line;
360 next;
361 }
362
363 my $e = decode_json($line);
364
365 if (defined $e) {
366 bless($e, 'Test2::Harness::Event');
367 my $fd = $e->{facet_data} //= {};
368
369 my $changed = 0;
370 for my $p (@$annotate_plugins) {
371 my %inject = $p->annotate_event($e, $settings);
372 next unless keys %inject;
373 $changed++;
374
375 # Can add new facets, but not modify existing ones.
376 # Someone could force the issue by modifying the event directly
377 # inside 'annotate_event', this is not supported, but also not
378 # forbidden, user beware.
379 for my $f (keys %inject) {
380 if (exists $fd->{$f}) {
381 if ('ARRAY' eq ref($fd->{$f})) {
382 push @{$fd->{$f}} => @{$inject{$f}};
383 }
384 else {
385 warn "Plugin '$p' tried to add facet '$f' via 'annotate_event()', but it is already present and not a list, ignoring plugin annotation.\n";
386 }
387 }
388 else {
389 $fd->{$f} = $inject{$f};
390 }
391 }
392
393 }
394
395 if ($logger) {
396 if ($changed) {
397 my $newline = $e->as_json;
398 print $logger $newline, "\n";
399 }
400 else {
401 print $logger $line;
402 }
403 }
404 }
405 else {
406 last;
407 }
408
409 if (my $final = $e->{facet_data}->{harness_final}) {
410 $self->{+FINAL_DATA} = $final;
411 }
412 $_->render_event($e) for @$renderers;
413
414 $self->{+TESTS_SEEN}++ if $e->{facet_data}->{harness_job_launch};
415 $self->{+ASSERTS_SEEN}++ if $e->{facet_data}->{assert};
416
417 $_->handle_event($e, $settings) for @$handle_plugins;
418
419 $ipc->wait() if $ipc;
420 }
421
422 # Anything still buffered at EOF is a fragment of an event that was never
423 # completed, so it cannot be parsed. Report it, do not feed it to the JSON
424 # parser, which dies on invalid input.
425 if (defined($buffer) && length($buffer)) {
426 # An event can carry a whole test's output, so an incomplete one can
427 # be large. Show enough to identify it.
428 my $partial = length($buffer) > 200 ? substr($buffer, 0, 200) . "... (truncated)" : $buffer;
429 print STDERR "\nyath: Incomplete event discarded when the event stream ended: $partial\n";
430 }
431
432 return;
433 }
434
435 sub get_job_pid {
436 my $self = shift;
437 my ($run_id, $job_id) = @_;
438
439 return undef unless $run_id && $job_id;
440
441 my $run_dir = File::Spec->catdir($self->workdir, $run_id);
442 my $jobs_file = File::Spec->catfile($run_dir, 'jobs.jsonl');
443
444 return undef unless -f $jobs_file;
445 my $queue = Test2::Harness::Util::Queue->new(file => $jobs_file);
446
447 my $found;
448 for my $item ($queue->poll) {
449 my $task = $item->[-1];
450 next unless $task->{job_id} && $task->{job_id} eq $job_id;
451 $found = $task;
452 }
453
454 return undef unless $found;
455
456 return $found->{pid} // undef;
457 }
458
459 sub stop {
460 my $self = shift;
461
462 my $settings = $self->settings;
463 my $renderers = $self->renderers;
464 my $logger = $self->logger;
465
466 $self->teardown_plugins($renderers, $logger);
467 if ($logger) {
468 print $logger "null\n";
469 close($logger);
470 }
471
472 $_->finish() for @$renderers;
473
474 my $ipc = $self->ipc;
475 print STDERR "Waiting for child processes to exit...\n" if $self->{+SIGNAL};
476
477 if ($self->{+SIGNAL}) {
478 my $state = $self->state;
479 delete $state->{no_poll};
480 $state->poll;
481 my $running = $state->running_tasks;
482 $state->halt_run($self->{+RUN_ID});
483
484 for my $task (values %$running) {
485 next unless $task->{run_id} && $task->{run_id} eq $self->{+RUN_ID};
486 my $pid = $self->get_job_pid($task->{run_id}, $task->{job_id}) // next;
487 my $file = $task->{rel_file};
488 print "Killing test $pid - $file...\n";
489 kill('INT', USE_P_GROUPS ? -$pid : $pid);
490 }
491 }
492
493 $ipc->wait(all => 1);
494 $ipc->stop;
495
496 unless ($settings->display->quiet > 2) {
497 printf STDERR "\nNo tests were seen!\n" unless $self->{+TESTS_SEEN};
498
499 printf("\nKeeping work dir: %s\n", $self->workdir)
500 if $settings->debug->keep_dirs;
501
502 if ($settings->logging->log) {
503 print "\n";
504 print "Wrote log file: " . $settings->logging->log_file . "\n";
505 print " (Symlinked to: " . $self->{+LAST_LOG} . ")\n";
506 }
507
508 $self->finalize_plugins();
509 }
510 }
511
512 sub terminate_queue {
513 my $self = shift;
514
515 $self->tasks_queue->end();
516 $self->state->end_queue();
517 }
518
519 sub build_run {
520 my $self = shift;
521
522 return $self->{+RUN} if $self->{+RUN};
523
524 my $settings = $self->settings;
525 my $dir = $self->workdir;
526
527 my $run = $settings->build(run => 'Test2::Harness::Run');
528
529 mkdir($run->run_dir($dir)) or die "Could not make run dir: $!";
530 chmod_tmp($dir);
531
532 return $self->{+RUN} = $run;
533 }
534
535 sub state {
536 my $self = shift;
537
538 $self->{+STATE} //= Test2::Harness::Runner::State->new(
539 workdir => $self->workdir,
540 job_count => $self->job_count,
541 no_poll => 1,
542 );
543 }
544
545 sub job_count {
546 my $self = shift;
547
548 return $self->settings->runner->job_count;
549 }
550
551 sub run_queue {
552 my $self = shift;
553 my $dir = $self->workdir;
554 return $self->{+RUN_QUEUE} //= Test2::Harness::Util::Queue->new(file => File::Spec->catfile($dir, 'run_queue.jsonl'));
555 }
556
557 sub tasks_queue {
558 my $self = shift;
559
560 $self->{+TASKS_QUEUE} //= Test2::Harness::Util::Queue->new(
561 file => File::Spec->catfile($self->build_run->run_dir($self->workdir), 'queue.jsonl'),
562 );
563 }
564
565 sub finder_args {()}
566
567 sub populate_queue {
568 my $self = shift;
569
570 my $run = $self->build_run();
571 $self->{+RUN_ID} = $run->run_id;
572 my $settings = $self->settings;
573 my $finder = $settings->build(finder => $settings->finder->finder, $self->finder_args);
574
575 my $state = $self->state;
576 my $tasks_queue = $self->tasks_queue;
577 my $plugins = $settings->harness->plugins;
578
579 $state->queue_run($run->queue_item($plugins));
580
581 my @files = @{$finder->find_files($plugins, $self->settings)};
582
583 for my $plugin (@$plugins) {
584 if ($plugin->can('sort_files_2')) {
585 @files = $plugin->sort_files_2(settings => $settings, files => \@files);
586 }
587 elsif ($plugin->can('sort_files')) {
588 @files = $plugin->sort_files(@files);
589 }
590 }
591
592 my $job_count = 0;
593 for my $file (@files) {
594 my $task = $file->queue_item(++$job_count, $run->run_id,
595 $settings->check_prefix('display') ? (verbose => $settings->display->verbose) : (),
596 );
597
598 $task->{category} = 'isolation' if $settings->debug->interactive;
599
600 $state->queue_task($task);
601 $tasks_queue->enqueue($task);
602 }
603
604 $state->stop_run($run->run_id);
605
606 return $job_count;
607 }
608
609 sub produce_summary {
610 my $self = shift;
611 my ($pass) = @_;
612
613 my $settings = $self->settings;
614
615 my $time_data = {
616 start => $settings->harness->start,
617 stop => time(),
618 };
619
620 $time_data->{wall} = $time_data->{stop} - $time_data->{start};
621
622 my @times = times();
623 @{$time_data}{qw/user system cuser csystem/} = @times;
624 $time_data->{cpu} = sum @times;
625
626 my $cpu_usage = int($time_data->{cpu} / $time_data->{wall} * 100);
627
628 $self->write_summary($pass, $time_data, $cpu_usage);
629 $self->render_summary($pass, $time_data, $cpu_usage);
630 }
631
632 sub write_summary {
633 my $self = shift;
634 my ($pass, $time_data, $cpu_usage) = @_;
635
636 my $file = $self->settings->debug->summary or return;
637
638 my $final_data = $self->{+FINAL_DATA};
639
640 my $failures = @{$final_data->{failed} // []};
641
642 my %data = (
643 %$final_data,
644
645 pass => $pass ? JSON->true : JSON->false,
646
647 total_failures => $failures // 0,
648 total_tests => $self->{+TESTS_SEEN} // 0,
649 total_asserts => $self->{+ASSERTS_SEEN} // 0,
650
651 cpu_usage => $cpu_usage,
652
653 times => $time_data,
654 );
655
656 require Test2::Harness::Util::File::JSON;
657 my $jfile = Test2::Harness::Util::File::JSON->new(name => $file);
658 $jfile->write(\%data);
659
660 print "\nWrote summary file: $file\n\n";
661
662 return;
663 }
664
665 sub render_summary {
666 my $self = shift;
667 my ($pass, $time_data, $cpu_usage) = @_;
668
669 return if $self->settings->display->quiet > 1;
670
671 my $final_data = $self->{+FINAL_DATA};
672 my $failures = @{$final_data->{failed} // []};
673
674 my @summary = (
675 $failures ? (" Fail Count: $failures") : (),
676 " File Count: $self->{+TESTS_SEEN}",
677 "Assertion Count: $self->{+ASSERTS_SEEN}",
678 $time_data ? (
679 sprintf(" Wall Time: %.2f seconds", $time_data->{wall}),
680 sprintf(" CPU Time: %.2f seconds (usr: %.2fs | sys: %.2fs | cusr: %.2fs | csys: %.2fs)", @{$time_data}{qw/cpu user system cuser csystem/}),
681 sprintf(" CPU Usage: %i%%", $cpu_usage),
682 ) : (),
683 );
684
685 my $res = " --> Result: " . ($pass ? 'PASSED' : 'FAILED') . " <--";
686 if ($self->settings->display->color && USE_ANSI_COLOR) {
687 my $color = $pass ? Term::ANSIColor::color('bold bright_green') : Term::ANSIColor::color('bold bright_red');
688 my $reset = Term::ANSIColor::color('reset');
689 $res = "$color$res$reset";
690 }
691 push @summary => $res;
692
693 my $msg = "Yath Result Summary";
694 my $length = max map { length($_) } @summary;
695 my $prefix = ($length - length($msg)) / 2;
696
697 print "\n";
698 print " " x $prefix;
699 print "$msg\n";
700 print "-" x $length;
701 print "\n";
702 print join "\n" => @summary;
703 print "\n";
704 }
705
706 sub render_final_data {
707 my $self = shift;
708 my ($final_data) = @_;
709
710 return if $self->settings->display->quiet > 1;
711
712 return $self->_render_final_data_plainly($final_data)
713 if $self->settings->display->no_final_table;
714
715 if (my $rows = $final_data->{retried}) {
716 print "\nThe following jobs failed at least once:\n";
717 print join "\n" => table(
718 header => ['Job ID', 'Times Run', 'Test File', "Succeeded Eventually?"],
719 rows => $rows,
720 );
721 print "\n";
722 }
723
724 if (my $rows = $final_data->{failed}) {
725 print "\nThe following jobs failed:\n";
726 print join "\n" => table(
727 collapse => 1,
728 header => ['Job ID', 'Test File', 'Subtests'],
729 rows => [map { my $r = [@{$_}]; $r->[2] = stringify_subtest_map($r->[2]) if $r->[2]; $r} @$rows],
730 );
731 print "\n";
732 }
733
734 if (my $rows = $final_data->{halted}) {
735 print "\nThe following jobs requested all testing be halted:\n";
736 print join "\n" => table(
737 header => ['Job ID', 'Test File', "Reason"],
738 rows => $rows,
739 );
740 print "\n";
741 }
742
743 if (my $rows = $final_data->{unseen}) {
744 print "\nThe following jobs never ran:\n";
745 print join "\n" => table(
746 header => ['Job ID', 'Test File'],
747 rows => $rows,
748 );
749 print "\n";
750 }
751 }
752
753 sub _render_final_data_plainly {
754 my $self = shift;
755 my ($final_data) = @_;
756
757 return if $self->settings->display->quiet > 1;
758
759 if (my $rows = $final_data->{retried}) {
760 print "\nThe following jobs failed at least once:\n";
761 for my $row (@$rows) {
762 print "- filename: $row->[2]\n";
763 print " job_id: $row->[0]\n";
764 print " times_run: $row->[1]\n";
765 print " succeeded_eventually: $row->[3]\n";
766 }
767 }
768
769 if (my $rows = $final_data->{failed}) {
770 print "\nThe following jobs failed:\n";
771 for my $row (@$rows) {
772 print "- filename: $row->[1]\n";
773 print " job_id: $row->[0]\n";
774 if ($row->[2]) {
775 print " subtests:\n";
776 my @paths = _subtest_paths($row->[2]);
777 print " - $_\n" for @paths;
778 }
779 }
780 }
781
782 if (my $rows = $final_data->{halted}) {
783 print "\nThe following jobs requested all testing be halted:\n";
784 for my $row (@$rows) {
785 print "- filename: $row->[1]\n";
786 print " job_id: $row->[0]\n";
787 print " reason: $row->[2]\n" if $row->[2];
788 }
789 }
790
791 if (my $rows = $final_data->{unseen}) {
792 print "\nThe following jobs never ran:\n";
793 for my $row (@$rows) {
794 print "- filename: $row->[1]\n";
795 print " job_id: $row->[0]\n";
796 }
797 }
798 }
799
800 sub _subtest_paths {
801 my ($map) = @_;
802
803 my @paths;
804 my @todo = @$map;
805 my @state;
806 while (my $st = shift @todo) {
807 if (!ref($st)) {
808 pop @state if $st eq 'pop';
809 next;
810 }
811 push @state, $st->[0];
812 push @paths, join(' -> ', @state);
813 unshift @todo, (@{$st->[1]}, 'pop');
814 }
815
816 return @paths;
817 }
818
819 sub stringify_subtest_map {
820 my ($map) = @_;
821
822 my $out = "";
823 my @todo = @$map;
824 my @state;
825 while (my $st = shift @todo) {
826 if (!ref($st)) {
827 pop @state if $st eq 'pop';
828 next;
829 }
830 push @state => $st->[0];
831 $out .= join(' -> ' => @state) . "\n";
832 unshift @todo => (@{$st->[1]}, 'pop');
833 }
834
835 return $out;
836 }
837
838 sub logger {
839 my $self = shift;
840
841 return $self->{+LOGGER} if $self->{+LOGGER};
842
843 my $settings = $self->{+SETTINGS};
844
845 return unless $settings->logging->log;
846
847 my $file = $settings->logging->log_file;
848
849 if ($settings->logging->bzip2) {
850 no warnings 'once';
851 require IO::Compress::Bzip2;
852 $self->{+LOGGER} = IO::Compress::Bzip2->new($file) or die "Could not open log file '$file': $IO::Compress::Bzip2::Bzip2Error";
853 }
854 elsif ($settings->logging->gzip) {
855 no warnings 'once';
856 require IO::Compress::Gzip;
857 $self->{+LOGGER} = IO::Compress::Gzip->new($file) or die "Could not open log file '$file': $IO::Compress::Gzip::GzipError";
858 }
859 else {
860 $self->{+LOGGER} = open_file($file, '>');
861 }
862
863 for my $ext ('jsonl', 'jsonl.bz2', 'jsonl.gz') {
864 my $name = "./lastlog.$ext";
865 next unless -f $name;
866 local ($!, $@) = (0, '');
867 eval { unlink($name) } or warn "Could not unlink '$name': ($!) $@";
868 }
869
870 if ($file =~ m/\.(jsonl(?:\.(?:bz2|gz))?)$/) {
871 my $ext = $1;
872 my $name = "./lastlog.$ext";
873 if (eval { symlink($file, $name); 1 }) {
874 $self->{+LAST_LOG} = $name;
875 }
876 else {
877 warn "Could not symlink the log file to '$name': $@";
878 }
879 }
880
881 return $self->{+LOGGER};
882 }
883
884 sub renderers {
885 my $self = shift;
886
887 return $self->{+RENDERERS} if $self->{+RENDERERS};
888
889 my $settings = $self->{+SETTINGS};
890
891 my @renderers;
892 for my $class (@{$settings->display->renderers->{'@'}}) {
893 require(mod2file($class));
894 my $args = $settings->display->renderers->{$class};
895 my $renderer = $class->new(@$args, settings => $settings, command_class => ref($self));
896 push @renderers => $renderer;
897 }
898
899 return $self->{+RENDERERS} = \@renderers;
900 }
901
902 sub start_auditor {
903 my $self = shift;
904
905 my $run = $self->build_run();
906 my $settings = $self->settings;
907
908 my $ipc = $self->ipc;
909 $ipc->spawn(
910 stdin => $self->auditor_reader(),
911 stdout => $self->auditor_writer(),
912 no_set_pgrp => 1,
913 command => [
914 $^X, $self->spawn_args($settings), $settings->harness->script,
915 (map { "-D$_" } @{$settings->harness->dev_libs}),
916 '--no-scan-plugins', # Do not preload any plugin modules
917 auditor => 'Test2::Harness::Auditor',
918 $run->run_id,
919 procname_prefix => $settings->debug->procname_prefix,
920 $self->stall_detector ? (stall_dir => File::Spec->catdir($self->workdir, 'stall')) : (),
921 ],
922 );
923
924 close($self->auditor_writer());
925 }
926
927 # Off unless --stall-report was given. Only 'yath test' and the commands that
928 # own their runner get one; App::Yath::Command::run overrides this, since its
929 # runner is a persistent one it did not start and may be shared with other
930 # sessions.
931 sub stall_reporting { 1 }
932
933 sub stall_detector {
934 my $self = shift;
935
936 return $self->{+STALL_DETECTOR} if exists $self->{+STALL_DETECTOR};
937
938 $self->{+STALL_DETECTOR} = undef;
939
940 return undef unless $self->stall_reporting;
941
942 my $settings = $self->settings;
943 return undef unless $settings->check_prefix('runner');
944
945 my %spec = Test2::Harness::Stall::Detector->parse_spec($settings->runner->stall_report)
946 or return undef;
947
948 return $self->{+STALL_DETECTOR} = Test2::Harness::Stall::Detector->new(
949 %spec,
950 workdir => $self->workdir,
951 job_count => $self->job_count,
952 );
953 }
954
955 sub check_stall {
956 my $self = shift;
957
958 my $detector = $self->stall_detector or return;
959
960 # Diagnostics must never be able to end a healthy run, so nothing here is
961 # allowed to escape.
962 my $ok = eval { $self->report_stall($detector); 1 };
963 warn $@ unless $ok;
964
965 return;
966 }
967
968 sub report_stall {
969 my $self = shift;
970 my ($detector) = @_;
971
972 my $found = $detector->check or return;
973
974 # Rooted at this process, so the tree covers the runner and its children
975 # plus the collector and auditor, which are children of this process.
976 my $capture = Test2::Harness::Stall::Capture->new(
977 workdir => $self->workdir,
978 root_pid => $$,
979 );
980
981 my @pids = grep { $_ } $self->runner_pid, $found->{scheduler_pid}, values %{$found->{stage_pids} // {}};
982 push @pids => keys %{$self->ipc->procs // {}} if $self->ipc;
983
984 my %seen;
985 my $bundle = $capture->collect({
986 %$found,
987 state => undef,
988 tasks => undef,
989 harness_pids => [grep { $_ > 0 && !$seen{$_}++ } @pids],
990 });
991
992 my $report = Test2::Harness::Stall::Report->new(
993 workdir => $self->workdir,
994 run_id => $self->{+RUN_ID},
995 report_dir => $self->settings->runner->stall_report_dir,
996 );
997 $bundle->{state_summary} = $report->state_summary($found->{state}, $found->{tasks});
998 $report->emit($bundle);
999
1000 return;
1001 }
1002
1003 sub collector_options { () }
1004
1005 sub start_collector {
1006 my $self = shift;
1007
1008 my $dir = $self->workdir;
1009 my $run = $self->build_run();
1010 my $settings = $self->settings;
1011 my $runner_pid = $self->runner_pid;
1012
1013 my ($rh, $wh);
1014 pipe($rh, $wh) or die "Could not create pipe";
1015
1016 my %options = (show_runner_output => 1);
1017 if ($settings->check_prefix('display')) {
1018 $options{show_runner_output} = $settings->display->hide_runner_output ? 0 : 1;
1019 $options{truncate_runner_output} = $settings->display->truncate_runner_output;
1020 }
1021
1022 %options = (
1023 %options,
1024 $self->collector_options(),
1025 );
1026
1027 my $ipc = $self->ipc;
1028 $ipc->spawn(
1029 stdout => $self->collector_writer,
1030 stdin => $rh,
1031 no_set_pgrp => 1,
1032 command => [
1033 $^X, $self->spawn_args($settings), $settings->harness->script,
1034 (map { "-D$_" } @{$settings->harness->dev_libs}),
1035 '--no-scan-plugins', # Do not preload any plugin modules
1036 collector => 'Test2::Harness::Collector',
1037 $dir, $run->run_id, $runner_pid,
1038 %options,
1039 ],
1040 );
1041
1042 close($rh);
1043 print $wh encode_json($run) . "\n";
1044 close($wh);
1045
1046 close($self->collector_writer());
1047 }
1048
1049 sub start_runner {
1050 my $self = shift;
1051 my %args = @_;
1052
1053 $args{monitor_preloads} //= $self->monitor_preloads;
1054
1055 my $settings = $self->settings;
1056 my $dir = $settings->workspace->workdir;
1057
1058 my @prof;
1059 if ($settings->runner->nytprof) {
1060 push @prof => '-d:NYTProf';
1061 }
1062
1063 my $ipc = $self->ipc;
1064 my $proc = $ipc->spawn(
1065 stderr => File::Spec->catfile($dir, 'error.log'),
1066 stdout => File::Spec->catfile($dir, 'output.log'),
1067 env_vars => { @prof ? (NYTPROF => 'start=no:addpid=1') : () },
1068 no_set_pgrp => 1,
1069 command => [
1070 $^X, @prof, $self->spawn_args($settings), $settings->harness->script,
1071 (map { "-D$_" } @{$settings->harness->dev_libs}),
1072 '--no-scan-plugins', # Do not preload any plugin modules
1073 runner => $dir,
1074 %args,
1075 ],
1076 );
1077
1078 $self->{+RUNNER_PID} = $proc->pid;
1079
1080 return $proc;
1081 }
1082
1083 sub parse_args {
1084 my $self = shift;
1085 my $settings = $self->settings;
1086 my $args = $self->args;
1087
1088 my $dest = $settings->finder->search;
1089 for my $arg (@$args) {
1090 next if $arg eq '--';
1091 if ($arg eq '::') {
1092 $dest = $settings->run->test_args;
1093 next;
1094 }
1095
1096 push @$dest => $arg;
1097 }
1098
1099 return;
1100 }
1101
1102 1;
1103
1104 __END__
1105
1106 =pod
1107
1108 =encoding UTF-8
1109
1110 =head1 NAME
1111
1112 App::Yath::Command::test - Run tests
1113
1114 =head1 DESCRIPTION
1115
1116 This yath command (which is also the default command) will run all the test
1117 files for the current project. If no test files are specified this command will
1118 look for the 't', and 't2' directories, as well as the 'test.pl' file.
1119
1120 This command is always recursive when given directories.
1121
1122 This command will add 'lib', 'blib/arch' and 'blib/lib' to the perl path for
1123 you by default (after any -I's). You can specify -l if you just want lib, -b if
1124 you just want the blib paths. If you specify both -l and -b both will be added
1125 in the order you specify (order relative to any -I options will also be
1126 preserved. If you do not specify they will be added in this order: -I's, lib,
1127 blib/lib, blib/arch. You can also add --no-lib and --no-blib to avoid both.
1128
1129 Any command line argument that is not an option will be treated as a test file
1130 or directory of test files to be run.
1131
1132 If you wish to specify the ARGV for tests you may append them after '::'. This
1133 is mainly useful for Test::Class::Moose and similar tools. EVERY test run will
1134 get the same ARGV.
1135
1136
1137 =head1 USAGE
1138
1139 $ yath [YATH OPTIONS] test [COMMAND OPTIONS]
1140
1141 =head2 YATH OPTIONS
1142
1143 =head3 Developer
1144
1145 =over 4
1146
1147 =item --dev-lib
1148
1149 =item --dev-lib=lib
1150
1151 =item -D
1152
1153 =item -D=lib
1154
1155 =item -Dlib
1156
1157 =item --no-dev-lib
1158
1159 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.
1160
1161 Can be specified multiple times
1162
1163
1164 =back
1165
1166 =head3 Environment
1167
1168 =over 4
1169
1170 =item --persist-dir ARG
1171
1172 =item --persist-dir=ARG
1173
1174 =item --no-persist-dir
1175
1176 Where to find persistence files.
1177
1178
1179 =item --persist-file ARG
1180
1181 =item --persist-file=ARG
1182
1183 =item --pfile ARG
1184
1185 =item --pfile=ARG
1186
1187 =item --no-persist-file
1188
1189 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.
1190
1191
1192 =item --project ARG
1193
1194 =item --project=ARG
1195
1196 =item --project-name ARG
1197
1198 =item --project-name=ARG
1199
1200 =item --no-project
1201
1202 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.
1203
1204
1205 =back
1206
1207 =head3 Finder Options
1208
1209 =over 4
1210
1211 =item --finder MyFinder
1212
1213 =item --finder +Test2::Harness::Finder::MyFinder
1214
1215 =item --no-finder
1216
1217 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.
1218
1219
1220 =back
1221
1222 =head3 Help and Debugging
1223
1224 =over 4
1225
1226 =item --show-opts
1227
1228 =item --no-show-opts
1229
1230 Exit after showing what yath thinks your options mean
1231
1232
1233 =item --version
1234
1235 =item -V
1236
1237 =item --no-version
1238
1239 Exit after showing a helpful usage message
1240
1241
1242 =back
1243
1244 =head3 Plugins
1245
1246 =over 4
1247
1248 =item --no-scan-plugins
1249
1250 =item --no-no-scan-plugins
1251
1252 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.
1253
1254
1255 =item --plugins PLUGIN
1256
1257 =item --plugins +App::Yath::Plugin::PLUGIN
1258
1259 =item --plugins PLUGIN=arg1,arg2,...
1260
1261 =item --plugin PLUGIN
1262
1263 =item --plugin +App::Yath::Plugin::PLUGIN
1264
1265 =item --plugin PLUGIN=arg1,arg2,...
1266
1267 =item -pPLUGIN
1268
1269 =item --no-plugins
1270
1271 Load a yath plugin.
1272
1273 Can be specified multiple times
1274
1275
1276 =back
1277
1278 =head2 COMMAND OPTIONS
1279
1280 =head3 Collector Options
1281
1282 =over 4
1283
1284 =item --max-open-jobs 18
1285
1286 =item --no-max-open-jobs
1287
1288 Maximum number of jobs a collector can process at a time, if more jobs are pending their output will be delayed until the earlier jobs have been processed. (Default: double the -j value)
1289
1290
1291 =item --max-poll-events 1000
1292
1293 =item --no-max-poll-events
1294
1295 Maximum number of events to poll from a job before jumping to the next job. (Default: 1000)
1296
1297
1298 =back
1299
1300 =head3 Cover Options
1301
1302 =over 4
1303
1304 =item --cover-aggregator ByTest
1305
1306 =item --cover-aggregator ByRun
1307
1308 =item --cover-aggregator +Custom::Aggregator
1309
1310 =item --cover-agg ByTest
1311
1312 =item --cover-agg ByRun
1313
1314 =item --cover-agg +Custom::Aggregator
1315
1316 =item --no-cover-aggregator
1317
1318 Choose a custom aggregator subclass
1319
1320
1321 =item --cover-class ARG
1322
1323 =item --cover-class=ARG
1324
1325 =item --no-cover-class
1326
1327 Choose a Test2::Plugin::Cover subclass
1328
1329
1330 =item --cover-dirs ARG
1331
1332 =item --cover-dirs=ARG
1333
1334 =item --cover-dir ARG
1335
1336 =item --cover-dir=ARG
1337
1338 =item --no-cover-dirs
1339
1340 NO DESCRIPTION - FIX ME
1341
1342 Can be specified multiple times
1343
1344
1345 =item --cover-exclude-dirs ARG
1346
1347 =item --cover-exclude-dirs=ARG
1348
1349 =item --cover-exclude-dir ARG
1350
1351 =item --cover-exclude-dir=ARG
1352
1353 =item --no-cover-exclude-dirs
1354
1355 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.
1356
1357 Can be specified multiple times
1358
1359
1360 =item --cover-exclude-private
1361
1362 =item --no-cover-exclude-private
1363
1364
1365
1366
1367 =item --cover-files
1368
1369 =item --no-cover-files
1370
1371 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)
1372
1373
1374 =item --cover-from path/to/log.jsonl
1375
1376 =item --cover-from http://example.com/coverage
1377
1378 =item --cover-from path/to/coverage.jsonl
1379
1380 =item --no-cover-from
1381
1382 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.
1383
1384
1385 =item --cover-from-type json
1386
1387 =item --cover-from-type jsonl
1388
1389 =item --cover-from-type log
1390
1391 =item --no-cover-from-type
1392
1393 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.
1394
1395
1396 =item --cover-manager My::Coverage::Manager
1397
1398 =item --no-cover-manager
1399
1400 Coverage 'from' manager to use when coverage data does not provide one
1401
1402
1403 =item --cover-maybe-from path/to/log.jsonl
1404
1405 =item --cover-maybe-from http://example.com/coverage
1406
1407 =item --cover-maybe-from path/to/coverage.jsonl
1408
1409 =item --no-cover-maybe-from
1410
1411 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.
1412
1413
1414 =item --cover-maybe-from-type json
1415
1416 =item --cover-maybe-from-type jsonl
1417
1418 =item --cover-maybe-from-type log
1419
1420 =item --no-cover-maybe-from-type
1421
1422 Same as "from_type" but for "maybe_from". Defaults to "from_type" if that is specified, otherwise auto-detect
1423
1424
1425 =item --cover-metrics
1426
1427 =item --no-cover-metrics
1428
1429
1430
1431
1432 =item --cover-types ARG
1433
1434 =item --cover-types=ARG
1435
1436 =item --cover-type ARG
1437
1438 =item --cover-type=ARG
1439
1440 =item --no-cover-types
1441
1442 NO DESCRIPTION - FIX ME
1443
1444 Can be specified multiple times
1445
1446
1447 =item --cover-write
1448
1449 =item --cover-write=coverage.jsonl
1450
1451 =item --cover-write=coverage.json
1452
1453 =item --no-cover-write
1454
1455 Create a json or jsonl file of all coverage data seen during the run (This implies --cover-files).
1456
1457
1458 =back
1459
1460 =head3 Display Options
1461
1462 =over 4
1463
1464 =item --color
1465
1466 =item --no-color
1467
1468 Turn color on, default is true if STDOUT is a TTY.
1469
1470
1471 =item --hide-runner-output
1472
1473 =item --no-hide-runner-output
1474
1475 Hide output from the runner, showing only test output. (See Also truncate_runner_output)
1476
1477
1478 =item --no-final-table
1479
1480 =item --no-no-final-table
1481
1482 When printing final results, don't use table-style display
1483
1484
1485 =item --no-wrap
1486
1487 =item --no-no-wrap
1488
1489 Do not do fancy text-wrapping, let the terminal handle it
1490
1491
1492 =item --progress
1493
1494 =item --no-progress
1495
1496 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
1497
1498
1499 =item --quiet
1500
1501 =item -q
1502
1503 =item --no-quiet
1504
1505 Be very quiet.
1506
1507 Can be specified multiple times
1508
1509
1510 =item --renderers +My::Renderer
1511
1512 =item --renderers Renderer=arg1,arg2,...
1513
1514 =item --renderer +My::Renderer
1515
1516 =item --renderer Renderer=arg1,arg2,...
1517
1518 =item --no-renderers
1519
1520 Specify renderers, (Default: "Formatter=Test2"). Use "+" to give a fully qualified module name. Without "+" "Test2::Harness::Renderer::" will be prepended to your argument.
1521
1522 Can be specified multiple times. If the same key is listed multiple times the value lists will be appended together.
1523
1524
1525 =item --show-times
1526
1527 =item -T
1528
1529 =item --no-show-times
1530
1531 Show the timing data for each job
1532
1533
1534 =item --term-width 80
1535
1536 =item --term-width 200
1537
1538 =item --term-size 80
1539
1540 =item --term-size 200
1541
1542 =item --no-term-width
1543
1544 Alternative to setting $TABLE_TERM_SIZE. Setting this will override the terminal width detection to the number of characters specified.
1545
1546
1547 =item --truncate-runner-output
1548
1549 =item --no-truncate-runner-output
1550
1551 Only show runner output that was generated after the current command. This is only useful with a persistent runner.
1552
1553
1554 =item --verbose
1555
1556 =item -v
1557
1558 =item --no-verbose
1559
1560 Be more verbose
1561
1562 Can be specified multiple times
1563
1564
1565 =back
1566
1567 =head3 Finder Options
1568
1569 =over 4
1570
1571 =item --changed path/to/file
1572
1573 =item --no-changed
1574
1575 Specify one or more files as having been changed.
1576
1577 Can be specified multiple times
1578
1579
1580 =item --changed-only
1581
1582 =item --no-changed-only
1583
1584 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())
1585
1586
1587 =item --changes-diff path/to/diff.diff
1588
1589 =item --no-changes-diff
1590
1591 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`
1592
1593
1594 =item --changes-exclude-file path/to/file
1595
1596 =item --no-changes-exclude-file
1597
1598 Specify one or more files to ignore when looking at changes
1599
1600 Can be specified multiple times
1601
1602
1603 =item --changes-exclude-loads
1604
1605 =item --no-changes-exclude-loads
1606
1607 Exclude coverage tests which only load changed files, but never call code from them. (default: off)
1608
1609
1610 =item --changes-exclude-nonsub
1611
1612 =item --no-changes-exclude-nonsub
1613
1614 Exclude changes outside of subroutines (perl files only) (default: off)
1615
1616
1617 =item --changes-exclude-opens
1618
1619 =item --no-changes-exclude-opens
1620
1621 Exclude coverage tests which only open() changed files, but never call code from them. (default: off)
1622
1623
1624 =item --changes-exclude-pattern '(apple|pear|orange)'
1625
1626 =item --no-changes-exclude-pattern
1627
1628 Ignore files matching this pattern when looking for changes. Your pattern will be inserted unmodified into a `$file =~ m/$pattern/` check.
1629
1630 Can be specified multiple times
1631
1632
1633 =item --changes-filter-file path/to/file
1634
1635 =item --no-changes-filter-file
1636
1637 Specify one or more files to check for changes. Changes to other files will be ignored
1638
1639 Can be specified multiple times
1640
1641
1642 =item --changes-filter-pattern '(apple|pear|orange)'
1643
1644 =item --no-changes-filter-pattern
1645
1646 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.
1647
1648 Can be specified multiple times
1649
1650
1651 =item --changes-include-whitespace
1652
1653 =item --no-changes-include-whitespace
1654
1655 Include changed lines that are whitespace only (default: off)
1656
1657
1658 =item --changes-plugin Git
1659
1660 =item --changes-plugin +App::Yath::Plugin::Git
1661
1662 =item --no-changes-plugin
1663
1664 What plugin should be used to detect changed files.
1665
1666
1667 =item --default-at-search ARG
1668
1669 =item --default-at-search=ARG
1670
1671 =item --no-default-at-search
1672
1673 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
1674
1675 Can be specified multiple times
1676
1677
1678 =item --default-search ARG
1679
1680 =item --default-search=ARG
1681
1682 =item --no-default-search
1683
1684 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
1685
1686 Can be specified multiple times
1687
1688
1689 =item --durations file.json
1690
1691 =item --durations http://example.com/durations.json
1692
1693 =item --no-durations
1694
1695 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.
1696
1697
1698 =item --durations-threshold ARG
1699
1700 =item --durations-threshold=ARG
1701
1702 =item --Dt ARG
1703
1704 =item --Dt=ARG
1705
1706 =item --no-durations-threshold
1707
1708 Only fetch duration data if running at least this number of tests. Default (-j value + 1)
1709
1710
1711 =item --exclude-file t/nope.t
1712
1713 =item --no-exclude-file
1714
1715 Exclude a file from testing
1716
1717 Can be specified multiple times
1718
1719
1720 =item --exclude-list file.txt
1721
1722 =item --exclude-list http://example.com/exclusions.txt
1723
1724 =item --no-exclude-list
1725
1726 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).
1727
1728 Can be specified multiple times
1729
1730
1731 =item --exclude-pattern t/nope.t
1732
1733 =item --no-exclude-pattern
1734
1735 Exclude a pattern from testing, matched using m/$PATTERN/
1736
1737 Can be specified multiple times
1738
1739
1740 =item --extension ARG
1741
1742 =item --extension=ARG
1743
1744 =item --ext ARG
1745
1746 =item --ext=ARG
1747
1748 =item --no-extension
1749
1750 Specify valid test filename extensions, default: t and t2
1751
1752 Can be specified multiple times
1753
1754
1755 =item --maybe-durations file.json
1756
1757 =item --maybe-durations http://example.com/durations.json
1758
1759 =item --no-maybe-durations
1760
1761 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.
1762
1763
1764 =item --no-long
1765
1766 =item --no-no-long
1767
1768 Do not run tests that have their duration flag set to 'LONG'
1769
1770
1771 =item --only-long
1772
1773 =item --no-only-long
1774
1775 Only run tests that have their duration flag set to 'LONG'
1776
1777
1778 =item --rerun
1779
1780 =item --rerun=path/to/log.jsonl
1781
1782 =item --rerun=plugin_specific_string
1783
1784 =item --no-rerun
1785
1786 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.
1787
1788
1789 =item --rerun-all
1790
1791 =item --rerun-all=path/to/log.jsonl
1792
1793 =item --rerun-all=plugin_specific_string
1794
1795 =item --no-rerun-all
1796
1797 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.
1798
1799
1800 =item --rerun-failed
1801
1802 =item --rerun-failed=path/to/log.jsonl
1803
1804 =item --rerun-failed=plugin_specific_string
1805
1806 =item --no-rerun-failed
1807
1808 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.
1809
1810
1811 =item --rerun-missed
1812
1813 =item --rerun-missed=path/to/log.jsonl
1814
1815 =item --rerun-missed=plugin_specific_string
1816
1817 =item --no-rerun-missed
1818
1819 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.
1820
1821
1822 =item --rerun-modes failed,missed,...
1823
1824 =item --rerun-modes all
1825
1826 =item --rerun-modes failed
1827
1828 =item --rerun-modes missed
1829
1830 =item --rerun-modes passed
1831
1832 =item --rerun-modes retried
1833
1834 =item --rerun-mode failed,missed,...
1835
1836 =item --rerun-mode all
1837
1838 =item --rerun-mode failed
1839
1840 =item --rerun-mode missed
1841
1842 =item --rerun-mode passed
1843
1844 =item --rerun-mode retried
1845
1846 =item --no-rerun-modes
1847
1848 Pick which test categories to run
1849
1850 Can be specified multiple times
1851
1852
1853 =item --rerun-passed
1854
1855 =item --rerun-passed=path/to/log.jsonl
1856
1857 =item --rerun-passed=plugin_specific_string
1858
1859 =item --no-rerun-passed
1860
1861 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.
1862
1863
1864 =item --rerun-plugin Foo
1865
1866 =item --rerun-plugin +App::Yath::Plugin::Foo
1867
1868 =item --no-rerun-plugin
1869
1870 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)
1871
1872 Can be specified multiple times
1873
1874
1875 =item --rerun-retried
1876
1877 =item --rerun-retried=path/to/log.jsonl
1878
1879 =item --rerun-retried=plugin_specific_string
1880
1881 =item --no-rerun-retried
1882
1883 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.
1884
1885
1886 =item --search ARG
1887
1888 =item --search=ARG
1889
1890 =item --no-search
1891
1892 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.
1893
1894 Can be specified multiple times
1895
1896
1897 =item --show-changed-files
1898
1899 =item --no-show-changed-files
1900
1901 Print a list of changed files if any are found
1902
1903
1904 =back
1905
1906 =head3 Formatter Options
1907
1908 =over 4
1909
1910 =item --formatter ARG
1911
1912 =item --formatter=ARG
1913
1914 =item --no-formatter
1915
1916 NO DESCRIPTION - FIX ME
1917
1918
1919 =item --qvf
1920
1921 =item --no-qvf
1922
1923 [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.
1924
1925
1926 =item --show-job-end
1927
1928 =item --no-show-job-end
1929
1930 Show output when a job ends. (Default: on)
1931
1932
1933 =item --show-job-info
1934
1935 =item --no-show-job-info
1936
1937 Show the job configuration when a job starts. (Default: off, unless -vv)
1938
1939
1940 =item --show-job-launch
1941
1942 =item --no-show-job-launch
1943
1944 Show output for the start of a job. (Default: off unless -v)
1945
1946
1947 =item --show-run-info
1948
1949 =item --no-show-run-info
1950
1951 Show the run configuration when a run starts. (Default: off, unless -vv)
1952
1953
1954 =back
1955
1956 =head3 Git Options
1957
1958 =over 4
1959
1960 =item --git-change-base master
1961
1962 =item --git-change-base HEAD^
1963
1964 =item --git-change-base df22abe4
1965
1966 =item --no-git-change-base
1967
1968 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.
1969
1970
1971 =back
1972
1973 =head3 Help and Debugging
1974
1975 =over 4
1976
1977 =item --dummy
1978
1979 =item -d
1980
1981 =item --no-dummy
1982
1983 Dummy run, do not actually execute anything
1984
1985 Can also be set with the following environment variables: C<T2_HARNESS_DUMMY>
1986
1987
1988 =item --help
1989
1990 =item -h
1991
1992 =item --no-help
1993
1994 exit after showing help information
1995
1996
1997 =item --interactive
1998
1999 =item -i
2000
2001 =item --no-interactive
2002
2003 Use interactive mode, 1 test at a time, stdin forwarded to it
2004
2005
2006 =item --keep-dirs
2007
2008 =item --keep_dir
2009
2010 =item -k
2011
2012 =item --no-keep-dirs
2013
2014 Do not delete directories when done. This is useful if you want to inspect the directories used for various commands.
2015
2016
2017 =item --procname-prefix ARG
2018
2019 =item --procname-prefix=ARG
2020
2021 =item --no-procname-prefix
2022
2023 Add a prefix to all proc names (as seen by ps).
2024
2025
2026 =item --summary
2027
2028 =item --summary=/path/to/summary.json
2029
2030 =item --no-summary
2031
2032 Write out a summary json file, if no path is provided 'summary.json' will be used. The .json extension is added automatically if omitted.
2033
2034
2035 =back
2036
2037 =head3 Logging Options
2038
2039 =over 4
2040
2041 =item --bzip2
2042
2043 =item --bz2
2044
2045 =item --bzip2_log
2046
2047 =item -B
2048
2049 =item --no-bzip2
2050
2051 Use bzip2 compression when writing the log. This option implies -L. The .bz2 prefix is added to log file name for you
2052
2053
2054 =item --gzip
2055
2056 =item --gz
2057
2058 =item --gzip_log
2059
2060 =item -G
2061
2062 =item --no-gzip
2063
2064 Use gzip compression when writing the log. This option implies -L. The .gz prefix is added to log file name for you
2065
2066
2067 =item --log
2068
2069 =item -L
2070
2071 =item --no-log
2072
2073 Turn on logging
2074
2075
2076 =item --log-dir ARG
2077
2078 =item --log-dir=ARG
2079
2080 =item --no-log-dir
2081
2082 Specify a log directory. Will fall back to the system temp dir.
2083
2084
2085 =item --log-file ARG
2086
2087 =item --log-file=ARG
2088
2089 =item -F ARG
2090
2091 =item -F=ARG
2092
2093 =item --no-log-file
2094
2095 Specify the name of the log file. This option implies -L.
2096
2097
2098 =item --log-file-format ARG
2099
2100 =item --log-file-format=ARG
2101
2102 =item --lff ARG
2103
2104 =item --lff=ARG
2105
2106 =item --no-log-file-format
2107
2108 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)
2109
2110 Can also be set with the following environment variables: C<YATH_LOG_FILE_FORMAT>, C<TEST2_HARNESS_LOG_FORMAT>
2111
2112
2113 =back
2114
2115 =head3 Notification Options
2116
2117 =over 4
2118
2119 =item --notify-email [email protected]
2120
2121 =item --no-notify-email
2122
2123 Email the test results to the specified email address(es)
2124
2125 Can be specified multiple times
2126
2127
2128 =item --notify-email-fail [email protected]
2129
2130 =item --no-notify-email-fail
2131
2132 Email failing results to the specified email address(es)
2133
2134 Can be specified multiple times
2135
2136
2137 =item --notify-email-from [email protected]
2138
2139 =item --no-notify-email-from
2140
2141 If any email is sent, this is who it will be from
2142
2143
2144 =item --notify-email-owner
2145
2146 =item --no-notify-email-owner
2147
2148 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
2149
2150
2151 =item --notify-no-batch-email
2152
2153 =item --no-notify-no-batch-email
2154
2155 Usually owner failures are sent as a single batch at the end of testing. Toggle this to send failures as they happen.
2156
2157
2158 =item --notify-no-batch-slack
2159
2160 =item --no-notify-no-batch-slack
2161
2162 Usually owner failures are sent as a single batch at the end of testing. Toggle this to send failures as they happen.
2163
2164
2165 =item --notify-slack '#foo'
2166
2167 =item --notify-slack '@bar'
2168
2169 =item --no-notify-slack
2170
2171 Send results to a slack channel and/or user
2172
2173 Can be specified multiple times
2174
2175
2176 =item --notify-slack-fail '#foo'
2177
2178 =item --notify-slack-fail '@bar'
2179
2180 =item --no-notify-slack-fail
2181
2182 Send failing results to a slack channel and/or user
2183
2184 Can be specified multiple times
2185
2186
2187 =item --notify-slack-owner
2188
2189 =item --no-notify-slack-owner
2190
2191 Send slack notifications to the slack channels/users listed in test meta-data when tests fail.
2192
2193
2194 =item --notify-slack-url https://hooks.slack.com/...
2195
2196 =item --no-notify-slack-url
2197
2198 Specify an API endpoint for slack webhook integrations
2199
2200
2201 =item --notify-text ARG
2202
2203 =item --notify-text=ARG
2204
2205 =item --message ARG
2206
2207 =item --message=ARG
2208
2209 =item --msg ARG
2210
2211 =item --msg=ARG
2212
2213 =item --no-notify-text
2214
2215 Add a custom text snippet to email/slack notifications
2216
2217
2218 =item --notify-text-module ARG
2219
2220 =item --notify-text-module=ARG
2221
2222 =item --message_module ARG
2223
2224 =item --message_module=ARG
2225
2226 =item --no-notify-text-module
2227
2228 Use the specified module to generate messages for emails and/or slack.
2229
2230
2231 =back
2232
2233 =head3 Run Options
2234
2235 =over 4
2236
2237 =item --author-testing
2238
2239 =item -A
2240
2241 =item --no-author-testing
2242
2243 This will set the AUTHOR_TESTING environment to true
2244
2245
2246 =item --dbi-profiling
2247
2248 =item --no-dbi-profiling
2249
2250 Use Test2::Plugin::DBIProfile to collect database profiling data
2251
2252
2253 =item --env-var VAR=VAL
2254
2255 =item -EVAR=VAL
2256
2257 =item -E VAR=VAL
2258
2259 =item --no-env-var
2260
2261 Set environment variables to set when each test is run.
2262
2263 Can be specified multiple times
2264
2265
2266 =item --event-uuids
2267
2268 =item --uuids
2269
2270 =item --no-event-uuids
2271
2272 Use Test2::Plugin::UUID inside tests (default: on)
2273
2274
2275 =item --fields name:details
2276
2277 =item --fields JSON_STRING
2278
2279 =item -f name:details
2280
2281 =item -f JSON_STRING
2282
2283 =item --no-fields
2284
2285 Add custom data to the harness run
2286
2287 Can be specified multiple times
2288
2289
2290 =item --input ARG
2291
2292 =item --input=ARG
2293
2294 =item --no-input
2295
2296 Input string to be used as standard input for ALL tests. See also: --input-file
2297
2298
2299 =item --input-file ARG
2300
2301 =item --input-file=ARG
2302
2303 =item --no-input-file
2304
2305 Use the specified file as standard input to ALL tests
2306
2307
2308 =item --io-events
2309
2310 =item --no-io-events
2311
2312 Use Test2::Plugin::IOEvents inside tests to turn all prints into test2 events (default: off)
2313
2314
2315 =item --link 'https://travis.work/builds/42'
2316
2317 =item --link 'https://jenkins.work/job/42'
2318
2319 =item --link 'https://buildbot.work/builders/foo/builds/42'
2320
2321 =item --no-link
2322
2323 Provide one or more links people can follow to see more about this run.
2324
2325 Can be specified multiple times
2326
2327
2328 =item --load ARG
2329
2330 =item --load=ARG
2331
2332 =item --load-module ARG
2333
2334 =item --load-module=ARG
2335
2336 =item -m ARG
2337
2338 =item -m=ARG
2339
2340 =item --no-load
2341
2342 Load a module in each test (after fork). The "import" method is not called.
2343
2344 Can be specified multiple times
2345
2346
2347 =item --load-import Module
2348
2349 =item --load-import Module=import_arg1,arg2,...
2350
2351 =item --loadim Module
2352
2353 =item --loadim Module=import_arg1,arg2,...
2354
2355 =item -M Module
2356
2357 =item -M Module=import_arg1,arg2,...
2358
2359 =item --no-load-import
2360
2361 Load a module in each test (after fork). Import is called.
2362
2363 Can be specified multiple times. If the same key is listed multiple times the value lists will be appended together.
2364
2365
2366 =item --mem-usage
2367
2368 =item --no-mem-usage
2369
2370 Use Test2::Plugin::MemUsage inside tests (default: on)
2371
2372
2373 =item --retry ARG
2374
2375 =item --retry=ARG
2376
2377 =item -r ARG
2378
2379 =item -r=ARG
2380
2381 =item --no-retry
2382
2383 Run any jobs that failed a second time. NOTE: --retry=1 means failing tests will be attempted twice!
2384
2385
2386 =item --retry-isolated
2387
2388 =item --retry-iso
2389
2390 =item --no-retry-isolated
2391
2392 If true then any job retries will be done in isolation (as though -j1 was set)
2393
2394
2395 =item --run-id
2396
2397 =item --id
2398
2399 =item --no-run-id
2400
2401 Set a specific run-id. (Default: a UUID)
2402
2403
2404 =item --test-args ARG
2405
2406 =item --test-args=ARG
2407
2408 =item --no-test-args
2409
2410 Arguments to pass in as @ARGV for all tests that are run. These can be provided easier using the '::' argument separator.
2411
2412 Can be specified multiple times
2413
2414
2415 =item --stream
2416
2417 =item --no-stream
2418
2419 Use the stream formatter (default is on)
2420
2421
2422 =item --tap
2423
2424 =item --TAP
2425
2426 =item ----no-stream
2427
2428 =item --no-tap
2429
2430 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.
2431
2432
2433 =back
2434
2435 =head3 Runner Options
2436
2437 =over 4
2438
2439 =item --abort-on-bail
2440
2441 =item --no-abort-on-bail
2442
2443 Abort all testing if a bail-out is encountered (default: on)
2444
2445
2446 =item --blib
2447
2448 =item -b
2449
2450 =item --no-blib
2451
2452 (Default: include if it exists) Include 'blib/lib' and 'blib/arch' in your module path
2453
2454
2455 =item --cover
2456
2457 =item --cover=-silent,1,+ignore,^t/,+ignore,^t2/,+ignore,^xt,+ignore,^test.pl
2458
2459 =item --no-cover
2460
2461 Use Devel::Cover to calculate test coverage. This disables forking. If no args are specified the following are used: -silent,1,+ignore,^t/,+ignore,^t2/,+ignore,^xt,+ignore,^test.pl
2462
2463
2464 =item --dump-depmap
2465
2466 =item --no-dump-depmap
2467
2468 When using staged preload, dump the depmap for each stage as json files
2469
2470
2471 =item --event-timeout SECONDS
2472
2473 =item --et SECONDS
2474
2475 =item --no-event-timeout
2476
2477 Kill test if no output is received within timeout period. (Default: 60 seconds). Add the "# HARNESS-NO-TIMEOUT" comment to the top of a test file to disable timeouts on a per-test basis. This prevents a hung test from running forever.
2478
2479
2480 =item --fail-on-resource-skip
2481
2482 =item --no-fail-on-resource-skip
2483
2484 Treat resource-skipped tests as failures instead of skips. When enabled, tests that would be skipped due to unavailable resources will be marked as failing.
2485
2486
2487 =item --include ARG
2488
2489 =item --include=ARG
2490
2491 =item -I ARG
2492
2493 =item -I=ARG
2494
2495 =item --no-include
2496
2497 Add a directory to your include paths
2498
2499 Can be specified multiple times
2500
2501
2502 =item --job-count 4
2503
2504 =item --job-count 8:2
2505
2506 =item --jobs 4
2507
2508 =item --jobs 8:2
2509
2510 =item -j4
2511
2512 =item -j8:2
2513
2514 =item --no-job-count
2515
2516 Set the number of concurrent jobs to run. Add a :# if you also wish to designate multiple slots per test. 8:2 means 8 slots, but each test gets 2 slots, so 4 tests run concurrently. Tests can find their concurrency assignment in the "T2_HARNESS_MY_JOB_CONCURRENCY" environment variable.
2517
2518 Can also be set with the following environment variables: C<YATH_JOB_COUNT>, C<T2_HARNESS_JOB_COUNT>, C<HARNESS_JOB_COUNT>
2519
2520
2521 =item --lib
2522
2523 =item -l
2524
2525 =item --no-lib
2526
2527 (Default: include if it exists) Include 'lib' in your module path
2528
2529
2530 =item --nytprof
2531
2532 =item --no-nytprof
2533
2534 Use Devel::NYTProf on tests. This will set addpid=1 for you. This works with or without fork.
2535
2536
2537 =item --post-exit-timeout SECONDS
2538
2539 =item --pet SECONDS
2540
2541 =item --no-post-exit-timeout
2542
2543 Stop waiting post-exit after the timeout period. (Default: 15 seconds) Some tests fork and allow the parent to exit before writing all their output. If Test2::Harness detects an incomplete plan after the test exits it will monitor for more events until the timeout period. Add the "# HARNESS-NO-TIMEOUT" comment to the top of a test file to disable timeouts on a per-test basis.
2544
2545
2546 =item --preload-threshold ARG
2547
2548 =item --preload-threshold=ARG
2549
2550 =item --Pt ARG
2551
2552 =item --Pt=ARG
2553
2554 =item -W ARG
2555
2556 =item -W=ARG
2557
2558 =item --no-preload-threshold
2559
2560 Only do preload if at least N tests are going to be run. In some cases a full preload takes longer than simply running the tests, this lets you specify a minimum number of test jobs that will be run for preload to happen. This has no effect for a persistent runner. The default is 0, and it means always preload.
2561
2562
2563 =item --preloads ARG
2564
2565 =item --preloads=ARG
2566
2567 =item --preload ARG
2568
2569 =item --preload=ARG
2570
2571 =item -P ARG
2572
2573 =item -P=ARG
2574
2575 =item --no-preloads
2576
2577 Preload a module before running tests
2578
2579 Can be specified multiple times
2580
2581
2582 =item --resource-timeout SECONDS
2583
2584 =item --rt SECONDS
2585
2586 =item --no-resource-timeout
2587
2588 Abort the test run if no tests have been able to start for SECONDS seconds while there are pending tests and none running. This is useful when a resource class is broken and always claims a resource will become available, preventing yath from ever finishing. (Default: 0, meaning no timeout)
2589
2590
2591 =item --resource Port
2592
2593 =item --resource +Test2::Harness::Runner::Resource::Port
2594
2595 =item -R Port
2596
2597 =item --no-resource
2598
2599 Use a resource module to assign resource assignments to individual tests
2600
2601 Can be specified multiple times
2602
2603
2604 =item --runner-id ARG
2605
2606 =item --runner-id=ARG
2607
2608 =item --no-runner-id
2609
2610 Runner ID (usually a generated uuid)
2611
2612
2613 =item --shared-jobs-config .sharedjobslots.yml
2614
2615 =item --shared-jobs-config relative/path/.sharedjobslots.yml
2616
2617 =item --shared-jobs-config /absolute/path/.sharedjobslots.yml
2618
2619 =item --no-shared-jobs-config
2620
2621 Where to look for a shared slot config file. If a filename with no path is provided yath will search the current and all parent directories for the name.
2622
2623
2624 =item --slots-per-job 2
2625
2626 =item -x2
2627
2628 =item --no-slots-per-job
2629
2630 This sets the number of slots each job will use (default 1). This is normally set by the ':#' in '-j#:#'.
2631
2632 Can also be set with the following environment variables: C<T2_HARNESS_JOB_CONCURRENCY>
2633
2634
2635 =item --stall-report
2636
2637 =item --stall-report=STRONG:LOOSE
2638
2639 =item --stall-report=SECONDS
2640
2641 =item --no-stall-report
2642
2643 Print diagnostics when the scheduler appears to have stopped starting tests. Give it alone for sensible waits, or set them: STRONG is the wait, in seconds, before reporting when tests are pending and none are running; LOOSE is the wait when tests are pending and others are still running. A single number sets both, and a zero in either field turns off that tier alone, so 600:0 reports only when nothing is running. This only prints a report, it never ends the run, and a report may be benign. Enabling it sends SIGUSR1 to yath's own processes to collect stack traces, pauses output for a few seconds per report, stops after 5 reports, and writes a yath-stall-report-*.json bundle both into the run log and to a file (see --stall-report-dir). (Default: off; --stall-report alone means 600:1200)
2644
2645
2646 =item --stall-report-dir path/to/dir
2647
2648 =item --no-stall-report-dir
2649
2650 Directory for the JSON bundle --stall-report writes. Defaults to the directory yath was run from. Use this when that directory is not writable, or to collect bundles somewhere durable.
2651
2652
2653 =item --switch ARG
2654
2655 =item --switch=ARG
2656
2657 =item -S ARG
2658
2659 =item -S=ARG
2660
2661 =item --no-switch
2662
2663 Pass the specified switch to perl for each test. This is not compatible with preload.
2664
2665 Can be specified multiple times
2666
2667
2668 =item --tlib
2669
2670 =item --no-tlib
2671
2672 (Default: off) Include 't/lib' in your module path
2673
2674
2675 =item --unsafe-inc
2676
2677 =item --no-unsafe-inc
2678
2679 perl is removing '.' from @INC as a security concern. This option keeps things from breaking for now.
2680
2681 Can also be set with the following environment variables: C<PERL_USE_UNSAFE_INC>
2682
2683
2684 =item --use-fork
2685
2686 =item --fork
2687
2688 =item --no-use-fork
2689
2690 (default: on, except on windows) Normally tests are run by forking, which allows for features like preloading. This will turn off the behavior globally (which is not compatible with preloading). This is slower, it is better to tag misbehaving tests with the '# HARNESS-NO-PRELOAD' comment in their header to disable forking only for those tests.
2691
2692 Can also be set with the following environment variables: C<!T2_NO_FORK>, C<T2_HARNESS_FORK>, C<!T2_HARNESS_NO_FORK>, C<YATH_FORK>, C<!YATH_NO_FORK>
2693
2694
2695 =item --use-timeout
2696
2697 =item --timeout
2698
2699 =item --no-use-timeout
2700
2701 (default: on) Enable/disable timeouts
2702
2703
2704 =back
2705
2706 =head3 Workspace Options
2707
2708 =over 4
2709
2710 =item --clear
2711
2712 =item -C
2713
2714 =item --no-clear
2715
2716 Clear the work directory if it is not already empty
2717
2718
2719 =item --tmp-dir ARG
2720
2721 =item --tmp-dir=ARG
2722
2723 =item --tmpdir ARG
2724
2725 =item --tmpdir=ARG
2726
2727 =item -t ARG
2728
2729 =item -t=ARG
2730
2731 =item --no-tmp-dir
2732
2733 Use a specific temp directory (Default: use system temp dir)
2734
2735 Can also be set with the following environment variables: C<T2_HARNESS_TEMP_DIR>, C<YATH_TEMP_DIR>, C<TMPDIR>, C<TEMPDIR>, C<TMP_DIR>, C<TEMP_DIR>
2736
2737
2738 =item --workdir ARG
2739
2740 =item --workdir=ARG
2741
2742 =item -w ARG
2743
2744 =item -w=ARG
2745
2746 =item --no-workdir
2747
2748 Set the work directory (Default: new temp directory)
2749
2750 Can also be set with the following environment variables: C<T2_WORKDIR>, C<YATH_WORKDIR>
2751
2752
2753 =back
2754
2755 =head3 YathUI Options
2756
2757 =over 4
2758
2759 =item --yathui-api-key ARG
2760
2761 =item --yathui-api-key=ARG
2762
2763 =item --no-yathui-api-key
2764
2765 Yath-UI API key. This is not necessary if your Yath-UI instance is set to single-user
2766
2767
2768 =item --yathui-coverage
2769
2770 =item --no-yathui-coverage
2771
2772 Poll coverage data from Yath-UI to determine what tests should be run for changed files
2773
2774
2775 =item --yathui-durations
2776
2777 =item --no-yathui-durations
2778
2779 Poll duration data from Yath-UI to help order tests efficiently
2780
2781
2782 =item --yathui-grace
2783
2784 =item --no-yathui-grace
2785
2786 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.
2787
2788
2789 =item --yathui-long-duration 10
2790
2791 =item --no-yathui-long-duration
2792
2793 Minimum duration length (seconds) before a test goes from MEDIUM to LONG
2794
2795
2796 =item --yathui-medium-duration 5
2797
2798 =item --no-yathui-medium-duration
2799
2800 Minimum duration length (seconds) before a test goes from SHORT to MEDIUM
2801
2802
2803 =item --yathui-mode summary
2804
2805 =item --yathui-mode qvf
2806
2807 =item --yathui-mode qvfd
2808
2809 =item --yathui-mode complete
2810
2811 =item --no-yathui-mode
2812
2813 Set the upload mode (default 'qvfd')
2814
2815
2816 =item --yathui-project ARG
2817
2818 =item --yathui-project=ARG
2819
2820 =item --no-yathui-project
2821
2822 The Yath-UI project for your test results
2823
2824
2825 =item --yathui-retry
2826
2827 =item --no-yathui-retry
2828
2829 How many times to try an operation before giving up
2830
2831 Can be specified multiple times
2832
2833
2834 =item --yathui-upload
2835
2836 =item --no-yathui-upload
2837
2838 Upload the log to Yath-UI
2839
2840
2841 =item --yathui-url http://my-yath-ui.com/...
2842
2843 =item --uri http://my-yath-ui.com/...
2844
2845 =item --no-yathui-url
2846
2847 Yath-UI url
2848
2849
2850 =back
2851
2852 =head1 SOURCE
2853
2854 The source code repository for Test2-Harness can be found at
2855 F<http://github.com/Test-More/Test2-Harness/>.
2856
2857 =head1 MAINTAINERS
2858
2859 =over 4
2860
2861 =item Chad Granum E<lt>[email protected]<gt>
2862
2863 =back
2864
2865 =head1 AUTHORS
2866
2867 =over 4
2868
2869 =item Chad Granum E<lt>[email protected]<gt>
2870
2871 =back
2872
2873 =head1 COPYRIGHT
2874
2875 Copyright 2026 Chad Granum E<lt>[email protected]<gt>.
2876
2877 This program is free software; you can redistribute it and/or
2878 modify it under the same terms as Perl itself.
2879
2880 See F<http://dev.perl.org/licenses/>
2881
2882 =cut
2883