OPM-Validate

 view release on metacpan or  search on metacpan

bin/validate_opm  view on Meta::CPAN

our $VERSION = '1.13'; # VERSION

use Getopt::Long;
use OPM::Validate;

GetOptions(
    'sopm' => \my $is_sopm,
);

my $file    = _check_args() or do{ print_usage() and exit };
my $content = do { local (@ARGV, $/) = ($file); <> };

OPM::Validate->validate( $content, $is_sopm );

sub _check_args {
    return if !@ARGV;
    return if !-f $ARGV[0];

    return $ARGV[0];
}

t/001_base.t  view on Meta::CPAN

    good => [
        _get_files('good')
    ],
    bad  => [
        _get_files('bad')
    ]
);

for my $type ( sort keys %opms ) {
    for my $file ( @{ $opms{$type} || [] } ) {
        my $content = do { local ( @ARGV, $/ ) = $file; <> };
        my $success = eval {
            OPM::Validate->validate( $content );
            1;
        };

        is $@, '', 'no errors for ' . $file if $type eq 'good';
        ok( ($type eq 'good' ? $success : !$success), $file );
    }
}

t/002_sopm.t  view on Meta::CPAN

    ],
    bad  => [
        _get_files('bad')
    ]
);

for my $type ( sort keys %opms ) {
    for my $file ( @{ $opms{$type} || [] } ) {
        diag "Check $file";

        my $content = do { local ( @ARGV, $/ ) = $file; <> };
        my $is_sopm = ( ( split /\./, $file )[-1] eq 'sopm' ? 1 : 0 );
        my $success = eval {
            OPM::Validate->validate( $content, $is_sopm );
            1;
        };

        is $@, '', 'no errors for ' . $file if $type eq 'good';
        ok( ($type eq 'good' ? $success : !$success), $file );
    }
}



( run in 0.702 second using v1.01-cache-2.11-cpan-49f99fa48dc )