App::Prove(3pm)
π
App::Prove β the prove command, but make it a Perl module π
okay so bestie, this is App::Prove, from the Perl Programmers Reference Guide, and it literally is the prove command, just packaged up as a module so you can boss it around from inside your own code. iykyk β¨
πΈ VERSION πΈ
Version 3.50 β yes, she's been through some things and she's thriving.
π¦ DESCRIPTION π¦
Test::Harness ships a command called prove that runs a TAP based test suite and prints you a report. cute, right? and here's the tea: the prove command is literally just a minimal wrapper around an instance of this module. that's it. that's the whole vibe. no cap π
π SYNOPSIS π
use App::Prove;
my $app = App::Prove->new;
$app->process_args(@ARGV);
$app->run;
that's the entire glow-up in three lines. go off π
β¨ METHODS β¨
π Class Methods π
new
Creates a brand new App::Prove. if you want, you can hand it a hash ref of attribute initializers and she'll take those as her starting outfit π«Ά
state_class
Getter/setter for the name of the class used for maintaining state. heads up: this class has to either subclass from App::Prove::State or provide an identical interface β no shortcuts, bestie π
state_manager
Getter/setter for the instance of that state_class. same energy, but for the actual object this time.
add_rc_file
$prove->add_rc_file('myproj/.proverc');
You call this before process_args, and it prepends the contents of an rc file to the options. pre-gaming, basically. π
process_args
$prove->process_args(@args);
Does exactly what it says on the label β processes the command-line arguments and sets the attributes appropriately. any filenames it finds end up in the argv attribute.
Dies on invalid arguments. π like, it will end. keep your args valid, fr fr.
run
Performs whatever actions the command line args specified. The prove command line tool is literally made of this code right here:
use App::Prove;
my $app = App::Prove->new;
$app->process_args(@ARGV);
exit( $app->run ? 0 : 1 ); # if you need the exit code
that comment is doing so much heavy lifting and honestly? iconic.
require_harness
Loads a harness replacement class. main character energy:
$prove->require_harness($for => $class_name);
print_version
Displays the version numbers of the loaded TAP::Harness and the current Perl. little receipt, but make it cute π
π Attributes π
So after the command line gets parsed, all these attributes are reflecting the values of the corresponding command line switches. and here's the best part β you can alter them before calling run. build your own adventure, bestie β¨
archiveβ mirrors its switch, yours to tweak beforerunargvβ where any filenamesprocess_argsfound are chillin'backwardsβ the attribute for that switch, ready for a makeoverblibβ same deal, mirrors its switchcolorβ yes, the color vibes, mirroreddirectivesβ mirrored, editable, slaydryβ the dry-run-ish switch's attributeexecβ mirrored from its switchextensionsβ mirrored, yours to changefailuresβ mirrored, yours to changecommentsβ mirrored, yours to changeformatterβ mirrored, and yes you can change it beforerunharnessβ mirrored, editableignore_exitβ mirrored, editableincludesβ mirrored, editablejobsβ mirrored, editablelibβ mirrored, editablemergeβ mirrored, editablemodulesβ mirrored, editableparseβ mirrored, editablepluginsβ mirrored, editablequietβ mirrored, editablereally_quietβ mirrored, editable (yes, really)recurseβ mirrored, editablerulesβ mirrored, editableshow_countβ mirrored, editableshow_helpβ mirrored, editableshow_manβ mirrored, editableshow_versionβ mirrored, editableshuffleβ mirrored, editablestateβ mirrored, editablestate_classβ mirrored, editabletaint_failβ mirrored, editabletaint_warnβ mirrored, editabletest_argsβ mirrored, editabletimerβ mirrored, editableverboseβ mirrored, editablewarnings_failβ mirrored, editablewarnings_warnβ mirrored, editabletapversionβ mirrored, editabletrapβ mirrored, editable
all of them, every single one, set post-parse from their switch and fair game to change before run. the way that's so convenient π§
π PLUGINS π
App::Prove supports 3rd-party plugins, and this is the part where she gets β¨extensibleβ¨.
important detail: these are currently loaded at run-time, after arguments have been parsed. which means you can not change the way arguments are processed. sorry! π
You typically load one with the -Pplugin switch, eg:
prove -PMyPlugin
She'll search for a module named App::Prove::Plugin::MyPlugin, or failing that, MyPlugin. If the plugin can't be found, prove will complain & exit. no plugin, no service π
You can pass an argument to your plugin by appending an = after the plugin name, eg -PMyPlugin=foo. And you can pass multiple arguments using commas:
prove -PMyPlugin=foo,bar,baz
These get passed in to your plugin's load() class method (if it has one), along with a reference to the App::Prove object that is invoking your plugin:
sub load {
my ($class, $p) = @_;
my @args = @{ $p->{args} };
# @args will contain ( 'foo', 'bar', 'baz' )
$p->{app_prove}->do_something;
...
}
see how $p->{args} and $p->{app_prove} are just there for you? obsessed π«Ά
πΈ Sample Plugin πΈ
Here's a sample plugin, for your reference β copy it, remix it, make it yours:
package App::Prove::Plugin::Foo;
# Sample plugin, try running with:
# prove -PFoo=bar -r -j3
# prove -PFoo -Q
# prove -PFoo=bar,My::Formatter
use strict;
use warnings;
sub load {
my ($class, $p) = @_;
my @args = @{ $p->{args} };
my $app = $p->{app_prove};
print "loading plugin: $class, args: ", join(', ', @args ), "\n";
# turn on verbosity
$app->verbose( 1 );
# set the formatter?
$app->formatter( $args[1] ) if @args > 1;
# print some of App::Prove's state:
for my $attr (qw( jobs quiet really_quiet recurse verbose )) {
my $val = $app->$attr;
$val = 'undef' unless defined( $val );
print "$attr: $val\n";
}
return 1;
}
1;
those three commented prove lines at the top are the whole mood board, ngl π₯
β SEE ALSO β
prove, TAP::Harness β go read those next, bestie, they're the supporting cast π¦
and that's the page! π brought to you by perl v5.42.3, dated 2026-11-03, straight out of the Perl Programmers Reference Guide β mwah, go run some tests β¨π
π¦ where this page comes from
- alpine 3.24: perl-doc 5.42.3-r0 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms