Quite frequently while running tests, I find that it might be useful to skip a test or two while running through the full tests suite (maybe they take too long, for example). The following snippet allows more precise control over which tests I want to run at a given time.

You do write tests, don't you? :) (and thanks to Koschei for catching the typo in the POD)

#!/usr/bin/perl -w use strict; use Test::Harness; use Getopt::Long; use Pod::Usage; my (@exclude,@include); GetOptions( 'help|?' => sub { pod2usage(-verbose => 2); exit }, 'verbose!' => \$Test::Harness::verbose, 'quiet' => sub { $Test::Harness::verbose = 0 }, 'include=s' => \@include, 'exclude=s' => \@exclude ); @include = map { glob } @include; @exclude = map { glob } @exclude; BEGIN { chdir 't' if -d 't'; } my @files = @include; unless (@files) { @files = glob "*.t"; } my @tests; foreach my $file ( sort @files ) { push @tests => $file unless grep { /\Q$file\E/ } @exclude; } runtests( @tests ); __END__ =head1 NAME testall -- A test harness utility =head1 SYNOPSIS B<testall --help> for more information testall [options] Options: --help Display POD --? Same as --help --verbose Display standard output of test scripts while runni +ng them. --noverbose Turn off --verbose (default Test::Harness behavior) --quiet Same as --noverbose --include Tests to include --exclude Tests to exclude =head1 OVERVIEW This program uses C<Test::Harness> to run the results of a test suite. + With no arguments, it will run all tests in the current directory (assumes tes +t have a C<.t> extension). Shell metacharacters may be used with command lines options and will b +e exanded via C<glob>. =head1 COMMAND LINE OPTIONS Note that all options may be specified with a single dash and the firs +t letter of the option. =head2 --include Use this to specify which files will be run as tests. If used, only f +iles specified with C<--include> will be run. testall -i 02saleitem.t -i 02saletax.t -i 02saletender.t The above may be written as (note the quotes): testall -i '02sale*.t' =head2 --exclude Use this switch to specify which files will not be run as tests. If u +sed, the program assumes all files ending in C<.t> are tests and will skip thos +e that match C<--exclude>. To run all tests but exclude the tests used in th +e previous example: testall -e 02saleitem.t -e 02saletax.t -e 02saletender.t The above may be written as: testall -e '02sale*' The C<--exclude> and C<--include> options may be combined. To run all + tests containing the word 'product' in the filename, but skip 'productfinal. +t': testall -i '*product*.t' -e productfinal.t

In reply to Easy test management by Ovid

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.