Here's my auto-prove script. The idea of it is that if you're working in "my-code/lib/Foo/Bar/", you don't want to chdir all the way back to "my-code/" before you run your test suite.

So auto-prove climbs back down your directory tree looking for a test suite, then runs "prove" on it.

#!/usr/bin/perl use 5.008; use strict; use Getopt::Long; my @booleans = qw{ recurse|r timer verbose|v color|c dry|D failures|f comments|o fork ignore-exit merge|m shuffle|s reverse normalize T t W w }; my %opts; GetOptions(\%opts, @booleans, 'jobs|j=i', 'xt', 'help|usage|h') or die("See '--help'.\n"); die "Unlike prove, $0 does not accept a list of test cases.\nSee '--he +lp'.\n" if @ARGV; if ($opts{help}) { # Please look away if you are easily offended. my $nice_booleans = join "\n", sort { lc$a cmp lc$b } q{ --jobs=N}, map { q{ }. join q{, }, map { length == 1 ? "-$_" : "--$_" } split m{\|}, $_; } @booleans; print eval 'qq{'.(do { local $/ = <DATA> }).'}' and exit; } require App::Prove; require Cwd; Cwd->import('cwd'); while (-d '..' and not -d 't') { chdir '..'; } unless (-d 't') { die "No suitable test suite found.\n"; } my $cwd = cwd(); print "Found suitable test suite within directory '$cwd'.\n"; my @args; foreach my $opt (@booleans) { my ($full, $short) = split m{\|}, $opt; if ($opts{$full}) { push @args, sprintf( (length($full) == 1 ? '-%s' : '--%s'), $full, ); } } push @args, sprintf('--jobs=%d', $opts{jobs}||1); foreach my $dir (qw{blib/lib inc lib}) { next unless -d $dir; push @args, sprintf('-I%s', $dir) } if ($opts{xt}) { push @args, 't', 'xt'; } else { push @args, 't'; } print join(q{ }, prove => @args), "\n" if $opts{verbose}; my $app = App::Prove->new; $app->process_args(@args); $app->run; __DATA__ Usage: $0 [OPTIONS] Searches this directory, the parent, and further up the directory tree for a subdirectory called "t". Once found, runs "prove t" there. Automatically adds "blib/lib", "inc" and "lib" to \@INC if those directories exist. Passes any of the following options through to prove: $nice_booleans Additionally supports options: --help Show this help --xt Also run "xt" tests.

In reply to Run tests with "auto-prove" by tobyink

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.