| 1 |
package App::Yath::Command::runner; |
| 2 |
use strict; |
| 3 |
use warnings; |
| 4 |
|
| 5 |
our $VERSION = '1.000179'; |
| 6 |
|
| 7 |
use Config qw/%Config/; |
| 8 |
use File::Spec; |
| 9 |
|
| 10 |
# For some reason Filter::Util::Class breaks the STDIN filehandle. This works |
| 11 |
# around that. |
| 12 |
my $FIX_STDIN; |
| 13 |
BEGIN { |
| 14 |
require goto::file; |
| 15 |
no strict 'refs'; |
| 16 |
no warnings 'redefine'; |
| 17 |
|
| 18 |
my $int_done; |
| 19 |
my $orig = goto::file->can('filter'); |
| 20 |
*goto::file::filter = sub { |
| 21 |
local $.; |
| 22 |
my $out = $orig->(@_); |
| 23 |
seek(STDIN, 0, 0) if $FIX_STDIN; |
| 24 |
|
| 25 |
unless ($int_done++) { |
| 26 |
if (my $fifo = $ENV{YATH_INTERACTIVE}) { |
| 27 |
my $ok; |
| 28 |
for (1 .. 10) { |
| 29 |
$ok = open(STDIN, '<', $fifo); |
| 30 |
last if $ok; |
| 31 |
die "Could not open fifo ($fifo): $!"; |
| 32 |
sleep 1; |
| 33 |
} |
| 34 |
|
| 35 |
die "Could not open fifo ($fifo): $!" unless $ok; |
| 36 |
|
| 37 |
print STDERR <<' EOT'; |
| 38 |
|
| 39 |
******************************************************************************* |
| 40 |
* YATH IS RUNNING IN INTERACTIVE MODE * |
| 41 |
* * |
| 42 |
* STDIN is comming from a fifo pipe, not a TTY! * |
| 43 |
* * |
| 44 |
* The $ENV{YATH_INTERACTIVE} var is set to the FIFO being used. * |
| 45 |
* * |
| 46 |
* VERBOSE mode has been turned on for you * |
| 47 |
* * |
| 48 |
* Only 1 test will run at a time * |
| 49 |
* * |
| 50 |
* The main yath process no longer has STDIN, so yath plugins that wait for * |
| 51 |
* input WILL BREAK. * |
| 52 |
* * |
| 53 |
* Prompts that do not end with a newline may have a 1 second delay before * |
| 54 |
* they are displayed, they will be prefixed with [INTERACTIVE] * |
| 55 |
* * |
| 56 |
* Any stdin/stdout that is printed in 2 parts without a newline and more than * |
| 57 |
* a 1 second delay will be printed with the [INTERACTIVE] prefix, if they are * |
| 58 |
* not actually a prompt you can safely ignore them. * |
| 59 |
* * |
| 60 |
* It is possible that a prompt was displayed before this message, please * |
| 61 |
* check above if your prompt appears missing. This is an IO fluke, not a bug. * |
| 62 |
* * |
| 63 |
******************************************************************************* |
| 64 |
|
| 65 |
EOT |
| 66 |
} |
| 67 |
} |
| 68 |
|
| 69 |
return $out; |
| 70 |
}; |
| 71 |
} |
| 72 |
|
| 73 |
use Test2::Harness::IPC(); |
| 74 |
|
| 75 |
use Carp qw/confess/; |
| 76 |
use Scalar::Util qw/openhandle/; |
| 77 |
use List::Util qw/first/; |
| 78 |
use File::Path qw/remove_tree/; |
| 79 |
|
| 80 |
use Scope::Guard; |
| 81 |
|
| 82 |
use Test2::Util qw/clone_io/; |
| 83 |
|
| 84 |
use Long::Jump qw/setjump longjump/; |
| 85 |
|
| 86 |
use Test2::Harness::Util qw/mod2file write_file_atomic open_file clean_path process_includes/; |
| 87 |
|
| 88 |
use Test2::Harness::Util::IPC qw/swap_io/; |
| 89 |
|
| 90 |
use Test2::Harness::Runner::Preloader(); |
| 91 |
use Test2::Harness::Stall::Detector(); |
| 92 |
use Test2::Harness::Stall::Trace qw/install_trace_handler/; |
| 93 |
|
| 94 |
my @SIGNALS = grep { $_ ne 'ZERO' } split /\s+/, $Config{sig_name}; |
| 95 |
|
| 96 |
# If FindBin is installed, go ahead and load it. We do not care much about |
| 97 |
# success vs failure here. |
| 98 |
BEGIN { |
| 99 |
local $@; |
| 100 |
eval { require FindBin; FindBin->import }; |
| 101 |
} |
| 102 |
|
| 103 |
use parent 'App::Yath::Command'; |
| 104 |
use Test2::Harness::Util::HashBase; |
| 105 |
|
| 106 |
sub internal_only { 1 } |
| 107 |
sub summary { "For internal use only" } |
| 108 |
sub name { 'runner' } |
| 109 |
|
| 110 |
sub init { confess(ref($_[0]) . " is not intended to be instantiated") } |
| 111 |
sub run { confess(ref($_[0]) . " does not implement run()") } |
| 112 |
|
| 113 |
our $RUNNER_PID; |
| 114 |
sub generate_run_sub { |
| 115 |
my $class = shift; |
| 116 |
my ($symbol, $argv, $spawn_settings) = @_; |
| 117 |
my ($dir, %args) = @$argv; |
| 118 |
|
| 119 |
$RUNNER_PID = $$; |
| 120 |
my $runner_pid = $$; |
| 121 |
my $settings = Test2::Harness::Settings->new(File::Spec->catfile($dir, 'settings.json')); |
| 122 |
|
| 123 |
my $name = $ENV{NESTED_YATH} ? 'yath-nested-runner' : 'yath-runner'; |
| 124 |
$name = $settings->debug->procname_prefix . "-${name}" if $settings->debug->procname_prefix; |
| 125 |
$0 = $name; |
| 126 |
|
| 127 |
my $cleanup = $class->cleanup($settings, \%args, $dir); |
| 128 |
|
| 129 |
my $jump = setjump "Test-Runner" => sub { |
| 130 |
local $.; |
| 131 |
|
| 132 |
my %orig_sig = %SIG; |
| 133 |
|
| 134 |
# After the snapshot on purpose: the scheduler and stage forks inherit |
| 135 |
# this, and a test job sheds it when the guard below restores |
| 136 |
# %orig_sig. A job process must not keep it -- see the trace module. |
| 137 |
# Only when the feature is on: installing it changes what SIGUSR1 does |
| 138 |
# to a running yath process. |
| 139 |
# List context on purpose: parse_spec returns a list, so a boolean |
| 140 |
# test would see only its last value and miss STRONG:0. |
| 141 |
my %stall = |
| 142 |
$settings->check_prefix('runner') |
| 143 |
? Test2::Harness::Stall::Detector->parse_spec($settings->runner->stall_report) |
| 144 |
: (); |
| 145 |
install_trace_handler(File::Spec->catdir($dir, 'stall')) if %stall; |
| 146 |
|
| 147 |
my $guard = Scope::Guard->new(sub { |
| 148 |
my %seen; |
| 149 |
for my $sig (@SIGNALS) { |
| 150 |
next if $seen{$sig}++; |
| 151 |
if (exists $orig_sig{$sig}) { |
| 152 |
$SIG{$sig} = $orig_sig{$sig}; |
| 153 |
} |
| 154 |
else { |
| 155 |
delete $SIG{$sig}; |
| 156 |
} |
| 157 |
} |
| 158 |
}); |
| 159 |
|
| 160 |
my $runner = $settings->build( |
| 161 |
runner => 'Test2::Harness::Runner', |
| 162 |
|
| 163 |
%args, |
| 164 |
|
| 165 |
dir => $dir, |
| 166 |
settings => $settings, |
| 167 |
|
| 168 |
fork_job_callback => sub { $class->launch_via_fork(@_) }, |
| 169 |
fork_spawn_callback => sub { $class->launch_spawn(@_) }, |
| 170 |
respawn_runner_callback => sub { return unless $$ == $runner_pid; longjump "Test-Runner" => 'respawn' }, |
| 171 |
); |
| 172 |
|
| 173 |
my $exit = $runner->process(); |
| 174 |
|
| 175 |
if ($$ == $runner_pid) { |
| 176 |
$_->cleanup() for @{$runner->state->resources}; |
| 177 |
} |
| 178 |
|
| 179 |
my $complete = File::Spec->catfile($dir, 'complete'); |
| 180 |
write_file_atomic($complete, '1'); |
| 181 |
|
| 182 |
exit($exit // 1); |
| 183 |
}; |
| 184 |
|
| 185 |
die "Test runner completed, but failed to exit" unless $jump; |
| 186 |
|
| 187 |
my ($action, $job, $stage) = @$jump; |
| 188 |
|
| 189 |
if($action eq 'respawn') { |
| 190 |
print "$$ Respawning the runner...\n"; |
| 191 |
$cleanup->dismiss(1); |
| 192 |
exec($^X, $settings->harness->script, @{$spawn_settings->harness->orig_argv}); |
| 193 |
warn "exec failed!"; |
| 194 |
exit 1; |
| 195 |
} |
| 196 |
|
| 197 |
die "Invalid action: $action" if $action ne 'run_test'; |
| 198 |
|
| 199 |
if (my $chdir = $job->ch_dir) { |
| 200 |
chdir($chdir) or die "Could not chdir: $!"; |
| 201 |
} |
| 202 |
goto::file->import($job->run_file); |
| 203 |
$class->cleanup_process($job, $stage); |
| 204 |
DB::enable_profile() if $settings->runner->nytprof; |
| 205 |
} |
| 206 |
|
| 207 |
sub cleanup { |
| 208 |
my $class = shift; |
| 209 |
my ($settings, $args, $dir) = @_; |
| 210 |
|
| 211 |
my $pfile = $args->{persist} or return; |
| 212 |
|
| 213 |
my $pid = $$; |
| 214 |
return Scope::Guard->new(sub { |
| 215 |
return unless $pid == $$; |
| 216 |
|
| 217 |
unlink($pfile); |
| 218 |
|
| 219 |
remove_tree($dir, {safe => 1, keep_root => 0}) unless $settings->debug->keep_dirs; |
| 220 |
}); |
| 221 |
} |
| 222 |
|
| 223 |
sub get_stage { |
| 224 |
my $class = shift; |
| 225 |
my ($runner) = @_; |
| 226 |
|
| 227 |
return unless $runner->can('stage'); |
| 228 |
|
| 229 |
my $stage_name = $runner->stage or return; |
| 230 |
my $preloader = $runner->preloader or return; |
| 231 |
my $p = $preloader->staged or return; |
| 232 |
|
| 233 |
return $p->stage_lookup->{$stage_name}; |
| 234 |
} |
| 235 |
|
| 236 |
sub launch_spawn { |
| 237 |
my $class = shift; |
| 238 |
my ($runner, $spawn) = @_; |
| 239 |
|
| 240 |
my $pid = fork() // die $!; |
| 241 |
if ($pid) { |
| 242 |
local $?; |
| 243 |
waitpid($pid, 0); |
| 244 |
return; |
| 245 |
} |
| 246 |
|
| 247 |
require POSIX; |
| 248 |
POSIX::setsid or die "setsid: $!"; |
| 249 |
|
| 250 |
$pid = fork // die $!; |
| 251 |
exit 0 if $pid; |
| 252 |
|
| 253 |
eval { |
| 254 |
my ($wh); |
| 255 |
pipe(STDIN, $wh) or die "Could not create pipe: $!"; |
| 256 |
$pid = $class->launch_via_fork($runner, $spawn); |
| 257 |
|
| 258 |
if ($pid) { |
| 259 |
open(my $fh, '>>', $spawn->{task}->{ipcfile}) or die "Could not open pidfile: $!"; |
| 260 |
print $fh "$$\n$pid\n" . fileno($wh) . "\n"; |
| 261 |
$fh->flush(); |
| 262 |
local $?; |
| 263 |
waitpid($pid, 0); |
| 264 |
print $fh "$?\n"; |
| 265 |
close($fh); |
| 266 |
} |
| 267 |
|
| 268 |
exit(0); |
| 269 |
}; |
| 270 |
warn "Unknown problem daemonizing: $@"; |
| 271 |
exit(1); |
| 272 |
} |
| 273 |
|
| 274 |
sub launch_via_fork { |
| 275 |
my $class = shift; |
| 276 |
my ($runner, $job) = @_; |
| 277 |
|
| 278 |
my $stage = $class->get_stage($runner); |
| 279 |
|
| 280 |
$stage->do_pre_fork($job) if $stage; |
| 281 |
|
| 282 |
my $pid = fork(); |
| 283 |
die "Failed to fork: $!" unless defined $pid; |
| 284 |
|
| 285 |
# In parent |
| 286 |
return $pid if $pid; |
| 287 |
|
| 288 |
# In Child |
| 289 |
my $ok = eval { |
| 290 |
$0 = 'yath-pending-test'; |
| 291 |
setpgrp(0, 0) if Test2::Harness::IPC::USE_P_GROUPS(); |
| 292 |
$runner->stop(); |
| 293 |
|
| 294 |
$stage->do_post_fork($job) if $stage; |
| 295 |
|
| 296 |
longjump "Test-Runner" => ('run_test', $job, $stage); |
| 297 |
|
| 298 |
1; |
| 299 |
}; |
| 300 |
my $err = $@; |
| 301 |
eval { warn $err } unless $ok; |
| 302 |
exit(1); |
| 303 |
} |
| 304 |
|
| 305 |
sub cleanup_process { |
| 306 |
my $class = shift; |
| 307 |
my ($job, $stage) = @_; |
| 308 |
|
| 309 |
$class->update_io($job); # Get the correct filehandles in place early |
| 310 |
$class->set_env($job); # Set up the necessary env vars |
| 311 |
$class->build_init_state($job); # Lots of 'misc' stuff. |
| 312 |
$class->do_loads($job); # Modules that we wanted loaded/imported post fork |
| 313 |
$class->test2_state($job); # Normalize the Test2 state |
| 314 |
|
| 315 |
$stage->do_pre_launch($job) if $stage; |
| 316 |
|
| 317 |
$class->final_state($job); # Important final cleanup |
| 318 |
} |
| 319 |
|
| 320 |
sub test2_state { |
| 321 |
my $class = shift; |
| 322 |
my ($job) = @_; |
| 323 |
|
| 324 |
if ($INC{'Test2/API.pm'}) { |
| 325 |
Test2::API::test2_stop_preload(); |
| 326 |
Test2::API::test2_post_preload_reset(); |
| 327 |
} |
| 328 |
|
| 329 |
if ($job->use_stream) { |
| 330 |
$ENV{T2_FORMATTER} = 'Stream'; |
| 331 |
require Test2::Formatter::Stream; |
| 332 |
Test2::Formatter::Stream->import(dir => $job->event_dir, job_id => $job->job_id); |
| 333 |
} |
| 334 |
|
| 335 |
if ($job->event_uuids) { |
| 336 |
require Test2::Plugin::UUID; |
| 337 |
Test2::Plugin::UUID->import(); |
| 338 |
} |
| 339 |
|
| 340 |
if ($job->mem_usage) { |
| 341 |
require Test2::Plugin::MemUsage; |
| 342 |
Test2::Plugin::MemUsage->import(); |
| 343 |
} |
| 344 |
|
| 345 |
if ($job->io_events) { |
| 346 |
require Test2::Plugin::IOEvents; |
| 347 |
Test2::Plugin::IOEvents->import(); |
| 348 |
} |
| 349 |
|
| 350 |
return; |
| 351 |
} |
| 352 |
|
| 353 |
sub final_state { |
| 354 |
my $class = shift; |
| 355 |
my ($job) = @_; |
| 356 |
|
| 357 |
@ARGV = $job->args; |
| 358 |
|
| 359 |
# toggle -w switch late |
| 360 |
$^W = 1 if $job->use_w_switch; |
| 361 |
|
| 362 |
# reset the state of empty pattern matches, so that they have the same |
| 363 |
# behavior as running in a clean process. |
| 364 |
# see "The empty pattern //" in perlop. |
| 365 |
# note that this has to be dynamically scoped and can't go to other subs |
| 366 |
"" =~ /^/; |
| 367 |
|
| 368 |
return; |
| 369 |
} |
| 370 |
|
| 371 |
sub do_loads { |
| 372 |
my $class = shift; |
| 373 |
my ($job) = @_; |
| 374 |
|
| 375 |
local $@; |
| 376 |
my $importer = eval <<' EOT' or die $@; |
| 377 |
package main; |
| 378 |
#line 0 "-" |
| 379 |
sub { $_[0]->import(@{$_[1]}) } |
| 380 |
EOT |
| 381 |
|
| 382 |
for my $set ($job->load_import) { |
| 383 |
my ($mod, $args) = @$set; |
| 384 |
my $file = mod2file($mod); |
| 385 |
local $0 = '-'; |
| 386 |
require $file; |
| 387 |
$importer->($mod, $args); |
| 388 |
} |
| 389 |
|
| 390 |
for my $mod ($job->load) { |
| 391 |
my $file = mod2file($mod); |
| 392 |
local $0 = '-'; |
| 393 |
require $file; |
| 394 |
} |
| 395 |
|
| 396 |
return; |
| 397 |
} |
| 398 |
|
| 399 |
sub build_init_state { |
| 400 |
my $class = shift; |
| 401 |
my ($job) = @_; |
| 402 |
|
| 403 |
$0 = $job->rel_file; |
| 404 |
$class->_reset_DATA(); |
| 405 |
@ARGV = (); |
| 406 |
|
| 407 |
srand(); # avoid child processes sharing the same seed value as the parent |
| 408 |
|
| 409 |
@INC = process_includes( |
| 410 |
list => [$job->includes], |
| 411 |
include_dot => $job->unsafe_inc, |
| 412 |
include_current => 1, |
| 413 |
clean => 1, |
| 414 |
); |
| 415 |
|
| 416 |
# if FindBin is preloaded, reset it with the new $0 |
| 417 |
FindBin::init() if defined &FindBin::init; |
| 418 |
|
| 419 |
# restore defaults |
| 420 |
Getopt::Long::ConfigDefaults() if defined &Getopt::Long::ConfigDefaults; |
| 421 |
|
| 422 |
return; |
| 423 |
} |
| 424 |
|
| 425 |
sub set_env { |
| 426 |
my $class = shift; |
| 427 |
my ($job) = @_; |
| 428 |
|
| 429 |
my $env = $job->env_vars; |
| 430 |
{ |
| 431 |
no warnings 'uninitialized'; |
| 432 |
$ENV{$_} = $env->{$_} for keys %$env; |
| 433 |
} |
| 434 |
|
| 435 |
$ENV{T2_HARNESS_FORKED} = 1; |
| 436 |
$ENV{T2_HARNESS_PRELOAD} = 1; |
| 437 |
|
| 438 |
return; |
| 439 |
} |
| 440 |
|
| 441 |
sub update_io { |
| 442 |
my $class = shift; |
| 443 |
my ($job) = @_; |
| 444 |
|
| 445 |
my $out_fh = open_file($job->out_file, '>'); |
| 446 |
my $err_fh = open_file($job->err_file, '>'); |
| 447 |
|
| 448 |
my $in_file = $job->in_file; |
| 449 |
my $in_fh; |
| 450 |
$in_fh = open_file($in_file, '<') if $in_file; |
| 451 |
|
| 452 |
$out_fh->autoflush(1); |
| 453 |
$err_fh->autoflush(1); |
| 454 |
|
| 455 |
# Keep a copy of the old STDERR for a while so we can still report errors |
| 456 |
my $stderr = clone_io(\*STDERR); |
| 457 |
|
| 458 |
my $die = sub { |
| 459 |
my @caller = caller; |
| 460 |
my @caller2 = caller(1); |
| 461 |
my $msg = "$_[0] at $caller[1] line $caller[2] ($caller2[1] line $caller2[2]).\n"; |
| 462 |
print $stderr $msg; |
| 463 |
print STDERR $msg; |
| 464 |
POSIX::_exit(127); |
| 465 |
}; |
| 466 |
|
| 467 |
swap_io(\*STDIN, $in_fh, $die, '<&') if $in_file; |
| 468 |
swap_io(\*STDOUT, $out_fh, $die, '>&'); |
| 469 |
swap_io(\*STDERR, $err_fh, $die, '>&'); |
| 470 |
|
| 471 |
$FIX_STDIN = 1 if $in_file; |
| 472 |
|
| 473 |
return; |
| 474 |
} |
| 475 |
|
| 476 |
# Heavily modified from forkprove |
| 477 |
sub _reset_DATA { |
| 478 |
my $class = shift; |
| 479 |
|
| 480 |
for my $set (@{$class->preload_list}) { |
| 481 |
my ($mod, $file, $pos) = @$set; |
| 482 |
|
| 483 |
my $fh = do { |
| 484 |
no strict 'refs'; |
| 485 |
*{$mod . '::DATA'}; |
| 486 |
}; |
| 487 |
|
| 488 |
# note that we need to ensure that each forked copy is using a |
| 489 |
# different file handle, or else concurrent processes will interfere |
| 490 |
# with each other |
| 491 |
|
| 492 |
close $fh if openhandle($fh); |
| 493 |
|
| 494 |
if (open $fh, '<', $file) { |
| 495 |
seek($fh, $pos, 0); |
| 496 |
} |
| 497 |
else { |
| 498 |
warn "Couldn't reopen DATA for $mod ($file): $!"; |
| 499 |
} |
| 500 |
} |
| 501 |
} |
| 502 |
|
| 503 |
# Heavily modified from forkprove |
| 504 |
sub preload_list { |
| 505 |
my $class = shift; |
| 506 |
|
| 507 |
my $list = []; |
| 508 |
|
| 509 |
for my $loaded (keys %INC) { |
| 510 |
next unless $loaded =~ /\.pm$/; |
| 511 |
|
| 512 |
my $mod = $loaded; |
| 513 |
$mod =~ s{/}{::}g; |
| 514 |
$mod =~ s{\.pm$}{}; |
| 515 |
|
| 516 |
my $fh = do { |
| 517 |
no strict 'refs'; |
| 518 |
no warnings 'once'; |
| 519 |
*{$mod . '::DATA'}; |
| 520 |
}; |
| 521 |
|
| 522 |
next unless openhandle($fh); |
| 523 |
push @$list => [$mod, $INC{$loaded}, tell($fh)]; |
| 524 |
} |
| 525 |
|
| 526 |
return $list; |
| 527 |
} |
| 528 |
|
| 529 |
|
| 530 |
1; |
| 531 |
|
| 532 |
__END__ |
| 533 |
|
| 534 |
=pod |
| 535 |
|
| 536 |
=encoding UTF-8 |
| 537 |
|
| 538 |
=head1 NAME |
| 539 |
|
| 540 |
App::Yath::Command::runner - For internal use only |
| 541 |
|
| 542 |
=head1 DESCRIPTION |
| 543 |
|
| 544 |
No Description |
| 545 |
|
| 546 |
=head1 USAGE |
| 547 |
|
| 548 |
$ yath [YATH OPTIONS] runner [COMMAND OPTIONS] |
| 549 |
|
| 550 |
=head2 YATH OPTIONS |
| 551 |
|
| 552 |
=head3 Developer |
| 553 |
|
| 554 |
=over 4 |
| 555 |
|
| 556 |
=item --dev-lib |
| 557 |
|
| 558 |
=item --dev-lib=lib |
| 559 |
|
| 560 |
=item -D |
| 561 |
|
| 562 |
=item -D=lib |
| 563 |
|
| 564 |
=item -Dlib |
| 565 |
|
| 566 |
=item --no-dev-lib |
| 567 |
|
| 568 |
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. |
| 569 |
|
| 570 |
Can be specified multiple times |
| 571 |
|
| 572 |
|
| 573 |
=back |
| 574 |
|
| 575 |
=head3 Environment |
| 576 |
|
| 577 |
=over 4 |
| 578 |
|
| 579 |
=item --persist-dir ARG |
| 580 |
|
| 581 |
=item --persist-dir=ARG |
| 582 |
|
| 583 |
=item --no-persist-dir |
| 584 |
|
| 585 |
Where to find persistence files. |
| 586 |
|
| 587 |
|
| 588 |
=item --persist-file ARG |
| 589 |
|
| 590 |
=item --persist-file=ARG |
| 591 |
|
| 592 |
=item --pfile ARG |
| 593 |
|
| 594 |
=item --pfile=ARG |
| 595 |
|
| 596 |
=item --no-persist-file |
| 597 |
|
| 598 |
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. |
| 599 |
|
| 600 |
|
| 601 |
=item --project ARG |
| 602 |
|
| 603 |
=item --project=ARG |
| 604 |
|
| 605 |
=item --project-name ARG |
| 606 |
|
| 607 |
=item --project-name=ARG |
| 608 |
|
| 609 |
=item --no-project |
| 610 |
|
| 611 |
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. |
| 612 |
|
| 613 |
|
| 614 |
=back |
| 615 |
|
| 616 |
=head3 Help and Debugging |
| 617 |
|
| 618 |
=over 4 |
| 619 |
|
| 620 |
=item --show-opts |
| 621 |
|
| 622 |
=item --no-show-opts |
| 623 |
|
| 624 |
Exit after showing what yath thinks your options mean |
| 625 |
|
| 626 |
|
| 627 |
=item --version |
| 628 |
|
| 629 |
=item -V |
| 630 |
|
| 631 |
=item --no-version |
| 632 |
|
| 633 |
Exit after showing a helpful usage message |
| 634 |
|
| 635 |
|
| 636 |
=back |
| 637 |
|
| 638 |
=head3 Plugins |
| 639 |
|
| 640 |
=over 4 |
| 641 |
|
| 642 |
=item --no-scan-plugins |
| 643 |
|
| 644 |
=item --no-no-scan-plugins |
| 645 |
|
| 646 |
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. |
| 647 |
|
| 648 |
|
| 649 |
=item --plugins PLUGIN |
| 650 |
|
| 651 |
=item --plugins +App::Yath::Plugin::PLUGIN |
| 652 |
|
| 653 |
=item --plugins PLUGIN=arg1,arg2,... |
| 654 |
|
| 655 |
=item --plugin PLUGIN |
| 656 |
|
| 657 |
=item --plugin +App::Yath::Plugin::PLUGIN |
| 658 |
|
| 659 |
=item --plugin PLUGIN=arg1,arg2,... |
| 660 |
|
| 661 |
=item -pPLUGIN |
| 662 |
|
| 663 |
=item --no-plugins |
| 664 |
|
| 665 |
Load a yath plugin. |
| 666 |
|
| 667 |
Can be specified multiple times |
| 668 |
|
| 669 |
|
| 670 |
=back |
| 671 |
|
| 672 |
=head2 COMMAND OPTIONS |
| 673 |
|
| 674 |
=head3 Cover Options |
| 675 |
|
| 676 |
=over 4 |
| 677 |
|
| 678 |
=item --cover-aggregator ByTest |
| 679 |
|
| 680 |
=item --cover-aggregator ByRun |
| 681 |
|
| 682 |
=item --cover-aggregator +Custom::Aggregator |
| 683 |
|
| 684 |
=item --cover-agg ByTest |
| 685 |
|
| 686 |
=item --cover-agg ByRun |
| 687 |
|
| 688 |
=item --cover-agg +Custom::Aggregator |
| 689 |
|
| 690 |
=item --no-cover-aggregator |
| 691 |
|
| 692 |
Choose a custom aggregator subclass |
| 693 |
|
| 694 |
|
| 695 |
=item --cover-class ARG |
| 696 |
|
| 697 |
=item --cover-class=ARG |
| 698 |
|
| 699 |
=item --no-cover-class |
| 700 |
|
| 701 |
Choose a Test2::Plugin::Cover subclass |
| 702 |
|
| 703 |
|
| 704 |
=item --cover-dirs ARG |
| 705 |
|
| 706 |
=item --cover-dirs=ARG |
| 707 |
|
| 708 |
=item --cover-dir ARG |
| 709 |
|
| 710 |
=item --cover-dir=ARG |
| 711 |
|
| 712 |
=item --no-cover-dirs |
| 713 |
|
| 714 |
NO DESCRIPTION - FIX ME |
| 715 |
|
| 716 |
Can be specified multiple times |
| 717 |
|
| 718 |
|
| 719 |
=item --cover-exclude-dirs ARG |
| 720 |
|
| 721 |
=item --cover-exclude-dirs=ARG |
| 722 |
|
| 723 |
=item --cover-exclude-dir ARG |
| 724 |
|
| 725 |
=item --cover-exclude-dir=ARG |
| 726 |
|
| 727 |
=item --no-cover-exclude-dirs |
| 728 |
|
| 729 |
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. |
| 730 |
|
| 731 |
Can be specified multiple times |
| 732 |
|
| 733 |
|
| 734 |
=item --cover-exclude-private |
| 735 |
|
| 736 |
=item --no-cover-exclude-private |
| 737 |
|
| 738 |
|
| 739 |
|
| 740 |
|
| 741 |
=item --cover-files |
| 742 |
|
| 743 |
=item --no-cover-files |
| 744 |
|
| 745 |
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) |
| 746 |
|
| 747 |
|
| 748 |
=item --cover-from path/to/log.jsonl |
| 749 |
|
| 750 |
=item --cover-from http://example.com/coverage |
| 751 |
|
| 752 |
=item --cover-from path/to/coverage.jsonl |
| 753 |
|
| 754 |
=item --no-cover-from |
| 755 |
|
| 756 |
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. |
| 757 |
|
| 758 |
|
| 759 |
=item --cover-from-type json |
| 760 |
|
| 761 |
=item --cover-from-type jsonl |
| 762 |
|
| 763 |
=item --cover-from-type log |
| 764 |
|
| 765 |
=item --no-cover-from-type |
| 766 |
|
| 767 |
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. |
| 768 |
|
| 769 |
|
| 770 |
=item --cover-manager My::Coverage::Manager |
| 771 |
|
| 772 |
=item --no-cover-manager |
| 773 |
|
| 774 |
Coverage 'from' manager to use when coverage data does not provide one |
| 775 |
|
| 776 |
|
| 777 |
=item --cover-maybe-from path/to/log.jsonl |
| 778 |
|
| 779 |
=item --cover-maybe-from http://example.com/coverage |
| 780 |
|
| 781 |
=item --cover-maybe-from path/to/coverage.jsonl |
| 782 |
|
| 783 |
=item --no-cover-maybe-from |
| 784 |
|
| 785 |
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. |
| 786 |
|
| 787 |
|
| 788 |
=item --cover-maybe-from-type json |
| 789 |
|
| 790 |
=item --cover-maybe-from-type jsonl |
| 791 |
|
| 792 |
=item --cover-maybe-from-type log |
| 793 |
|
| 794 |
=item --no-cover-maybe-from-type |
| 795 |
|
| 796 |
Same as "from_type" but for "maybe_from". Defaults to "from_type" if that is specified, otherwise auto-detect |
| 797 |
|
| 798 |
|
| 799 |
=item --cover-metrics |
| 800 |
|
| 801 |
=item --no-cover-metrics |
| 802 |
|
| 803 |
|
| 804 |
|
| 805 |
|
| 806 |
=item --cover-types ARG |
| 807 |
|
| 808 |
=item --cover-types=ARG |
| 809 |
|
| 810 |
=item --cover-type ARG |
| 811 |
|
| 812 |
=item --cover-type=ARG |
| 813 |
|
| 814 |
=item --no-cover-types |
| 815 |
|
| 816 |
NO DESCRIPTION - FIX ME |
| 817 |
|
| 818 |
Can be specified multiple times |
| 819 |
|
| 820 |
|
| 821 |
=item --cover-write |
| 822 |
|
| 823 |
=item --cover-write=coverage.jsonl |
| 824 |
|
| 825 |
=item --cover-write=coverage.json |
| 826 |
|
| 827 |
=item --no-cover-write |
| 828 |
|
| 829 |
Create a json or jsonl file of all coverage data seen during the run (This implies --cover-files). |
| 830 |
|
| 831 |
|
| 832 |
=back |
| 833 |
|
| 834 |
=head3 Git Options |
| 835 |
|
| 836 |
=over 4 |
| 837 |
|
| 838 |
=item --git-change-base master |
| 839 |
|
| 840 |
=item --git-change-base HEAD^ |
| 841 |
|
| 842 |
=item --git-change-base df22abe4 |
| 843 |
|
| 844 |
=item --no-git-change-base |
| 845 |
|
| 846 |
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. |
| 847 |
|
| 848 |
|
| 849 |
=back |
| 850 |
|
| 851 |
=head3 Help and Debugging |
| 852 |
|
| 853 |
=over 4 |
| 854 |
|
| 855 |
=item --dummy |
| 856 |
|
| 857 |
=item -d |
| 858 |
|
| 859 |
=item --no-dummy |
| 860 |
|
| 861 |
Dummy run, do not actually execute anything |
| 862 |
|
| 863 |
Can also be set with the following environment variables: C<T2_HARNESS_DUMMY> |
| 864 |
|
| 865 |
|
| 866 |
=item --help |
| 867 |
|
| 868 |
=item -h |
| 869 |
|
| 870 |
=item --no-help |
| 871 |
|
| 872 |
exit after showing help information |
| 873 |
|
| 874 |
|
| 875 |
=item --interactive |
| 876 |
|
| 877 |
=item -i |
| 878 |
|
| 879 |
=item --no-interactive |
| 880 |
|
| 881 |
Use interactive mode, 1 test at a time, stdin forwarded to it |
| 882 |
|
| 883 |
|
| 884 |
=item --keep-dirs |
| 885 |
|
| 886 |
=item --keep_dir |
| 887 |
|
| 888 |
=item -k |
| 889 |
|
| 890 |
=item --no-keep-dirs |
| 891 |
|
| 892 |
Do not delete directories when done. This is useful if you want to inspect the directories used for various commands. |
| 893 |
|
| 894 |
|
| 895 |
=item --procname-prefix ARG |
| 896 |
|
| 897 |
=item --procname-prefix=ARG |
| 898 |
|
| 899 |
=item --no-procname-prefix |
| 900 |
|
| 901 |
Add a prefix to all proc names (as seen by ps). |
| 902 |
|
| 903 |
|
| 904 |
=back |
| 905 |
|
| 906 |
=head3 YathUI Options |
| 907 |
|
| 908 |
=over 4 |
| 909 |
|
| 910 |
=item --yathui-api-key ARG |
| 911 |
|
| 912 |
=item --yathui-api-key=ARG |
| 913 |
|
| 914 |
=item --no-yathui-api-key |
| 915 |
|
| 916 |
Yath-UI API key. This is not necessary if your Yath-UI instance is set to single-user |
| 917 |
|
| 918 |
|
| 919 |
=item --yathui-grace |
| 920 |
|
| 921 |
=item --no-yathui-grace |
| 922 |
|
| 923 |
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. |
| 924 |
|
| 925 |
|
| 926 |
=item --yathui-long-duration 10 |
| 927 |
|
| 928 |
=item --no-yathui-long-duration |
| 929 |
|
| 930 |
Minimum duration length (seconds) before a test goes from MEDIUM to LONG |
| 931 |
|
| 932 |
|
| 933 |
=item --yathui-medium-duration 5 |
| 934 |
|
| 935 |
=item --no-yathui-medium-duration |
| 936 |
|
| 937 |
Minimum duration length (seconds) before a test goes from SHORT to MEDIUM |
| 938 |
|
| 939 |
|
| 940 |
=item --yathui-mode summary |
| 941 |
|
| 942 |
=item --yathui-mode qvf |
| 943 |
|
| 944 |
=item --yathui-mode qvfd |
| 945 |
|
| 946 |
=item --yathui-mode complete |
| 947 |
|
| 948 |
=item --no-yathui-mode |
| 949 |
|
| 950 |
Set the upload mode (default 'qvfd') |
| 951 |
|
| 952 |
|
| 953 |
=item --yathui-project ARG |
| 954 |
|
| 955 |
=item --yathui-project=ARG |
| 956 |
|
| 957 |
=item --no-yathui-project |
| 958 |
|
| 959 |
The Yath-UI project for your test results |
| 960 |
|
| 961 |
|
| 962 |
=item --yathui-retry |
| 963 |
|
| 964 |
=item --no-yathui-retry |
| 965 |
|
| 966 |
How many times to try an operation before giving up |
| 967 |
|
| 968 |
Can be specified multiple times |
| 969 |
|
| 970 |
|
| 971 |
=item --yathui-url http://my-yath-ui.com/... |
| 972 |
|
| 973 |
=item --uri http://my-yath-ui.com/... |
| 974 |
|
| 975 |
=item --no-yathui-url |
| 976 |
|
| 977 |
Yath-UI url |
| 978 |
|
| 979 |
|
| 980 |
=back |
| 981 |
|
| 982 |
=head1 SOURCE |
| 983 |
|
| 984 |
The source code repository for Test2-Harness can be found at |
| 985 |
F<http://github.com/Test-More/Test2-Harness/>. |
| 986 |
|
| 987 |
=head1 MAINTAINERS |
| 988 |
|
| 989 |
=over 4 |
| 990 |
|
| 991 |
=item Chad Granum E<lt>[email protected]<gt> |
| 992 |
|
| 993 |
=back |
| 994 |
|
| 995 |
=head1 AUTHORS |
| 996 |
|
| 997 |
=over 4 |
| 998 |
|
| 999 |
=item Chad Granum E<lt>[email protected]<gt> |
| 1000 |
|
| 1001 |
=back |
| 1002 |
|
| 1003 |
=head1 COPYRIGHT |
| 1004 |
|
| 1005 |
Copyright 2026 Chad Granum E<lt>[email protected]<gt>. |
| 1006 |
|
| 1007 |
This program is free software; you can redistribute it and/or |
| 1008 |
modify it under the same terms as Perl itself. |
| 1009 |
|
| 1010 |
See F<http://dev.perl.org/licenses/> |
| 1011 |
|
| 1012 |
=cut |
| 1013 |
|