| 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
| |||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||
| 38 | 17 | ▶ | version() if $version; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 39 | |||||||||||||||||||||||||||||
| 40 | 16 | unshift @INC, @include_path; | |||||||||||||||||||||||||||
| 41 | |||||||||||||||||||||||||||||
| 42 | 16 | ▶ | if (defined($config_path) and !-f $config_path) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
defined $config_path and not -f $config_path
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
| |||||||||||||||||||||||||||||
| 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")
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")
| |||||||||||||||||||||||||||||
| 47 | 16 | ▶ | if (defined($config_path) and -r $config_path) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
defined $config_path and -r $config_path
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
| |||||||||||||||||||||||||||||
| 48 | 2 | $config = LoadFile($config_path); | |||||||||||||||||||||||||||
| 49 | } | ||||||||||||||||||||||||||||
| 50 | |||||||||||||||||||||||||||||
| 51 | 16 | ▶ | if ($config->{fixture_root}) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||
| 62 | 16 | ▶ | $config->{fixture_base} = $fixture_base if defined $fixture_base; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 63 | 16 | ▶ | $config->{file_root} = $file_root if defined $file_root; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 64 | 16 | ▶ | $config->{verbose} = $verbose if defined $verbose; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 65 | 16 | ▶ | $config->{filenames} = \@ARGV if @ARGV; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 66 | 16 | ▶ | $config->{testcase_id} = $test_id if defined $test_id; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||
| 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__ | ||||||||||||||||||||||||||||