Debian Codegraph @

lib/App/Yath/Command/reload.pm

raw
1 package App::Yath::Command::reload;
2 use strict;
3 use warnings;
4
5 our $VERSION = '1.000179';
6
7 use File::Spec();
8 use Test2::Harness::Util::File::JSON;
9
10 use App::Yath::Util qw/find_pfile/;
11 use Test2::Harness::Util qw/open_file/;
12
13 use parent 'App::Yath::Command';
14 use Test2::Harness::Util::HashBase;
15
16 sub group { 'persist' }
17
18 sub summary { "Reload the persistent test runner" }
19 sub cli_args { "" }
20
21 sub description {
22 return <<" EOT";
23 This will send a SIGHUP to the persistent runner, forcing it to reload. This
24 will also clear the blacklist allowing all preloads to load as normal.
25 EOT
26 }
27
28 sub run {
29 my $self = shift;
30
31 my $pfile = find_pfile($self->settings, no_fatal => 1)
32 or die "Could not find a persistent yath running.\n";
33
34 my $data = Test2::Harness::Util::File::JSON->new(name => $pfile)->read();
35
36 my $blacklist = File::Spec->catfile($data->{dir}, 'BLACKLIST');
37 if (-e $blacklist) {
38 print "Deleting module blacklist...\n";
39 unlink($blacklist) or warn "Could not delete blacklist file!";
40 }
41
42 print "\nSending SIGHUP to $data->{pid}\n\n";
43 kill('HUP', $data->{pid}) or die "Could not send signal!\n";
44 return 0;
45 }
46
47 1;
48
49 __END__
50
51 =pod
52
53 =encoding UTF-8
54
55 =head1 NAME
56
57 App::Yath::Command::reload - Reload the persistent test runner
58
59 =head1 DESCRIPTION
60
61 This will send a SIGHUP to the persistent runner, forcing it to reload. This
62 will also clear the blacklist allowing all preloads to load as normal.
63
64
65 =head1 USAGE
66
67 $ yath [YATH OPTIONS] reload [COMMAND OPTIONS]
68
69 =head2 YATH OPTIONS
70
71 =head3 Developer
72
73 =over 4
74
75 =item --dev-lib
76
77 =item --dev-lib=lib
78
79 =item -D
80
81 =item -D=lib
82
83 =item -Dlib
84
85 =item --no-dev-lib
86
87 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.
88
89 Can be specified multiple times
90
91
92 =back
93
94 =head3 Environment
95
96 =over 4
97
98 =item --persist-dir ARG
99
100 =item --persist-dir=ARG
101
102 =item --no-persist-dir
103
104 Where to find persistence files.
105
106
107 =item --persist-file ARG
108
109 =item --persist-file=ARG
110
111 =item --pfile ARG
112
113 =item --pfile=ARG
114
115 =item --no-persist-file
116
117 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.
118
119
120 =item --project ARG
121
122 =item --project=ARG
123
124 =item --project-name ARG
125
126 =item --project-name=ARG
127
128 =item --no-project
129
130 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.
131
132
133 =back
134
135 =head3 Help and Debugging
136
137 =over 4
138
139 =item --show-opts
140
141 =item --no-show-opts
142
143 Exit after showing what yath thinks your options mean
144
145
146 =item --version
147
148 =item -V
149
150 =item --no-version
151
152 Exit after showing a helpful usage message
153
154
155 =back
156
157 =head3 Plugins
158
159 =over 4
160
161 =item --no-scan-plugins
162
163 =item --no-no-scan-plugins
164
165 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.
166
167
168 =item --plugins PLUGIN
169
170 =item --plugins +App::Yath::Plugin::PLUGIN
171
172 =item --plugins PLUGIN=arg1,arg2,...
173
174 =item --plugin PLUGIN
175
176 =item --plugin +App::Yath::Plugin::PLUGIN
177
178 =item --plugin PLUGIN=arg1,arg2,...
179
180 =item -pPLUGIN
181
182 =item --no-plugins
183
184 Load a yath plugin.
185
186 Can be specified multiple times
187
188
189 =back
190
191 =head2 COMMAND OPTIONS
192
193 =head3 Cover Options
194
195 =over 4
196
197 =item --cover-aggregator ByTest
198
199 =item --cover-aggregator ByRun
200
201 =item --cover-aggregator +Custom::Aggregator
202
203 =item --cover-agg ByTest
204
205 =item --cover-agg ByRun
206
207 =item --cover-agg +Custom::Aggregator
208
209 =item --no-cover-aggregator
210
211 Choose a custom aggregator subclass
212
213
214 =item --cover-class ARG
215
216 =item --cover-class=ARG
217
218 =item --no-cover-class
219
220 Choose a Test2::Plugin::Cover subclass
221
222
223 =item --cover-dirs ARG
224
225 =item --cover-dirs=ARG
226
227 =item --cover-dir ARG
228
229 =item --cover-dir=ARG
230
231 =item --no-cover-dirs
232
233 NO DESCRIPTION - FIX ME
234
235 Can be specified multiple times
236
237
238 =item --cover-exclude-dirs ARG
239
240 =item --cover-exclude-dirs=ARG
241
242 =item --cover-exclude-dir ARG
243
244 =item --cover-exclude-dir=ARG
245
246 =item --no-cover-exclude-dirs
247
248 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.
249
250 Can be specified multiple times
251
252
253 =item --cover-exclude-private
254
255 =item --no-cover-exclude-private
256
257
258
259
260 =item --cover-files
261
262 =item --no-cover-files
263
264 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)
265
266
267 =item --cover-from path/to/log.jsonl
268
269 =item --cover-from http://example.com/coverage
270
271 =item --cover-from path/to/coverage.jsonl
272
273 =item --no-cover-from
274
275 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.
276
277
278 =item --cover-from-type json
279
280 =item --cover-from-type jsonl
281
282 =item --cover-from-type log
283
284 =item --no-cover-from-type
285
286 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.
287
288
289 =item --cover-manager My::Coverage::Manager
290
291 =item --no-cover-manager
292
293 Coverage 'from' manager to use when coverage data does not provide one
294
295
296 =item --cover-maybe-from path/to/log.jsonl
297
298 =item --cover-maybe-from http://example.com/coverage
299
300 =item --cover-maybe-from path/to/coverage.jsonl
301
302 =item --no-cover-maybe-from
303
304 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.
305
306
307 =item --cover-maybe-from-type json
308
309 =item --cover-maybe-from-type jsonl
310
311 =item --cover-maybe-from-type log
312
313 =item --no-cover-maybe-from-type
314
315 Same as "from_type" but for "maybe_from". Defaults to "from_type" if that is specified, otherwise auto-detect
316
317
318 =item --cover-metrics
319
320 =item --no-cover-metrics
321
322
323
324
325 =item --cover-types ARG
326
327 =item --cover-types=ARG
328
329 =item --cover-type ARG
330
331 =item --cover-type=ARG
332
333 =item --no-cover-types
334
335 NO DESCRIPTION - FIX ME
336
337 Can be specified multiple times
338
339
340 =item --cover-write
341
342 =item --cover-write=coverage.jsonl
343
344 =item --cover-write=coverage.json
345
346 =item --no-cover-write
347
348 Create a json or jsonl file of all coverage data seen during the run (This implies --cover-files).
349
350
351 =back
352
353 =head3 Git Options
354
355 =over 4
356
357 =item --git-change-base master
358
359 =item --git-change-base HEAD^
360
361 =item --git-change-base df22abe4
362
363 =item --no-git-change-base
364
365 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.
366
367
368 =back
369
370 =head3 Help and Debugging
371
372 =over 4
373
374 =item --dummy
375
376 =item -d
377
378 =item --no-dummy
379
380 Dummy run, do not actually execute anything
381
382 Can also be set with the following environment variables: C<T2_HARNESS_DUMMY>
383
384
385 =item --help
386
387 =item -h
388
389 =item --no-help
390
391 exit after showing help information
392
393
394 =item --interactive
395
396 =item -i
397
398 =item --no-interactive
399
400 Use interactive mode, 1 test at a time, stdin forwarded to it
401
402
403 =item --keep-dirs
404
405 =item --keep_dir
406
407 =item -k
408
409 =item --no-keep-dirs
410
411 Do not delete directories when done. This is useful if you want to inspect the directories used for various commands.
412
413
414 =item --procname-prefix ARG
415
416 =item --procname-prefix=ARG
417
418 =item --no-procname-prefix
419
420 Add a prefix to all proc names (as seen by ps).
421
422
423 =back
424
425 =head3 YathUI Options
426
427 =over 4
428
429 =item --yathui-api-key ARG
430
431 =item --yathui-api-key=ARG
432
433 =item --no-yathui-api-key
434
435 Yath-UI API key. This is not necessary if your Yath-UI instance is set to single-user
436
437
438 =item --yathui-grace
439
440 =item --no-yathui-grace
441
442 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.
443
444
445 =item --yathui-long-duration 10
446
447 =item --no-yathui-long-duration
448
449 Minimum duration length (seconds) before a test goes from MEDIUM to LONG
450
451
452 =item --yathui-medium-duration 5
453
454 =item --no-yathui-medium-duration
455
456 Minimum duration length (seconds) before a test goes from SHORT to MEDIUM
457
458
459 =item --yathui-mode summary
460
461 =item --yathui-mode qvf
462
463 =item --yathui-mode qvfd
464
465 =item --yathui-mode complete
466
467 =item --no-yathui-mode
468
469 Set the upload mode (default 'qvfd')
470
471
472 =item --yathui-project ARG
473
474 =item --yathui-project=ARG
475
476 =item --no-yathui-project
477
478 The Yath-UI project for your test results
479
480
481 =item --yathui-retry
482
483 =item --no-yathui-retry
484
485 How many times to try an operation before giving up
486
487 Can be specified multiple times
488
489
490 =item --yathui-url http://my-yath-ui.com/...
491
492 =item --uri http://my-yath-ui.com/...
493
494 =item --no-yathui-url
495
496 Yath-UI url
497
498
499 =back
500
501 =head1 SOURCE
502
503 The source code repository for Test2-Harness can be found at
504 F<http://github.com/Test-More/Test2-Harness/>.
505
506 =head1 MAINTAINERS
507
508 =over 4
509
510 =item Chad Granum E<lt>[email protected]<gt>
511
512 =back
513
514 =head1 AUTHORS
515
516 =over 4
517
518 =item Chad Granum E<lt>[email protected]<gt>
519
520 =back
521
522 =head1 COPYRIGHT
523
524 Copyright 2026 Chad Granum E<lt>[email protected]<gt>.
525
526 This program is free software; you can redistribute it and/or
527 modify it under the same terms as Perl itself.
528
529 See F<http://dev.perl.org/licenses/>
530
531 =cut
532