scripts/storytest

filter: Statementstmt 97.3% 73 / 75 Branchbran 84.6% 22 / 26 Conditioncond 66.6% 6 / 9 MC/DCmcdc 16.6% 1 / 6 Subroutinesub 100% 10 / 10 Podpod n/a totaltotal 88.8% 112 / 126 CC 1 SCAR 0.0
CC
1
Cov
92%
BEGIN
1.0
BEGIN
1.0
BEGIN
1.0
CRAP 1.0
« blib/lib/Test/Story/Tutorial.pm ↑ Summary
1 #!/usr/bin/env perl
2 18 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 18 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 18 ▶use lib qw( t/lib blib lib );
Subroutine BEGIN: called CC=1 SCAR=0.0
5 18 ▶use Test::Story;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 18 ▶use Getopt::Long;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 18 ▶use Pod::Usage;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 18 ▶use YAML qw(LoadFile);
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10 18 our $config = {};
11 18 my $home = $ENV{HOME};
12 18 my $config_path;
13  
14 18 our @allowed_extensions;
15 18 our @include_path;
16 18 our $verbose;
17 18 our $version = 0;
18 18 our $help = 0;
19 18 our $list = 0;
20 18 our $fixture_base;
21 18 our $file_root;
22 18 our $test_id;
23 18 our @tags = ();
24 18 ▶GetOptions(
Branch: 1 branch
BranchTrueFalseTotal
&GetOptions("version", \$main::version, "v|verbose+", \$main::verbose, "help", \$main::help, "list", \$main::list, "b|fixture_base=s", \$main::fixture_base, "r|file_root=s", \$main::file_root, "I|include=s", \@main::include_path, "config=s", \$config_path, "tag=s", \@main::tags, "extension=s", \@main::allowed_extensions, "id=s", \$main::test_id) or usage() 18 0 18
25 'version' => \$version,
26 'v|verbose+' => \$verbose,
27 'help' => \$help,
28 'list' => \$list,
29 'b|fixture_base=s' => \$fixture_base,
30 'r|file_root=s' => \$file_root,
31 'I|include=s' => \@include_path,
32 'config=s' => \$config_path,
33 'tag=s' => \@tags,
34 'extension=s' => \@allowed_extensions,
35 'id=s' => \$test_id,
36 ) or usage();
37 18 ▶usage() if $help;
Branch: 1 branch
BranchTrueFalseTotal
if $main::help 1 17 18
38 17 ▶version() if $version;
Branch: 1 branch
BranchTrueFalseTotal
if $main::version 1 16 17
39  
40 16 unshift @INC, @include_path;
41  
42 16 ▶if (defined($config_path) and !-f $config_path) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $config_path and not -f $config_path) 0 16 16
Condition66%2/3
defined $config_path and not -f $config_path
!ll&&!rl&&r
1420
MC/DC0%0/2
defined $config_path and not -f $config_path
defined $config_path not -f $config_path
Truth table66%2/3
A and not(B)
A= defined $config_pathB= not -f $config_path
ABresult
0X0
100
111
43 0 warn "Can't find specified config file \"$config_path\"\n";
44 0 usage();
45 }
46 16 ▶$config_path ||= glob("$home/.storytestrc");
Subroutine BEGIN: called CC=1 SCAR=0.0
Condition66%2/3
$config_path ||= glob("$home/.storytestrc")
l!l&&r!l&&!r
2140
MC/DC0%0/2
$config_path ||= glob("$home/.storytestrc")
$config_path glob("$home/.storytestrc")
Truth table66%2/3
A ||= B
A= $config_pathB= glob("$home/.storytestrc")
ABresult
1X1
011
000
47 16 ▶if (defined($config_path) and -r $config_path) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $config_path and -r $config_path) 2 14 16
Condition66%2/3
defined $config_path and -r $config_path
!ll&&!rl&&r
0142
MC/DC50%1/2
defined $config_path and -r $config_path
defined $config_path -r $config_path
Truth table66%2/3
A and B
A= defined $config_pathB= -r $config_path
ABresult
0X0
100
111
48 2 $config = LoadFile($config_path);
49 }
50  
51 16 ▶if ($config->{fixture_root}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($main::config->{"fixture_root"}) 2 14 16
52 2 lib->import($config->{fixture_root});
53 }
54 16 @tags = split(/,/, join(',', @tags));
55 1 our @exclude_tags = map { $_ =~ /^!(.*)/ }
56 16 grep { $_ =~ /^!/ }
57 @tags;
58 16 our @include_tags = grep { $_ !~ /^!/ }
59 @tags;
60  
61 16 ▶$config->{allowed_extensions} = \@allowed_extensions if @allowed_extensions;
Branch: 1 branch
BranchTrueFalseTotal
if @main::allowed_extensions 0 16 16
62 16 ▶$config->{fixture_base} = $fixture_base if defined $fixture_base;
Branch: 1 branch
BranchTrueFalseTotal
if defined $main::fixture_base 0 16 16
63 16 ▶$config->{file_root} = $file_root if defined $file_root;
Branch: 1 branch
BranchTrueFalseTotal
if defined $main::file_root 14 2 16
64 16 ▶$config->{verbose} = $verbose if defined $verbose;
Branch: 1 branch
BranchTrueFalseTotal
if defined $main::verbose 4 12 16
65 16 ▶$config->{filenames} = \@ARGV if @ARGV;
Branch: 1 branch
BranchTrueFalseTotal
if @ARGV 12 4 16
66 16 ▶$config->{testcase_id} = $test_id if defined $test_id;
Branch: 1 branch
BranchTrueFalseTotal
if defined $main::test_id 1 15 16
67 $config->{tags} = {
68 16 include => \@include_tags,
69 exclude => \@exclude_tags,
70 };
71  
72 16 my $a8n = Test::Story->new({ config => $config });
73 16 ▶if ($list) {
Branch: 1 branch
BranchTrueFalseTotal
if ($main::list) 6 10 16
74 6 my @cases = map { @{ $_->filtered_cases($test_id) } }
75 6 @{ $a8n->files };
76 6 foreach my $case (@cases) {
77 9 print $case->filename . " => " . $case->id . "\n";
78 }
79 6 exit;
80 }
81 10 $a8n->run_tests();
82  
83 1 ▶sub usage {
Subroutine usage: called CC=1 SCAR=0.0
84 1 pod2usage();
85 }
86  
87 1 ▶sub version {
Subroutine version: called CC=1 SCAR=0.0
88 1 print "storytest version " . $Test::Story::VERSION . "\n";
89 1 exit 2;
90 }
91  
92 __END__
« blib/lib/Test/Story/Tutorial.pm ↑ Summary