Maker/Command/sopmtest.pm

filter: Statementstmt 95.2% 40 / 42 Branchbran 87.5% 7 / 8 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 10 / 10 Podpod 100% 4 / 4 totaltotal 95.3% 61 / 64 CC 5 SCAR 7.0
CC
5
Cov
94%
execute
4.0
validate_args
2.0
BEGIN
1.0
CRAP 2.0
« Maker/Command/dependencies.pm ↑ Summary Maker/Command/dbtest.pm »
1 package OPM::Maker::Command::sopmtest;
2 21 $OPM::Maker::Command::sopmtest::VERSION = '1.17';
3 # ABSTRACT: Check if sopm is valid
4  
5 21 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 21 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 21 ▶use Path::Class ();
Subroutine BEGIN: called CC=1 SCAR=0.0
9 21 ▶use OPM::Validate;
Subroutine BEGIN: called CC=1 SCAR=0.0
10  
11 21 ▶use OPM::Maker -command;
Subroutine BEGIN: called CC=1 SCAR=0.0
12 21 ▶use OPM::Maker::Utils qw(check_args_sopm);
Subroutine BEGIN: called CC=1 SCAR=0.0
13  
14 1 ▶sub abstract {
Subroutine abstract: called CC=1 SCAR=0.0
Pod documented
15 1 return "check .sopm if it is valid";
16 }
17  
18 1 ▶sub usage_desc {
Subroutine usage_desc: called CC=1 SCAR=0.0
Pod documented
19 1 return "opmbuild sopmtest <path_to_sopm>";
20 }
21  
22 16 ▶sub validate_args {
Subroutine validate_args: called CC=2 SCAR=6.9
Pod documented
23 16 my ($self, $opt, $args) = @_;
24  
25 16 my $sopm = check_args_sopm( $args, 1 );
26 16 ▶ $self->usage_error( 'need path to .sopm' ) if
Branch: 1 branch
BranchTrueFalseTotal
if not $sopm 10 6 16
27 !$sopm;
28 }
29  
30 9 ▶sub execute {
Subroutine execute: called CC=4 SCAR=14.0
Pod documented
31 9 my ($self, $opt, $args) = @_;
32
33 9 my $file = check_args_sopm( $args, 1 );
34  
35 9 ▶ if ( !defined $file ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $file) 2 7 9
36 2 print "No file given!";
37 2 return;
38 }
39
40 7 ▶ if ( !-f $file ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (-f $file) 0 7 7
41 0 print "$file does not exist";
42 0 return;
43 }
44  
45 eval {
46 7 my $content = do{ local (@ARGV, $/) = $file; <> };
47 7 OPM::Validate->validate( $content, 1 );
48 4 1;
49 7 ▶ } or do {
Branch: 1 branch
BranchTrueFalseTotal
eval { do { my $content = do { local(@ARGV, $/) = $file; readline ARGV }; "OPM::Validate"->validate($content, 1); 1 } } or do { print ".sopm is not valid: $@\n"; return } 4 3 7
50 3 print ".sopm is not valid: $@\n";
51 3 return;
52 };
53
54 4 return 1;
55 }
56  
57 21 1;
58  
59 __END__
« Maker/Command/dependencies.pm ↑ Summary Maker/Command/dbtest.pm »