Test::Count::Filter::ByFileType::App - a standalone command line application


Test-Count documentation Contained in the Test-Count distribution.

Index


Code Index:

NAME

Top

Test::Count::Filter::ByFileType::App - a standalone command line application that filters according to the filetype.

SYNOPSIS

Top

    # To filter C code
    $ perl -MTest::Count::Filter::ByFileType::App -e 'run()' --ft=c

    # To filter Perl 5 code
    $ perl -MTest::Count::Filter::ByFileType::App -e 'run()'

FUNCTIONS

Top

run()

Runs the program.

AUTHOR

Top

Shlomi Fish, http://www.shlomifish.org/ .

BUGS

Top

Please report any bugs or feature requests to bug-test-count at rt.cpan.org, or through the web interface at http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Test::Count. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.

SUPPORT

Top

You can find documentation for this module with the perldoc command.

    perldoc Test::Count

You can also look for information at:

* AnnoCPAN: Annotated CPAN documentation

http://annocpan.org/dist/Test::Count

* CPAN Ratings

http://cpanratings.perl.org/d/Test::Count

* RT: CPAN's request tracker

http://rt.cpan.org/NoAuth/Bugs.html?Dist=Test::Count

* Search CPAN

http://search.cpan.org/dist/Test::Count

SEE ALSO

Top

Test::Count, Test::Count::Parser

ACKNOWLEDGEMENTS

Top

COPYRIGHT & LICENSE

Top


Test-Count documentation Contained in the Test-Count distribution.
package Test::Count::Filter::ByFileType::App;

use strict;
use warnings;

use Test::Count::Filter;
use Getopt::Long;

use base 'Exporter';

our @EXPORT = (qw(run));

sub run
{
    my $filetype = "perl";
    GetOptions('ft=s' => \$filetype);

    my %params =
    (
        'lisp' => 
        {
            assert_prefix_regex => qr{; TEST},
            plan_prefix_regex => qr{\(plan\s+},
        },
        'c' =>
        {
            assert_prefix_regex => qr{/[/\*]\s+TEST},
            plan_prefix_regex => qr{\s*plan_tests\s*\(\s*},
        },
        'python' =>
        {
            plan_prefix_regex => qr{plan\s*\(\s*},
        },
    );

    my %aliases =
    (
        'arc' => "lisp",
        'scheme' => "lisp",
        'cpp' => "c",
    );

    $filetype = exists($aliases{$filetype}) ? $aliases{$filetype} : $filetype;
    my $ft_params = exists($params{$filetype}) ? $params{$filetype} : +{};

    my $filter = 
        Test::Count::Filter->new(
            {
                %{$ft_params},
            }
        );

    $filter->process();

    return 0;
}

1;

__END__