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);

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 before run
  • argv β€” where any filenames process_args found are chillin'
  • backwards β€” the attribute for that switch, ready for a makeover
  • blib β€” same deal, mirrors its switch
  • color β€” yes, the color vibes, mirrored
  • directives β€” mirrored, editable, slay
  • dry β€” the dry-run-ish switch's attribute
  • exec β€” mirrored from its switch
  • extensions β€” mirrored, yours to change
  • failures β€” mirrored, yours to change
  • comments β€” mirrored, yours to change
  • formatter β€” mirrored, and yes you can change it before run
  • harness β€” mirrored, editable
  • ignore_exit β€” mirrored, editable
  • includes β€” mirrored, editable
  • jobs β€” mirrored, editable
  • lib β€” mirrored, editable
  • merge β€” mirrored, editable
  • modules β€” mirrored, editable
  • parse β€” mirrored, editable
  • plugins β€” mirrored, editable
  • quiet β€” mirrored, editable
  • really_quiet β€” mirrored, editable (yes, really)
  • recurse β€” mirrored, editable
  • rules β€” mirrored, editable
  • show_count β€” mirrored, editable
  • show_help β€” mirrored, editable
  • show_man β€” mirrored, editable
  • show_version β€” mirrored, editable
  • shuffle β€” mirrored, editable
  • state β€” mirrored, editable
  • state_class β€” mirrored, editable
  • taint_fail β€” mirrored, editable
  • taint_warn β€” mirrored, editable
  • test_args β€” mirrored, editable
  • timer β€” mirrored, editable
  • verbose β€” mirrored, editable
  • warnings_fail β€” mirrored, editable
  • warnings_warn β€” mirrored, editable
  • tapversion β€” mirrored, editable
  • trap β€” 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