File Coverage

blib/lib/Test/XS/Check.pm
Criterion Covered Total %
statement 26 26 100.0
branch 2 2 100.0
condition n/a
subroutine 7 7 100.0
pod 1 1 100.0
total 36 36 100.0


line stmt bran cond sub pod time code
1             package Test::XS::Check;
2              
3 1     1   217855 use strict;
  1         3  
  1         41  
4 1     1   14 use warnings;
  1         2  
  1         74  
5              
6             our $VERSION = '0.02';
7              
8 1     1   7 use Test2::API qw( context );
  1         1  
  1         65  
9 1     1   617 use XS::Check 0.07;
  1         43150  
  1         100  
10              
11             our @EXPORT_OK = qw( xs_ok );
12              
13 1     1   12 use Exporter qw( import );
  1         2  
  1         246  
14              
15             sub xs_ok {
16 2     2 1 646962 my $file = shift;
17              
18 2         9 my $context = context();
19              
20 2         264 my @errors;
21 2     3   32 my $check = XS::Check->new( reporter => sub { push @errors, {@_} } );
  3         1107  
22 2         59 $check->check_file($file);
23              
24 2         20280 $context->ok( !@errors, "XS check for $file" );
25 2 100       822 if (@errors) {
26 1         10 $context->diag("$_->{message} at line $_->{line}") for @errors;
27             }
28 2         739 $context->release;
29              
30 2         138 return !@errors;
31             }
32              
33             1;
34              
35             # ABSTRACT: Test that your XS files are problem-free with XS::Check
36              
37             __END__