| 1 | package Test::Smoke::BuildCFG; | ||||||||||||||||||||||||||||||||||||||||||
| 2 | 15 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 3 | |||||||||||||||||||||||||||||||||||||||||||
| 4 | 15 | our $VERSION = '0.011'; | |||||||||||||||||||||||||||||||||||||||||
| 5 | |||||||||||||||||||||||||||||||||||||||||||
| 6 | 15 | ▶ | use Cwd; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 7 | 15 | ▶ | use File::Basename qw( dirname ); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 8 | 15 | ▶ | use File::Spec; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 9 | 15 | require File::Path; | |||||||||||||||||||||||||||||||||||||||||
| 10 | 15 | ▶ | use Test::Smoke::LogMixin; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 11 | 15 | ▶ | use Test::Smoke::Util qw( skip_config ); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 12 | |||||||||||||||||||||||||||||||||||||||||||
| 13 | 15 | my %CONFIG = ( | |||||||||||||||||||||||||||||||||||||||||
| 14 | df_v => 0, | ||||||||||||||||||||||||||||||||||||||||||
| 15 | df_dfopts => '-Dusedevel', | ||||||||||||||||||||||||||||||||||||||||||
| 16 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 17 | |||||||||||||||||||||||||||||||||||||||||||
| 18 | =head1 NAME | ||||||||||||||||||||||||||||||||||||||||||
| 19 | |||||||||||||||||||||||||||||||||||||||||||
| 20 | Test::Smoke::BuildCFG - OO interface for handling build configurations | ||||||||||||||||||||||||||||||||||||||||||
| 21 | |||||||||||||||||||||||||||||||||||||||||||
| 22 | =head1 SYNOPSIS | ||||||||||||||||||||||||||||||||||||||||||
| 23 | |||||||||||||||||||||||||||||||||||||||||||
| 24 | use Test::Smoke::BuildCFG; | ||||||||||||||||||||||||||||||||||||||||||
| 25 | |||||||||||||||||||||||||||||||||||||||||||
| 26 | my $name = 'perlcurrent.cfg'; | ||||||||||||||||||||||||||||||||||||||||||
| 27 | my $bcfg = Test::Smoke::BuildCFG->new( $name ); | ||||||||||||||||||||||||||||||||||||||||||
| 28 | |||||||||||||||||||||||||||||||||||||||||||
| 29 | foreach my $config ( $bcfg->configurations ) { | ||||||||||||||||||||||||||||||||||||||||||
| 30 | # do somthing with $config | ||||||||||||||||||||||||||||||||||||||||||
| 31 | } | ||||||||||||||||||||||||||||||||||||||||||
| 32 | |||||||||||||||||||||||||||||||||||||||||||
| 33 | =head1 DESCRIPTION | ||||||||||||||||||||||||||||||||||||||||||
| 34 | |||||||||||||||||||||||||||||||||||||||||||
| 35 | Handle the build configurations | ||||||||||||||||||||||||||||||||||||||||||
| 36 | |||||||||||||||||||||||||||||||||||||||||||
| 37 | =head1 METHODS | ||||||||||||||||||||||||||||||||||||||||||
| 38 | |||||||||||||||||||||||||||||||||||||||||||
| 39 | =head2 Test::Smoke::BuildCFG->new( [$cfgname] ) | ||||||||||||||||||||||||||||||||||||||||||
| 40 | |||||||||||||||||||||||||||||||||||||||||||
| 41 | [ Constructor | Public ] | ||||||||||||||||||||||||||||||||||||||||||
| 42 | |||||||||||||||||||||||||||||||||||||||||||
| 43 | Initialise a new object. | ||||||||||||||||||||||||||||||||||||||||||
| 44 | |||||||||||||||||||||||||||||||||||||||||||
| 45 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 46 | |||||||||||||||||||||||||||||||||||||||||||
| 47 | 8 | ▶ | sub new { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
new: called CC=5 SCAR=16.1
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 48 | 8 | my $proto = shift; | |||||||||||||||||||||||||||||||||||||||||
| 49 | 8 | ▶ | my $class = ref $proto ? ref $proto : $proto; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 50 | |||||||||||||||||||||||||||||||||||||||||||
| 51 | 8 | my $config = shift; | |||||||||||||||||||||||||||||||||||||||||
| 52 | |||||||||||||||||||||||||||||||||||||||||||
| 53 | 8 | ▶ | my %args_raw = @_ ? UNIVERSAL::isa( $_[0], 'HASH' ) ? %{ $_[0] } : @_ : (); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 54 | |||||||||||||||||||||||||||||||||||||||||||
| 55 | my %args = map { | ||||||||||||||||||||||||||||||||||||||||||
| 56 | 8 | ( my $key = $_ ) =~ s/^-?(.+)$/lc $1/e; | |||||||||||||||||||||||||||||||||||||||||
| 57 | 7 | ( $key => $args_raw{ $_ } ); | |||||||||||||||||||||||||||||||||||||||||
| 58 | } keys %args_raw; | ||||||||||||||||||||||||||||||||||||||||||
| 59 | |||||||||||||||||||||||||||||||||||||||||||
| 60 | my %fields = map { | ||||||||||||||||||||||||||||||||||||||||||
| 61 | 8 | ▶ | my $value = exists $args{$_} ? $args{ $_ } : $CONFIG{ "df_$_" }; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 62 | 16 | ( $_ => $value ) | |||||||||||||||||||||||||||||||||||||||||
| 63 | } qw( v dfopts ); | ||||||||||||||||||||||||||||||||||||||||||
| 64 | |||||||||||||||||||||||||||||||||||||||||||
| 65 | 8 | my $self = bless \%fields, $class; | |||||||||||||||||||||||||||||||||||||||||
| 66 | 8 | $self->read_parse( $config ); | |||||||||||||||||||||||||||||||||||||||||
| 67 | } | ||||||||||||||||||||||||||||||||||||||||||
| 68 | |||||||||||||||||||||||||||||||||||||||||||
| 69 | =head2 Test::Smoke::BuildCFG->continue( $logfile[, $cfgname, %options] ) | ||||||||||||||||||||||||||||||||||||||||||
| 70 | |||||||||||||||||||||||||||||||||||||||||||
| 71 | [Constructor | public] | ||||||||||||||||||||||||||||||||||||||||||
| 72 | |||||||||||||||||||||||||||||||||||||||||||
| 73 | Initialize a new object without the configurations that have already | ||||||||||||||||||||||||||||||||||||||||||
| 74 | been fully processed. If *all* configurations have been processed, | ||||||||||||||||||||||||||||||||||||||||||
| 75 | just pass the equivalent of the C<new()> method. | ||||||||||||||||||||||||||||||||||||||||||
| 76 | |||||||||||||||||||||||||||||||||||||||||||
| 77 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 78 | |||||||||||||||||||||||||||||||||||||||||||
| 79 | 1 | ▶ | sub continue { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
continue: called CC=8 SCAR=21.6
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 80 | 1 | my $proto = shift; | |||||||||||||||||||||||||||||||||||||||||
| 81 | 1 | ▶ | my $class = ref $proto ? ref $proto : $proto; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 82 | |||||||||||||||||||||||||||||||||||||||||||
| 83 | 1 | my $logfile = shift; | |||||||||||||||||||||||||||||||||||||||||
| 84 | |||||||||||||||||||||||||||||||||||||||||||
| 85 | 1 | my $self = $class->new( @_ ); | |||||||||||||||||||||||||||||||||||||||||
| 86 | 1 | $self->{_continue} = 1; | |||||||||||||||||||||||||||||||||||||||||
| 87 | 1 | ▶ | return $self unless $logfile && -f $logfile; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$logfile and -f $logfile
MC/DC0%0/2
$logfile and -f $logfile
$logfile
-f $logfile
Truth table33%1/3
A and B
A= $logfileB= -f $logfile
| |||||||||||||||||||||||||||||||||||||||||||
| 88 | |||||||||||||||||||||||||||||||||||||||||||
| 89 | 1 | my %seen = __get_smoked_configs( $logfile ); | |||||||||||||||||||||||||||||||||||||||||
| 90 | 1 | my @not_seen = (); | |||||||||||||||||||||||||||||||||||||||||
| 91 | 1 | foreach my $config ( $self->configurations ) { | |||||||||||||||||||||||||||||||||||||||||
| 92 | 4 | ▶ | push @not_seen, $config unless exists $seen{ "$config" } || | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
exists $seen{"$config"} or skip_config($config)
MC/DC50%1/2
exists $seen{"$config"} or skip_config($config)
exists $seen{"$config"}
skip_config($config)
Truth table66%2/3
A or B
A= exists $seen{"$config"}B= skip_config($config)
| |||||||||||||||||||||||||||||||||||||||||||
| 93 | skip_config( $config ); | ||||||||||||||||||||||||||||||||||||||||||
| 94 | } | ||||||||||||||||||||||||||||||||||||||||||
| 95 | 1 | ▶ | return $self unless @not_seen; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 96 | 1 | $self->{_list} = \@not_seen; | |||||||||||||||||||||||||||||||||||||||||
| 97 | 1 | return $self; | |||||||||||||||||||||||||||||||||||||||||
| 98 | } | ||||||||||||||||||||||||||||||||||||||||||
| 99 | |||||||||||||||||||||||||||||||||||||||||||
| 100 | =head2 $bldcfg->verbose | ||||||||||||||||||||||||||||||||||||||||||
| 101 | |||||||||||||||||||||||||||||||||||||||||||
| 102 | [ Getter | Public] | ||||||||||||||||||||||||||||||||||||||||||
| 103 | |||||||||||||||||||||||||||||||||||||||||||
| 104 | Get verbosity. | ||||||||||||||||||||||||||||||||||||||||||
| 105 | |||||||||||||||||||||||||||||||||||||||||||
| 106 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 107 | |||||||||||||||||||||||||||||||||||||||||||
| 108 | 32 | ▶ | sub verbose { $_[0]->{v} } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
verbose: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 109 | |||||||||||||||||||||||||||||||||||||||||||
| 110 | =head2 Test::Smoke::BuildCFG->config( $key[, $value] ) | ||||||||||||||||||||||||||||||||||||||||||
| 111 | |||||||||||||||||||||||||||||||||||||||||||
| 112 | [ ClassAccessor | Public ] | ||||||||||||||||||||||||||||||||||||||||||
| 113 | |||||||||||||||||||||||||||||||||||||||||||
| 114 | C<config()> is an interface to the package lexical C<%CONFIG>, | ||||||||||||||||||||||||||||||||||||||||||
| 115 | which holds all the default values for the C<new()> arguments. | ||||||||||||||||||||||||||||||||||||||||||
| 116 | |||||||||||||||||||||||||||||||||||||||||||
| 117 | With the special key B<all_defaults> this returns a reference | ||||||||||||||||||||||||||||||||||||||||||
| 118 | to a hash holding all the default values. | ||||||||||||||||||||||||||||||||||||||||||
| 119 | |||||||||||||||||||||||||||||||||||||||||||
| 120 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 121 | |||||||||||||||||||||||||||||||||||||||||||
| 122 | 18 | ▶ | sub config { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
config: called CC=4 SCAR=15.8
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 123 | 18 | my $dummy = shift; | |||||||||||||||||||||||||||||||||||||||||
| 124 | |||||||||||||||||||||||||||||||||||||||||||
| 125 | 18 | my $key = lc shift; | |||||||||||||||||||||||||||||||||||||||||
| 126 | |||||||||||||||||||||||||||||||||||||||||||
| 127 | 18 | ▶ | if ( $key eq 'all_defaults' ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 128 | my %default = map { | ||||||||||||||||||||||||||||||||||||||||||
| 129 | 0 | my( $pass_key ) = $_ =~ /^df_(.+)/; | |||||||||||||||||||||||||||||||||||||||||
| 130 | 0 | ( $pass_key => $CONFIG{ $_ } ); | |||||||||||||||||||||||||||||||||||||||||
| 131 | } grep /^df_/ => keys %CONFIG; | ||||||||||||||||||||||||||||||||||||||||||
| 132 | 0 | return \%default; | |||||||||||||||||||||||||||||||||||||||||
| 133 | } | ||||||||||||||||||||||||||||||||||||||||||
| 134 | |||||||||||||||||||||||||||||||||||||||||||
| 135 | 18 | ▶ | return undef unless exists $CONFIG{ "df_$key" }; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 136 | |||||||||||||||||||||||||||||||||||||||||||
| 137 | 18 | ▶ | $CONFIG{ "df_$key" } = shift if @_; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 138 | |||||||||||||||||||||||||||||||||||||||||||
| 139 | 18 | return $CONFIG{ "df_$key" }; | |||||||||||||||||||||||||||||||||||||||||
| 140 | } | ||||||||||||||||||||||||||||||||||||||||||
| 141 | |||||||||||||||||||||||||||||||||||||||||||
| 142 | =head2 $self->read_parse( $cfgname ) | ||||||||||||||||||||||||||||||||||||||||||
| 143 | |||||||||||||||||||||||||||||||||||||||||||
| 144 | C<read_parse()> reads the build configurations file and parses it. | ||||||||||||||||||||||||||||||||||||||||||
| 145 | |||||||||||||||||||||||||||||||||||||||||||
| 146 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 147 | |||||||||||||||||||||||||||||||||||||||||||
| 148 | 8 | ▶ | sub read_parse { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
read_parse: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 149 | 8 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 150 | |||||||||||||||||||||||||||||||||||||||||||
| 151 | 8 | $self->_read( @_ ); | |||||||||||||||||||||||||||||||||||||||||
| 152 | 8 | $self->_parse; | |||||||||||||||||||||||||||||||||||||||||
| 153 | |||||||||||||||||||||||||||||||||||||||||||
| 154 | 8 | return $self; | |||||||||||||||||||||||||||||||||||||||||
| 155 | } | ||||||||||||||||||||||||||||||||||||||||||
| 156 | |||||||||||||||||||||||||||||||||||||||||||
| 157 | =head2 $self->_read( $nameorref ) | ||||||||||||||||||||||||||||||||||||||||||
| 158 | |||||||||||||||||||||||||||||||||||||||||||
| 159 | C<_read()> is a private method that handles the reading. | ||||||||||||||||||||||||||||||||||||||||||
| 160 | |||||||||||||||||||||||||||||||||||||||||||
| 161 | =over 4 | ||||||||||||||||||||||||||||||||||||||||||
| 162 | |||||||||||||||||||||||||||||||||||||||||||
| 163 | =item B<Reference to a SCALAR> build configurations are in C<$$nameorref> | ||||||||||||||||||||||||||||||||||||||||||
| 164 | |||||||||||||||||||||||||||||||||||||||||||
| 165 | =item B<Reference to an ARRAY> build configurations are in C<@$nameorref> | ||||||||||||||||||||||||||||||||||||||||||
| 166 | |||||||||||||||||||||||||||||||||||||||||||
| 167 | =item B<Reference to a GLOB> build configurations are read from the filehandle | ||||||||||||||||||||||||||||||||||||||||||
| 168 | |||||||||||||||||||||||||||||||||||||||||||
| 169 | =item B<Other values> are taken as the filename for the build configurations | ||||||||||||||||||||||||||||||||||||||||||
| 170 | |||||||||||||||||||||||||||||||||||||||||||
| 171 | =back | ||||||||||||||||||||||||||||||||||||||||||
| 172 | |||||||||||||||||||||||||||||||||||||||||||
| 173 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 174 | |||||||||||||||||||||||||||||||||||||||||||
| 175 | 8 | ▶ | sub _read { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_read: called CC=9 SCAR=31.2
| |||||||||||||||||||||||||||||||||||||||||||
| 176 | 8 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 177 | 8 | my( $nameorref ) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 178 | 8 | ▶ | $nameorref = '' unless defined $nameorref; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 179 | |||||||||||||||||||||||||||||||||||||||||||
| 180 | 8 | my $vmsg = ""; | |||||||||||||||||||||||||||||||||||||||||
| 181 | 8 | local *BUILDCFG; | |||||||||||||||||||||||||||||||||||||||||
| 182 | 8 | ▶ | if ( ref $nameorref eq 'SCALAR' ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 4 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 183 | 6 | $self->{_buildcfg} = $$nameorref; | |||||||||||||||||||||||||||||||||||||||||
| 184 | 6 | $vmsg = "internal content"; | |||||||||||||||||||||||||||||||||||||||||
| 185 | } elsif ( ref $nameorref eq 'ARRAY' ) { | ||||||||||||||||||||||||||||||||||||||||||
| 186 | 0 | $self->{_buildcfg} = join "", @$nameorref; | |||||||||||||||||||||||||||||||||||||||||
| 187 | 0 | $vmsg = "internal content"; | |||||||||||||||||||||||||||||||||||||||||
| 188 | } elsif ( ref $nameorref eq 'HASH' ) { | ||||||||||||||||||||||||||||||||||||||||||
| 189 | 0 | $self->{_buildcfg} = undef; | |||||||||||||||||||||||||||||||||||||||||
| 190 | 0 | $self->{_list} = $nameorref->{_list}; | |||||||||||||||||||||||||||||||||||||||||
| 191 | 0 | $vmsg = "continuing smoke"; | |||||||||||||||||||||||||||||||||||||||||
| 192 | } elsif ( ref $nameorref eq 'GLOB' ) { | ||||||||||||||||||||||||||||||||||||||||||
| 193 | 0 | *BUILDCFG = *$nameorref; | |||||||||||||||||||||||||||||||||||||||||
| 194 | 0 | $self->{_buildcfg} = do { local $/; <BUILDCFG> }; | |||||||||||||||||||||||||||||||||||||||||
| 195 | 0 | $vmsg = "anonymous filehandle"; | |||||||||||||||||||||||||||||||||||||||||
| 196 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 197 | 2 | ▶ | if ( $nameorref ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 198 | 0 | ▶ | if ( open BUILDCFG, "< $nameorref" ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 199 | 0 | $self->{_buildcfg} = do { local $/; <BUILDCFG> }; | |||||||||||||||||||||||||||||||||||||||||
| 200 | 0 | close BUILDCFG; | |||||||||||||||||||||||||||||||||||||||||
| 201 | 0 | $vmsg = $nameorref; | |||||||||||||||||||||||||||||||||||||||||
| 202 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 203 | 0 | require Carp; | |||||||||||||||||||||||||||||||||||||||||
| 204 | 0 | Carp::carp("Cannot read buildconfigurations ($nameorref): $!"); | |||||||||||||||||||||||||||||||||||||||||
| 205 | 0 | $self->{_buildcfg} = $self->default_buildcfg(); | |||||||||||||||||||||||||||||||||||||||||
| 206 | 0 | $vmsg = "internal content"; | |||||||||||||||||||||||||||||||||||||||||
| 207 | } | ||||||||||||||||||||||||||||||||||||||||||
| 208 | } else { # Allow intentional default_buildcfg() | ||||||||||||||||||||||||||||||||||||||||||
| 209 | 2 | $self->{_buildcfg} = $self->default_buildcfg(); | |||||||||||||||||||||||||||||||||||||||||
| 210 | 2 | $vmsg = "internal content"; | |||||||||||||||||||||||||||||||||||||||||
| 211 | } | ||||||||||||||||||||||||||||||||||||||||||
| 212 | } | ||||||||||||||||||||||||||||||||||||||||||
| 213 | 8 | ▶ | $vmsg .= "[continue]" if $self->{_continue}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 214 | 8 | $self->log_info("Reading build configurations from %s", $vmsg); | |||||||||||||||||||||||||||||||||||||||||
| 215 | } | ||||||||||||||||||||||||||||||||||||||||||
| 216 | |||||||||||||||||||||||||||||||||||||||||||
| 217 | =head2 $self->_parse( ) | ||||||||||||||||||||||||||||||||||||||||||
| 218 | |||||||||||||||||||||||||||||||||||||||||||
| 219 | C<_parse()> will split the build configurations file in sections. | ||||||||||||||||||||||||||||||||||||||||||
| 220 | Sections are ended with a line that begins with an equals-sign ('='). | ||||||||||||||||||||||||||||||||||||||||||
| 221 | |||||||||||||||||||||||||||||||||||||||||||
| 222 | There are two types of section | ||||||||||||||||||||||||||||||||||||||||||
| 223 | |||||||||||||||||||||||||||||||||||||||||||
| 224 | =over | ||||||||||||||||||||||||||||||||||||||||||
| 225 | |||||||||||||||||||||||||||||||||||||||||||
| 226 | =item B<buildopt-section> | ||||||||||||||||||||||||||||||||||||||||||
| 227 | |||||||||||||||||||||||||||||||||||||||||||
| 228 | =item B<policy-section> | ||||||||||||||||||||||||||||||||||||||||||
| 229 | |||||||||||||||||||||||||||||||||||||||||||
| 230 | A B<policy-section> contains a "target-option". This is a build option | ||||||||||||||||||||||||||||||||||||||||||
| 231 | that should be in the ccflags variable in the F<Policy.sh> file | ||||||||||||||||||||||||||||||||||||||||||
| 232 | (see also L<Test::Smoke::Policy>) and starts with a (forward) slash ('/'). | ||||||||||||||||||||||||||||||||||||||||||
| 233 | |||||||||||||||||||||||||||||||||||||||||||
| 234 | A B<policy-section> can have only one (1) target-option. | ||||||||||||||||||||||||||||||||||||||||||
| 235 | |||||||||||||||||||||||||||||||||||||||||||
| 236 | =back | ||||||||||||||||||||||||||||||||||||||||||
| 237 | |||||||||||||||||||||||||||||||||||||||||||
| 238 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 239 | |||||||||||||||||||||||||||||||||||||||||||
| 240 | 8 | ▶ | sub _parse { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_parse: called CC=11 SCAR=24.2
| |||||||||||||||||||||||||||||||||||||||||||
| 241 | 8 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 242 | |||||||||||||||||||||||||||||||||||||||||||
| 243 | 8 | ▶ | return unless defined $self->{_buildcfg}; # || $self->{_list}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 244 | |||||||||||||||||||||||||||||||||||||||||||
| 245 | 8 | $self->{_sections} = [ ]; | |||||||||||||||||||||||||||||||||||||||||
| 246 | 8 | my @sections = split m/^=.*\n/m, $self->{_buildcfg}; | |||||||||||||||||||||||||||||||||||||||||
| 247 | 8 | $self->log_debug("Found %d raw-sections", scalar @sections); | |||||||||||||||||||||||||||||||||||||||||
| 248 | |||||||||||||||||||||||||||||||||||||||||||
| 249 | 8 | foreach my $section ( @sections ) { | |||||||||||||||||||||||||||||||||||||||||
| 250 | 25 | chomp $section; | |||||||||||||||||||||||||||||||||||||||||
| 251 | 25 | my $index = 0; | |||||||||||||||||||||||||||||||||||||||||
| 252 | 25 | my %opts = map { s/^\s+$//; $_ => $index++ } | |||||||||||||||||||||||||||||||||||||||||
| 253 | grep !/^#/ => split /\n/, $section, -1; | ||||||||||||||||||||||||||||||||||||||||||
| 254 | # Skip empty sections | ||||||||||||||||||||||||||||||||||||||||||
| 255 | 25 | ▶ | next if (keys %opts == 0) or (exists $opts{ "" } and keys %opts == 1); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition83%5/6
keys %opts == 0 or exists $opts{""} and keys %opts == 1
exists $opts{""} and keys %opts == 1
MC/DC66%2/3
keys %opts == 0 or exists $opts{""} and keys %opts == 1
keys %opts == 0
exists $opts{""}
keys %opts == 1
Truth table75%3/4
A or B and C
A= keys %opts == 0B= exists $opts{""}C= keys %opts == 1
| |||||||||||||||||||||||||||||||||||||||||||
| 256 | |||||||||||||||||||||||||||||||||||||||||||
| 257 | 22 | ▶ | if ( grep m|^/.+/?$| => keys %opts ) { # Policy section | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 258 | 9 | my @targets; | |||||||||||||||||||||||||||||||||||||||||
| 259 | 9 | my @lines = keys %opts; | |||||||||||||||||||||||||||||||||||||||||
| 260 | 9 | foreach my $line ( @lines ) { | |||||||||||||||||||||||||||||||||||||||||
| 261 | 27 | ▶ | next unless $line =~ m|^/(.+?)/?$|; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 262 | |||||||||||||||||||||||||||||||||||||||||||
| 263 | 9 | push @targets, $1; | |||||||||||||||||||||||||||||||||||||||||
| 264 | 9 | delete $opts{ $line }; | |||||||||||||||||||||||||||||||||||||||||
| 265 | } | ||||||||||||||||||||||||||||||||||||||||||
| 266 | 9 | ▶ | if ( @targets > 1 ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 267 | 0 | require Carp; | |||||||||||||||||||||||||||||||||||||||||
| 268 | 0 | Carp::carp( "Multiple policy lines in one section:\n\t", | |||||||||||||||||||||||||||||||||||||||||
| 269 | join( "\n\t", @targets ), | ||||||||||||||||||||||||||||||||||||||||||
| 270 | "\nWill use /$targets[0]/\n" ); | ||||||||||||||||||||||||||||||||||||||||||
| 271 | } | ||||||||||||||||||||||||||||||||||||||||||
| 272 | 9 | push @{ $self->{_sections} }, | |||||||||||||||||||||||||||||||||||||||||
| 273 | { policy_target => $targets[0], | ||||||||||||||||||||||||||||||||||||||||||
| 274 | 9 | args => [ sort {$opts{ $a } <=> $opts{ $b }} keys %opts ] }; | |||||||||||||||||||||||||||||||||||||||||
| 275 | |||||||||||||||||||||||||||||||||||||||||||
| 276 | } else { # Buildopt section | ||||||||||||||||||||||||||||||||||||||||||
| 277 | 13 | push @{ $self->{_sections} }, | |||||||||||||||||||||||||||||||||||||||||
| 278 | 13 | [ sort {$opts{ $a } <=> $opts{ $b }} keys %opts ]; | |||||||||||||||||||||||||||||||||||||||||
| 279 | } | ||||||||||||||||||||||||||||||||||||||||||
| 280 | } | ||||||||||||||||||||||||||||||||||||||||||
| 281 | # Make sure we have at least *one* section | ||||||||||||||||||||||||||||||||||||||||||
| 282 | 0 | ▶ | push @{ $self->{_sections} }, [ "" ] unless @{ $self->{_sections} }; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 283 | |||||||||||||||||||||||||||||||||||||||||||
| 284 | 8 | $self->log_debug("Left with %d parsed sections", scalar @{$self->{_sections}}); | |||||||||||||||||||||||||||||||||||||||||
| 285 | 8 | $self->_serialize; | |||||||||||||||||||||||||||||||||||||||||
| 286 | 8 | $self->log_debug("Found %d (unfiltered) configurations", scalar @{$self->{_list}}); | |||||||||||||||||||||||||||||||||||||||||
| 287 | } | ||||||||||||||||||||||||||||||||||||||||||
| 288 | |||||||||||||||||||||||||||||||||||||||||||
| 289 | =head2 $self->_serialize( ) | ||||||||||||||||||||||||||||||||||||||||||
| 290 | |||||||||||||||||||||||||||||||||||||||||||
| 291 | C<_serialize()> creates a list of B<Test::Smoke::BuildCFG::Config> | ||||||||||||||||||||||||||||||||||||||||||
| 292 | objects from the parsed sections. | ||||||||||||||||||||||||||||||||||||||||||
| 293 | |||||||||||||||||||||||||||||||||||||||||||
| 294 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 295 | |||||||||||||||||||||||||||||||||||||||||||
| 296 | 8 | ▶ | sub _serialize { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_serialize: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 297 | 8 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 298 | |||||||||||||||||||||||||||||||||||||||||||
| 299 | 8 | my $list = [ ]; | |||||||||||||||||||||||||||||||||||||||||
| 300 | 8 | __build_list( $list, $self->{dfopts}, [ ], @{ $self->{_sections} } ); | |||||||||||||||||||||||||||||||||||||||||
| 301 | |||||||||||||||||||||||||||||||||||||||||||
| 302 | 8 | $self->{_list} = $list; | |||||||||||||||||||||||||||||||||||||||||
| 303 | } | ||||||||||||||||||||||||||||||||||||||||||
| 304 | |||||||||||||||||||||||||||||||||||||||||||
| 305 | =head2 __build_list( $list, $previous_args, $policy_subst, $this_cfg, @cfgs ) | ||||||||||||||||||||||||||||||||||||||||||
| 306 | |||||||||||||||||||||||||||||||||||||||||||
| 307 | Recursive sub, mainly taken from the old C<run_tests()> in F<mktest.pl> | ||||||||||||||||||||||||||||||||||||||||||
| 308 | |||||||||||||||||||||||||||||||||||||||||||
| 309 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 310 | |||||||||||||||||||||||||||||||||||||||||||
| 311 | 52 | ▶ | sub __build_list { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__build_list: called CC=6 SCAR=17.9
| |||||||||||||||||||||||||||||||||||||||||||
| 312 | 52 | my( $list, $previous_args, $policy_subst, $this_cfg, @cfgs ) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 313 | |||||||||||||||||||||||||||||||||||||||||||
| 314 | 52 | my $policy_target; | |||||||||||||||||||||||||||||||||||||||||
| 315 | 52 | ▶ | if ( ref $this_cfg eq "HASH" ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 316 | 33 | $policy_target = $this_cfg->{policy_target}; | |||||||||||||||||||||||||||||||||||||||||
| 317 | 33 | $this_cfg = $this_cfg->{args}; | |||||||||||||||||||||||||||||||||||||||||
| 318 | } | ||||||||||||||||||||||||||||||||||||||||||
| 319 | |||||||||||||||||||||||||||||||||||||||||||
| 320 | 52 | foreach my $conf ( @$this_cfg ) { | |||||||||||||||||||||||||||||||||||||||||
| 321 | 108 | my $config_args = $previous_args; | |||||||||||||||||||||||||||||||||||||||||
| 322 | 108 | ▶ | $config_args .= " $conf" if length $conf; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 323 | |||||||||||||||||||||||||||||||||||||||||||
| 324 | 108 | my @substitutions = @$policy_subst; | |||||||||||||||||||||||||||||||||||||||||
| 325 | 108 | ▶ | push @substitutions, [ $policy_target, $conf ] | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 326 | if defined $policy_target; | ||||||||||||||||||||||||||||||||||||||||||
| 327 | |||||||||||||||||||||||||||||||||||||||||||
| 328 | 108 | ▶ | if ( @cfgs ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 329 | 44 | __build_list( $list, $config_args, \@substitutions, @cfgs ); | |||||||||||||||||||||||||||||||||||||||||
| 330 | 44 | next; | |||||||||||||||||||||||||||||||||||||||||
| 331 | } | ||||||||||||||||||||||||||||||||||||||||||
| 332 | |||||||||||||||||||||||||||||||||||||||||||
| 333 | 64 | push @$list, Test::Smoke::BuildCFG::Config->new( | |||||||||||||||||||||||||||||||||||||||||
| 334 | $config_args, @substitutions | ||||||||||||||||||||||||||||||||||||||||||
| 335 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 336 | } | ||||||||||||||||||||||||||||||||||||||||||
| 337 | } | ||||||||||||||||||||||||||||||||||||||||||
| 338 | |||||||||||||||||||||||||||||||||||||||||||
| 339 | =head2 $buildcfg->configurations( ) | ||||||||||||||||||||||||||||||||||||||||||
| 340 | |||||||||||||||||||||||||||||||||||||||||||
| 341 | Returns the list of configurations (Test::Smoke::BuildCFG::Config objects) | ||||||||||||||||||||||||||||||||||||||||||
| 342 | |||||||||||||||||||||||||||||||||||||||||||
| 343 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 344 | |||||||||||||||||||||||||||||||||||||||||||
| 345 | 7 | ▶ | sub configurations { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
configurations: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 346 | 7 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 347 | |||||||||||||||||||||||||||||||||||||||||||
| 348 | 7 | @{ $self->{_list} }; | |||||||||||||||||||||||||||||||||||||||||
| 349 | } | ||||||||||||||||||||||||||||||||||||||||||
| 350 | |||||||||||||||||||||||||||||||||||||||||||
| 351 | =head2 $buildcfg->policy_targets( ) | ||||||||||||||||||||||||||||||||||||||||||
| 352 | |||||||||||||||||||||||||||||||||||||||||||
| 353 | Returns a list of policytargets from the policy substitution sections | ||||||||||||||||||||||||||||||||||||||||||
| 354 | |||||||||||||||||||||||||||||||||||||||||||
| 355 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 356 | |||||||||||||||||||||||||||||||||||||||||||
| 357 | 2 | ▶ | sub policy_targets { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
policy_targets: called CC=5 SCAR=16.2
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 358 | 2 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 359 | |||||||||||||||||||||||||||||||||||||||||||
| 360 | 2 | ▶ | return unless UNIVERSAL::isa( $self->{_sections}, "ARRAY" ); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 361 | |||||||||||||||||||||||||||||||||||||||||||
| 362 | 2 | my @targets; | |||||||||||||||||||||||||||||||||||||||||
| 363 | 2 | for my $section ( @{ $self->{_sections} } ) { | |||||||||||||||||||||||||||||||||||||||||
| 364 | next unless UNIVERSAL::isa( $section, "HASH" ) && | ||||||||||||||||||||||||||||||||||||||||||
| 365 | 6 | ▶ | $section->{policy_target}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
UNIVERSAL::isa($section, "HASH") and $section->{"policy_target"}
MC/DC50%1/2
UNIVERSAL::isa($section, "HASH") and $section->{"policy_target"}
UNIVERSAL::isa($section, "HASH")
$section->{"policy_target"}
Truth table66%2/3
A and B
A= UNIVERSAL::isa($section, "HASH")B= $section->{"policy_target"}
| |||||||||||||||||||||||||||||||||||||||||||
| 366 | 3 | push @targets, $section->{policy_target}; | |||||||||||||||||||||||||||||||||||||||||
| 367 | } | ||||||||||||||||||||||||||||||||||||||||||
| 368 | |||||||||||||||||||||||||||||||||||||||||||
| 369 | 2 | return @targets; | |||||||||||||||||||||||||||||||||||||||||
| 370 | } | ||||||||||||||||||||||||||||||||||||||||||
| 371 | |||||||||||||||||||||||||||||||||||||||||||
| 372 | =head2 as_string | ||||||||||||||||||||||||||||||||||||||||||
| 373 | |||||||||||||||||||||||||||||||||||||||||||
| 374 | Return the parsed configuration as a string. | ||||||||||||||||||||||||||||||||||||||||||
| 375 | |||||||||||||||||||||||||||||||||||||||||||
| 376 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 377 | |||||||||||||||||||||||||||||||||||||||||||
| 378 | 5 | ▶ | sub as_string { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
as_string: called CC=4 SCAR=13.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 379 | 5 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 380 | 5 | my @sections; | |||||||||||||||||||||||||||||||||||||||||
| 381 | 5 | for my $section ( @{ $self->{_sections} } ) { | |||||||||||||||||||||||||||||||||||||||||
| 382 | 14 | ▶ | if ( UNIVERSAL::isa( $section, 'ARRAY' ) ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 383 | 8 | push @sections, $section; | |||||||||||||||||||||||||||||||||||||||||
| 384 | } elsif ( UNIVERSAL::isa( $section, 'HASH' ) ) { | ||||||||||||||||||||||||||||||||||||||||||
| 385 | push @sections, [ | ||||||||||||||||||||||||||||||||||||||||||
| 386 | "/$section->{policy_target}/", | ||||||||||||||||||||||||||||||||||||||||||
| 387 | 6 | @{ $section->{args} }, | |||||||||||||||||||||||||||||||||||||||||
| 388 | ]; | ||||||||||||||||||||||||||||||||||||||||||
| 389 | } | ||||||||||||||||||||||||||||||||||||||||||
| 390 | } | ||||||||||||||||||||||||||||||||||||||||||
| 391 | 5 | return join "=\n", map join( "\n", @$_, "" ) => @sections; | |||||||||||||||||||||||||||||||||||||||||
| 392 | } | ||||||||||||||||||||||||||||||||||||||||||
| 393 | |||||||||||||||||||||||||||||||||||||||||||
| 394 | =head2 source | ||||||||||||||||||||||||||||||||||||||||||
| 395 | |||||||||||||||||||||||||||||||||||||||||||
| 396 | returns the text-source of this instance. | ||||||||||||||||||||||||||||||||||||||||||
| 397 | |||||||||||||||||||||||||||||||||||||||||||
| 398 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 399 | |||||||||||||||||||||||||||||||||||||||||||
| 400 | 0 | ▶ | sub source { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
source: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 401 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 402 | |||||||||||||||||||||||||||||||||||||||||||
| 403 | 0 | return $self->{_buildcfg}; | |||||||||||||||||||||||||||||||||||||||||
| 404 | } | ||||||||||||||||||||||||||||||||||||||||||
| 405 | |||||||||||||||||||||||||||||||||||||||||||
| 406 | =head2 sections | ||||||||||||||||||||||||||||||||||||||||||
| 407 | |||||||||||||||||||||||||||||||||||||||||||
| 408 | returns an ARRAYREF of the sections in this instance. | ||||||||||||||||||||||||||||||||||||||||||
| 409 | |||||||||||||||||||||||||||||||||||||||||||
| 410 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 411 | |||||||||||||||||||||||||||||||||||||||||||
| 412 | 0 | ▶ | sub sections { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
sections: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 413 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 414 | |||||||||||||||||||||||||||||||||||||||||||
| 415 | 0 | return $self->{_sections}; | |||||||||||||||||||||||||||||||||||||||||
| 416 | } | ||||||||||||||||||||||||||||||||||||||||||
| 417 | |||||||||||||||||||||||||||||||||||||||||||
| 418 | =head2 __get_smoked_configs( $logfile ) | ||||||||||||||||||||||||||||||||||||||||||
| 419 | |||||||||||||||||||||||||||||||||||||||||||
| 420 | Parse the logfile and return a hash(ref) of already processed | ||||||||||||||||||||||||||||||||||||||||||
| 421 | configurations. | ||||||||||||||||||||||||||||||||||||||||||
| 422 | |||||||||||||||||||||||||||||||||||||||||||
| 423 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 424 | |||||||||||||||||||||||||||||||||||||||||||
| 425 | 1 | ▶ | sub __get_smoked_configs { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__get_smoked_configs: called CC=7 SCAR=19.6
| |||||||||||||||||||||||||||||||||||||||||||
| 426 | 1 | my( $logfile ) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 427 | |||||||||||||||||||||||||||||||||||||||||||
| 428 | 1 | my %conf_done = ( ); | |||||||||||||||||||||||||||||||||||||||||
| 429 | 1 | local *LOG; | |||||||||||||||||||||||||||||||||||||||||
| 430 | 1 | ▶ | if ( open LOG, "< $logfile" ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 431 | 1 | my $conf; | |||||||||||||||||||||||||||||||||||||||||
| 432 | # A Configuration is done when we detect a new Configuration: | ||||||||||||||||||||||||||||||||||||||||||
| 433 | # or the phrase "Finished smoking $patch" | ||||||||||||||||||||||||||||||||||||||||||
| 434 | 1 | ▶ | while ( <LOG> ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 435 | 17 | ▶ | s/^Configuration:\s*// || /^Finished smoking/ or next; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
s/^Configuration:\s*// or /^Finished smoking/
MC/DC50%1/2
s/^Configuration:\s*// or /^Finished smoking/
s/^Configuration:\s*//
/^Finished smoking/
Truth table66%2/3
A or B
A= s/^Configuration:\s*//B= /^Finished smoking/
| |||||||||||||||||||||||||||||||||||||||||||
| 436 | 3 | ▶ | $conf and $conf_done{ $conf }++; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 437 | 3 | chomp; $conf = $_; | |||||||||||||||||||||||||||||||||||||||||
| 438 | } | ||||||||||||||||||||||||||||||||||||||||||
| 439 | 1 | close LOG; | |||||||||||||||||||||||||||||||||||||||||
| 440 | } | ||||||||||||||||||||||||||||||||||||||||||
| 441 | 1 | ▶ | return wantarray ? %conf_done : \%conf_done; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 442 | } | ||||||||||||||||||||||||||||||||||||||||||
| 443 | |||||||||||||||||||||||||||||||||||||||||||
| 444 | =head2 Test::Smoke::BuildCFG->default_buildcfg() | ||||||||||||||||||||||||||||||||||||||||||
| 445 | |||||||||||||||||||||||||||||||||||||||||||
| 446 | This is a constant that returns a textversion of the default | ||||||||||||||||||||||||||||||||||||||||||
| 447 | configuration. | ||||||||||||||||||||||||||||||||||||||||||
| 448 | |||||||||||||||||||||||||||||||||||||||||||
| 449 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 450 | |||||||||||||||||||||||||||||||||||||||||||
| 451 | 2 | ▶ | sub default_buildcfg() { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
default_buildcfg: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 452 | |||||||||||||||||||||||||||||||||||||||||||
| 453 | 2 | return <<__EOCONFIG__; | |||||||||||||||||||||||||||||||||||||||||
| 454 | # Test::Smoke::BuildCFG->default_buildcfg | ||||||||||||||||||||||||||||||||||||||||||
| 455 | # Check the documentation for more information | ||||||||||||||||||||||||||||||||||||||||||
| 456 | == Build all configurations with and without ithreads | ||||||||||||||||||||||||||||||||||||||||||
| 457 | |||||||||||||||||||||||||||||||||||||||||||
| 458 | -Duseithreads | ||||||||||||||||||||||||||||||||||||||||||
| 459 | == Build with and without 64bitall | ||||||||||||||||||||||||||||||||||||||||||
| 460 | |||||||||||||||||||||||||||||||||||||||||||
| 461 | -Duse64bitall | ||||||||||||||||||||||||||||||||||||||||||
| 462 | == All configurations with and without -DDEBUGGING | ||||||||||||||||||||||||||||||||||||||||||
| 463 | /-DDEBUGGING/ | ||||||||||||||||||||||||||||||||||||||||||
| 464 | |||||||||||||||||||||||||||||||||||||||||||
| 465 | -DDEBUGGING | ||||||||||||||||||||||||||||||||||||||||||
| 466 | __EOCONFIG__ | ||||||||||||||||||||||||||||||||||||||||||
| 467 | } | ||||||||||||||||||||||||||||||||||||||||||
| 468 | |||||||||||||||||||||||||||||||||||||||||||
| 469 | =head2 Test::Smoke::BuildCFG->os_default_buildcfg($os) | ||||||||||||||||||||||||||||||||||||||||||
| 470 | |||||||||||||||||||||||||||||||||||||||||||
| 471 | Check for C<MSWin32> or C<VMS> and return one of the three prepared configs. | ||||||||||||||||||||||||||||||||||||||||||
| 472 | |||||||||||||||||||||||||||||||||||||||||||
| 473 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 474 | |||||||||||||||||||||||||||||||||||||||||||
| 475 | 5 | ▶ | sub os_default_buildcfg { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
os_default_buildcfg: called CC=4 SCAR=13.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 476 | 5 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 477 | 5 | my ($os) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 478 | |||||||||||||||||||||||||||||||||||||||||||
| 479 | 5 | (my $inc_name = __PACKAGE__ . ".pm") =~ s{::}{/}g; | |||||||||||||||||||||||||||||||||||||||||
| 480 | 5 | my $base_dir = dirname($INC{$inc_name}); | |||||||||||||||||||||||||||||||||||||||||
| 481 | 5 | my $bcfg_file = 'perlcurrent.cfg'; | |||||||||||||||||||||||||||||||||||||||||
| 482 | GIVEN: { | ||||||||||||||||||||||||||||||||||||||||||
| 483 | 5 | local $_ = $os; | |||||||||||||||||||||||||||||||||||||||||
| 484 | |||||||||||||||||||||||||||||||||||||||||||
| 485 | 5 | ▶ | /^MSWin32$/ && do { $bcfg_file = 'w32current.cfg'; last GIVEN; }; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 486 | 4 | ▶ | /^VMS$/ && do { $bcfg_file = 'vmsperl.cfg'; last GIVEN; }; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 487 | } | ||||||||||||||||||||||||||||||||||||||||||
| 488 | |||||||||||||||||||||||||||||||||||||||||||
| 489 | 5 | my $fullname = File::Spec->catfile($base_dir, $bcfg_file); | |||||||||||||||||||||||||||||||||||||||||
| 490 | 5 | my $content; | |||||||||||||||||||||||||||||||||||||||||
| 491 | 5 | ▶ | if (open(my $fh, '<', $fullname)) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 492 | 5 | $content = do { local $/; <$fh> }; | |||||||||||||||||||||||||||||||||||||||||
| 493 | 5 | close($fh); | |||||||||||||||||||||||||||||||||||||||||
| 494 | } | ||||||||||||||||||||||||||||||||||||||||||
| 495 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 496 | 0 | warn("Cannot open($fullname): $!"); | |||||||||||||||||||||||||||||||||||||||||
| 497 | 0 | $content = $self->default_buildcfg(); | |||||||||||||||||||||||||||||||||||||||||
| 498 | } | ||||||||||||||||||||||||||||||||||||||||||
| 499 | |||||||||||||||||||||||||||||||||||||||||||
| 500 | 5 | return $content; | |||||||||||||||||||||||||||||||||||||||||
| 501 | } | ||||||||||||||||||||||||||||||||||||||||||
| 502 | |||||||||||||||||||||||||||||||||||||||||||
| 503 | |||||||||||||||||||||||||||||||||||||||||||
| 504 | =head2 new_configuration( $config ) | ||||||||||||||||||||||||||||||||||||||||||
| 505 | |||||||||||||||||||||||||||||||||||||||||||
| 506 | A wrapper around C<< Test::Smoke::BuildCFG::Config->new() >> so the | ||||||||||||||||||||||||||||||||||||||||||
| 507 | object is accessible from outside this package. | ||||||||||||||||||||||||||||||||||||||||||
| 508 | |||||||||||||||||||||||||||||||||||||||||||
| 509 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 510 | |||||||||||||||||||||||||||||||||||||||||||
| 511 | 180 | ▶ | sub new_configuration { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
new_configuration: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 512 | 180 | return Test::Smoke::BuildCFG::Config->new( @_ ); | |||||||||||||||||||||||||||||||||||||||||
| 513 | } | ||||||||||||||||||||||||||||||||||||||||||
| 514 | |||||||||||||||||||||||||||||||||||||||||||
| 515 | 15 | 1; | |||||||||||||||||||||||||||||||||||||||||
| 516 | |||||||||||||||||||||||||||||||||||||||||||
| 517 | package Test::Smoke::BuildCFG::Config; | ||||||||||||||||||||||||||||||||||||||||||
| 518 | |||||||||||||||||||||||||||||||||||||||||||
| 519 | use overload | ||||||||||||||||||||||||||||||||||||||||||
| 520 | 83 | ▶ | '""' => sub { $_[0]->[0] || "" }, | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
__ANON__: called CC=2 SCAR=6.9
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 521 | 15 | fallback => 1; | |||||||||||||||||||||||||||||||||||||||||
| 522 | |||||||||||||||||||||||||||||||||||||||||||
| 523 | 15 | ▶ | use Text::ParseWords qw( quotewords ); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 524 | |||||||||||||||||||||||||||||||||||||||||||
| 525 | =head1 PACKAGE | ||||||||||||||||||||||||||||||||||||||||||
| 526 | |||||||||||||||||||||||||||||||||||||||||||
| 527 | Test::Smoke::BuildCFG::Config - OO interface for a build confiuration | ||||||||||||||||||||||||||||||||||||||||||
| 528 | |||||||||||||||||||||||||||||||||||||||||||
| 529 | =head1 SYNOPSIS | ||||||||||||||||||||||||||||||||||||||||||
| 530 | |||||||||||||||||||||||||||||||||||||||||||
| 531 | my $bcfg = Test::Smoke::BuildCFG::Config->new( $args, $policy ); | ||||||||||||||||||||||||||||||||||||||||||
| 532 | |||||||||||||||||||||||||||||||||||||||||||
| 533 | or | ||||||||||||||||||||||||||||||||||||||||||
| 534 | |||||||||||||||||||||||||||||||||||||||||||
| 535 | my $bcfg = Test::Smoke::BuildCFG::Config->new; | ||||||||||||||||||||||||||||||||||||||||||
| 536 | $bcfg->args( $args ); | ||||||||||||||||||||||||||||||||||||||||||
| 537 | $bcfg->policy( [ -DDEBUGGING => '-DDEBUGGING' ], | ||||||||||||||||||||||||||||||||||||||||||
| 538 | [ -DPERL_COPY_ON_WRITE => '' ] ); | ||||||||||||||||||||||||||||||||||||||||||
| 539 | |||||||||||||||||||||||||||||||||||||||||||
| 540 | if ( $bcfg->has_arg( '-Duseithreads' ) ) { | ||||||||||||||||||||||||||||||||||||||||||
| 541 | # do stuff for -Duseithreads | ||||||||||||||||||||||||||||||||||||||||||
| 542 | } | ||||||||||||||||||||||||||||||||||||||||||
| 543 | |||||||||||||||||||||||||||||||||||||||||||
| 544 | =head1 DESCRIPTION | ||||||||||||||||||||||||||||||||||||||||||
| 545 | |||||||||||||||||||||||||||||||||||||||||||
| 546 | This is a simple object that holds both the build arguments and the | ||||||||||||||||||||||||||||||||||||||||||
| 547 | policy substitutions. The build arguments are stored as a string and | ||||||||||||||||||||||||||||||||||||||||||
| 548 | the policy subtitutions are stored as a list of lists. Each substitution is | ||||||||||||||||||||||||||||||||||||||||||
| 549 | represented as a list with the two elements: the target and its substitute. | ||||||||||||||||||||||||||||||||||||||||||
| 550 | |||||||||||||||||||||||||||||||||||||||||||
| 551 | =head1 METHODS | ||||||||||||||||||||||||||||||||||||||||||
| 552 | |||||||||||||||||||||||||||||||||||||||||||
| 553 | =head2 Test::Smoke::BuildCFG::Config->new( [ $args[, \@policy_substs ]] ) | ||||||||||||||||||||||||||||||||||||||||||
| 554 | |||||||||||||||||||||||||||||||||||||||||||
| 555 | Create the new object as an anonymous list. | ||||||||||||||||||||||||||||||||||||||||||
| 556 | |||||||||||||||||||||||||||||||||||||||||||
| 557 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 558 | |||||||||||||||||||||||||||||||||||||||||||
| 559 | 244 | ▶ | sub new { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
new: called CC=4 SCAR=14.3
| |||||||||||||||||||||||||||||||||||||||||||
| 560 | 244 | my $proto = shift; | |||||||||||||||||||||||||||||||||||||||||
| 561 | 244 | ▶ | my $class = ref $proto || $proto; | ||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
ref $proto || $proto
MC/DC0%0/2
ref $proto || $proto
ref $proto
$proto
Truth table33%1/3
A || B
A= ref $protoB= $proto
| |||||||||||||||||||||||||||||||||||||||||||
| 562 | |||||||||||||||||||||||||||||||||||||||||||
| 563 | 244 | my $self = bless [ undef, [ ], { } ], $class; | |||||||||||||||||||||||||||||||||||||||||
| 564 | |||||||||||||||||||||||||||||||||||||||||||
| 565 | 244 | ▶ | @_ >= 1 and $self->args( shift ); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 566 | 244 | ▶ | @_ > 0 and $self->policy( @_ ); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 567 | |||||||||||||||||||||||||||||||||||||||||||
| 568 | 244 | $self; | |||||||||||||||||||||||||||||||||||||||||
| 569 | } | ||||||||||||||||||||||||||||||||||||||||||
| 570 | |||||||||||||||||||||||||||||||||||||||||||
| 571 | =head2 $buildcfg->args( [$args] ) | ||||||||||||||||||||||||||||||||||||||||||
| 572 | |||||||||||||||||||||||||||||||||||||||||||
| 573 | Accessor for the build arguments field. | ||||||||||||||||||||||||||||||||||||||||||
| 574 | |||||||||||||||||||||||||||||||||||||||||||
| 575 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 576 | |||||||||||||||||||||||||||||||||||||||||||
| 577 | 244 | ▶ | sub args { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
args: called CC=2 SCAR=7.0
| |||||||||||||||||||||||||||||||||||||||||||
| 578 | 244 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 579 | |||||||||||||||||||||||||||||||||||||||||||
| 580 | 244 | ▶ | if ( defined $_[0] ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 581 | 244 | $self->[0] = shift; | |||||||||||||||||||||||||||||||||||||||||
| 582 | 244 | $self->_split_args; | |||||||||||||||||||||||||||||||||||||||||
| 583 | } | ||||||||||||||||||||||||||||||||||||||||||
| 584 | |||||||||||||||||||||||||||||||||||||||||||
| 585 | 244 | $self->[0]; | |||||||||||||||||||||||||||||||||||||||||
| 586 | } | ||||||||||||||||||||||||||||||||||||||||||
| 587 | |||||||||||||||||||||||||||||||||||||||||||
| 588 | =head2 $buildcfg->policy( [@substitutes] ) | ||||||||||||||||||||||||||||||||||||||||||
| 589 | |||||||||||||||||||||||||||||||||||||||||||
| 590 | Accessor for the policy substitutions. | ||||||||||||||||||||||||||||||||||||||||||
| 591 | |||||||||||||||||||||||||||||||||||||||||||
| 592 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 593 | |||||||||||||||||||||||||||||||||||||||||||
| 594 | 80 | ▶ | sub policy { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
policy: called CC=4 SCAR=14.2
| |||||||||||||||||||||||||||||||||||||||||||
| 595 | 80 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 596 | |||||||||||||||||||||||||||||||||||||||||||
| 597 | 80 | ▶ | if ( @_ ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 598 | my @substitutions = @_ == 1 && ref $_[0][0] eq 'ARRAY' | ||||||||||||||||||||||||||||||||||||||||||
| 599 | 0 | ▶ | ? @{ $_[0] } : @_; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
@_ == 1 and ref $_[0][0] eq "ARRAY"
MC/DC0%0/2
@_ == 1 and ref $_[0][0] eq "ARRAY"
@_ == 1
ref $_[0][0] eq "ARRAY"
Truth table66%2/3
A and B
A= @_ == 1B= ref $_[0][0] eq "ARRAY"
| |||||||||||||||||||||||||||||||||||||||||||
| 600 | 64 | $self->[1] = \@substitutions; | |||||||||||||||||||||||||||||||||||||||||
| 601 | } | ||||||||||||||||||||||||||||||||||||||||||
| 602 | |||||||||||||||||||||||||||||||||||||||||||
| 603 | 80 | @{ $self->[1] }; | |||||||||||||||||||||||||||||||||||||||||
| 604 | } | ||||||||||||||||||||||||||||||||||||||||||
| 605 | |||||||||||||||||||||||||||||||||||||||||||
| 606 | =head2 $self->_split_args( ) | ||||||||||||||||||||||||||||||||||||||||||
| 607 | |||||||||||||||||||||||||||||||||||||||||||
| 608 | Create a hash with all the build arguments as keys. | ||||||||||||||||||||||||||||||||||||||||||
| 609 | |||||||||||||||||||||||||||||||||||||||||||
| 610 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 611 | |||||||||||||||||||||||||||||||||||||||||||
| 612 | 244 | ▶ | sub _split_args { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_split_args: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 613 | 244 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 614 | |||||||||||||||||||||||||||||||||||||||||||
| 615 | 244 | my $i = 0; | |||||||||||||||||||||||||||||||||||||||||
| 616 | $self->[2] = { | ||||||||||||||||||||||||||||||||||||||||||
| 617 | 244 | map { ( $_ => $i++ ) } quotewords( '\s+', 1, $self->[0] ) | |||||||||||||||||||||||||||||||||||||||||
| 618 | }; | ||||||||||||||||||||||||||||||||||||||||||
| 619 | $self->[0] = join( " ", sort { | ||||||||||||||||||||||||||||||||||||||||||
| 620 | 453 | $self->[2]{ $a } <=> $self->[2]{ $b } | |||||||||||||||||||||||||||||||||||||||||
| 621 | 244 | ▶ | } keys %{ $self->[2] } ) || ""; | ||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
join(' ', (sort {$self->[2]{$a} <=> $self->[2]{$b};} keys %{$$self[2];})) || ''
MC/DC100%1/1
join(' ', (sort {$self->[2]{$a} <=> $self->[2]{$b};} keys %{$$self[2];})) || ''
join(' ', (sort {$self->[2]{$a} <=> $self->[2]{$b};} keys %{$$self[2];}))
Truth table100%2/2
A
A= join(' ', (sort {$self->[2]{$a} <=> $self->[2]{$b};} keys %{$$self[2];}))
| |||||||||||||||||||||||||||||||||||||||||||
| 622 | } | ||||||||||||||||||||||||||||||||||||||||||
| 623 | |||||||||||||||||||||||||||||||||||||||||||
| 624 | =head2 $buildcfg->has_arg( $arg[,...] ) | ||||||||||||||||||||||||||||||||||||||||||
| 625 | |||||||||||||||||||||||||||||||||||||||||||
| 626 | Check the build arguments hash for C<$arg>. If you specify more then one | ||||||||||||||||||||||||||||||||||||||||||
| 627 | the results will be logically ANDed! | ||||||||||||||||||||||||||||||||||||||||||
| 628 | |||||||||||||||||||||||||||||||||||||||||||
| 629 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 630 | |||||||||||||||||||||||||||||||||||||||||||
| 631 | 74 | ▶ | sub has_arg { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
has_arg: called CC=3 SCAR=11.0
| |||||||||||||||||||||||||||||||||||||||||||
| 632 | 74 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 633 | |||||||||||||||||||||||||||||||||||||||||||
| 634 | 74 | my $ok = 1; | |||||||||||||||||||||||||||||||||||||||||
| 635 | 74 | ▶ | $ok &&= exists $self->[2]{ $_ } foreach @_; | ||||||||||||||||||||||||||||||||||||||||
|
Condition100%3/3
$ok &&= exists $self->[2]{$_}
MC/DC100%2/2
$ok &&= exists $self->[2]{$_}
$ok
exists $self->[2]{$_}
Truth table100%3/3
A &&= B
A= $okB= exists $self->[2]{$_}
| |||||||||||||||||||||||||||||||||||||||||||
| 636 | 74 | return $ok; | |||||||||||||||||||||||||||||||||||||||||
| 637 | } | ||||||||||||||||||||||||||||||||||||||||||
| 638 | |||||||||||||||||||||||||||||||||||||||||||
| 639 | =head2 $buildcfg->any_arg( $arg[,...] ) | ||||||||||||||||||||||||||||||||||||||||||
| 640 | |||||||||||||||||||||||||||||||||||||||||||
| 641 | Check the build arguments hash for C<$arg>. If you specify more then one | ||||||||||||||||||||||||||||||||||||||||||
| 642 | the results will be logically ORed! | ||||||||||||||||||||||||||||||||||||||||||
| 643 | |||||||||||||||||||||||||||||||||||||||||||
| 644 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 645 | |||||||||||||||||||||||||||||||||||||||||||
| 646 | 1 | ▶ | sub any_arg { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
any_arg: called CC=3 SCAR=11.1
| |||||||||||||||||||||||||||||||||||||||||||
| 647 | 1 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 648 | |||||||||||||||||||||||||||||||||||||||||||
| 649 | 1 | my $ok = 0; | |||||||||||||||||||||||||||||||||||||||||
| 650 | 1 | ▶ | $ok ||= exists $self->[2]{ $_ } foreach @_; | ||||||||||||||||||||||||||||||||||||||||
|
Condition66%2/3
$ok ||= exists $self->[2]{$_}
MC/DC0%0/2
$ok ||= exists $self->[2]{$_}
$ok
exists $self->[2]{$_}
Truth table66%2/3
A ||= B
A= $okB= exists $self->[2]{$_}
| |||||||||||||||||||||||||||||||||||||||||||
| 651 | 1 | return $ok; | |||||||||||||||||||||||||||||||||||||||||
| 652 | } | ||||||||||||||||||||||||||||||||||||||||||
| 653 | |||||||||||||||||||||||||||||||||||||||||||
| 654 | =head2 $buildcfg->args_eq( $args ) | ||||||||||||||||||||||||||||||||||||||||||
| 655 | |||||||||||||||||||||||||||||||||||||||||||
| 656 | C<args_eq()> takes a string of config arguments and returns true if | ||||||||||||||||||||||||||||||||||||||||||
| 657 | C<$self> has exactly the same args as the C<$args> has. | ||||||||||||||||||||||||||||||||||||||||||
| 658 | |||||||||||||||||||||||||||||||||||||||||||
| 659 | There is the small matter of default_args (dfopts) kept as a Class | ||||||||||||||||||||||||||||||||||||||||||
| 660 | variable in L<Test::Smoke::BuildCFG>! | ||||||||||||||||||||||||||||||||||||||||||
| 661 | |||||||||||||||||||||||||||||||||||||||||||
| 662 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 663 | |||||||||||||||||||||||||||||||||||||||||||
| 664 | 17 | ▶ | sub args_eq { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
args_eq: called CC=5 SCAR=16.9
| |||||||||||||||||||||||||||||||||||||||||||
| 665 | 17 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 666 | 17 | my $args = shift; | |||||||||||||||||||||||||||||||||||||||||
| 667 | |||||||||||||||||||||||||||||||||||||||||||
| 668 | my $default_args = join "|", sort { | ||||||||||||||||||||||||||||||||||||||||||
| 669 | 0 | length($b) <=> length($a) | |||||||||||||||||||||||||||||||||||||||||
| 670 | } quotewords( '\s+', 1, Test::Smoke::BuildCFG->config( 'dfopts' ) ); | ||||||||||||||||||||||||||||||||||||||||||
| 671 | |||||||||||||||||||||||||||||||||||||||||||
| 672 | 26 | my %copy = map { ( $_ => undef ) } | |||||||||||||||||||||||||||||||||||||||||
| 673 | 17 | grep !/$default_args/ => keys %{ $self->[2] }; | |||||||||||||||||||||||||||||||||||||||||
| 674 | 17 | my @s_args = grep !/$default_args/ => quotewords( '\s+', 1, $args ); | |||||||||||||||||||||||||||||||||||||||||
| 675 | 17 | my @left; | |||||||||||||||||||||||||||||||||||||||||
| 676 | 17 | ▶ | while ( my $option = pop @s_args ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 677 | 26 | ▶ | if ( exists $copy{ $option } ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 678 | 26 | delete $copy{ $option }; | |||||||||||||||||||||||||||||||||||||||||
| 679 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 680 | 0 | push @left, $option; | |||||||||||||||||||||||||||||||||||||||||
| 681 | } | ||||||||||||||||||||||||||||||||||||||||||
| 682 | } | ||||||||||||||||||||||||||||||||||||||||||
| 683 | 17 | ▶ | return (@left || keys %copy) ? 0 : 1; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
@left or keys %copy
MC/DC0%0/2
@left or keys %copy
@left
keys %copy
Truth table33%1/3
A or B
A= @leftB= keys %copy
| |||||||||||||||||||||||||||||||||||||||||||
| 684 | } | ||||||||||||||||||||||||||||||||||||||||||
| 685 | |||||||||||||||||||||||||||||||||||||||||||
| 686 | =head2 $config->rm_arg( $arg[,..] ) | ||||||||||||||||||||||||||||||||||||||||||
| 687 | |||||||||||||||||||||||||||||||||||||||||||
| 688 | Simply remove the argument(s) from the list and recreate the arguments | ||||||||||||||||||||||||||||||||||||||||||
| 689 | line. | ||||||||||||||||||||||||||||||||||||||||||
| 690 | |||||||||||||||||||||||||||||||||||||||||||
| 691 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 692 | |||||||||||||||||||||||||||||||||||||||||||
| 693 | 170 | ▶ | sub rm_arg { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
rm_arg: called CC=4 SCAR=13.9
| |||||||||||||||||||||||||||||||||||||||||||
| 694 | 170 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 695 | |||||||||||||||||||||||||||||||||||||||||||
| 696 | 170 | foreach my $arg ( @_ ) { | |||||||||||||||||||||||||||||||||||||||||
| 697 | 138 | ▶ | exists $self->[2]{ $arg } and delete $self->[2]{ $arg }; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 698 | } | ||||||||||||||||||||||||||||||||||||||||||
| 699 | $self->[0] = join( " ", sort { | ||||||||||||||||||||||||||||||||||||||||||
| 700 | 152 | $self->[2]{ $a } <=> $self->[2]{ $b } | |||||||||||||||||||||||||||||||||||||||||
| 701 | 170 | ▶ | } keys %{ $self->[2] } ) || ""; | ||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
join(' ', (sort {$self->[2]{$a} <=> $self->[2]{$b};} keys %{$$self[2];})) || ''
MC/DC100%1/1
join(' ', (sort {$self->[2]{$a} <=> $self->[2]{$b};} keys %{$$self[2];})) || ''
join(' ', (sort {$self->[2]{$a} <=> $self->[2]{$b};} keys %{$$self[2];}))
Truth table100%2/2
A
A= join(' ', (sort {$self->[2]{$a} <=> $self->[2]{$b};} keys %{$$self[2];}))
| |||||||||||||||||||||||||||||||||||||||||||
| 702 | } | ||||||||||||||||||||||||||||||||||||||||||
| 703 | |||||||||||||||||||||||||||||||||||||||||||
| 704 | =head2 $config->vms | ||||||||||||||||||||||||||||||||||||||||||
| 705 | |||||||||||||||||||||||||||||||||||||||||||
| 706 | Redo the the commandline switches in a VMSish way. | ||||||||||||||||||||||||||||||||||||||||||
| 707 | |||||||||||||||||||||||||||||||||||||||||||
| 708 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 709 | |||||||||||||||||||||||||||||||||||||||||||
| 710 | 1 | ▶ | sub vms { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
vms: called CC=2 SCAR=7.0
| |||||||||||||||||||||||||||||||||||||||||||
| 711 | 1 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 712 | |||||||||||||||||||||||||||||||||||||||||||
| 713 | return join( " ", map { | ||||||||||||||||||||||||||||||||||||||||||
| 714 | 2 | tr/"'//d; | |||||||||||||||||||||||||||||||||||||||||
| 715 | 2 | s/^-//; | |||||||||||||||||||||||||||||||||||||||||
| 716 | 2 | qq/-"$_"/; | |||||||||||||||||||||||||||||||||||||||||
| 717 | } sort { | ||||||||||||||||||||||||||||||||||||||||||
| 718 | 1 | $self->[2]{ $a } <=> $self->[2]{ $b } | |||||||||||||||||||||||||||||||||||||||||
| 719 | 1 | ▶ | } keys %{ $self->[2] } ) || ""; | ||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
join(' ', map({tr/"'//d;
s/^-//;
qq[-"$_"];} (sort {$self->[2]{$a} <=> $self->[2]{$b};} keys %{$$self[2];}))) || ''
MC/DC0%0/1
join(' ', map({tr/"'//d;
s/^-//;
qq[-"$_"];} (sort {$self->[2]{$a} <=> $self->[2]{$b};} keys %{$$self[2];}))) || ''
join(' ', map({tr/"'//d;
s/^-//;
qq[-"$_"];} (sort {$self->[2]{$a} <=> $self->[2]{$b};} keys %{$$self[2];})))
Truth table50%1/2
A
A= join(' ', map({tr/"'//d;
s/^-//;
qq[-"$_"];} (sort {$self->[2]{$a} <=> $self->[2]{$b};} keys %{$$self[2];})))
| |||||||||||||||||||||||||||||||||||||||||||
| 720 | } | ||||||||||||||||||||||||||||||||||||||||||
| 721 | |||||||||||||||||||||||||||||||||||||||||||
| 722 | 15 | 1; | |||||||||||||||||||||||||||||||||||||||||
| 723 | |||||||||||||||||||||||||||||||||||||||||||
| 724 | =head1 SEE ALSO | ||||||||||||||||||||||||||||||||||||||||||
| 725 | |||||||||||||||||||||||||||||||||||||||||||
| 726 | L<Test::Smoke::Smoker>, L<Test::Smoke::Syncer::Policy> | ||||||||||||||||||||||||||||||||||||||||||
| 727 | |||||||||||||||||||||||||||||||||||||||||||
| 728 | =head1 COPYRIGHT | ||||||||||||||||||||||||||||||||||||||||||
| 729 | |||||||||||||||||||||||||||||||||||||||||||
| 730 | (c) 2002-2003, All rights reserved. | ||||||||||||||||||||||||||||||||||||||||||
| 731 | |||||||||||||||||||||||||||||||||||||||||||
| 732 | * Abe Timmerman <abeltje@cpan.org> | ||||||||||||||||||||||||||||||||||||||||||
| 733 | |||||||||||||||||||||||||||||||||||||||||||
| 734 | This library is free software; you can redistribute it and/or modify | ||||||||||||||||||||||||||||||||||||||||||
| 735 | it under the same terms as Perl itself. | ||||||||||||||||||||||||||||||||||||||||||
| 736 | |||||||||||||||||||||||||||||||||||||||||||
| 737 | See: | ||||||||||||||||||||||||||||||||||||||||||
| 738 | |||||||||||||||||||||||||||||||||||||||||||
| 739 | =over 4 | ||||||||||||||||||||||||||||||||||||||||||
| 740 | |||||||||||||||||||||||||||||||||||||||||||
| 741 | =item * http://www.perl.com/perl/misc/Artistic.html | ||||||||||||||||||||||||||||||||||||||||||
| 742 | |||||||||||||||||||||||||||||||||||||||||||
| 743 | =item * http://www.gnu.org/copyleft/gpl.html | ||||||||||||||||||||||||||||||||||||||||||
| 744 | |||||||||||||||||||||||||||||||||||||||||||
| 745 | =back | ||||||||||||||||||||||||||||||||||||||||||
| 746 | |||||||||||||||||||||||||||||||||||||||||||
| 747 | This program is distributed in the hope that it will be useful, | ||||||||||||||||||||||||||||||||||||||||||
| 748 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||||||||||||||||||||||||||||||||||||||||||
| 749 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | ||||||||||||||||||||||||||||||||||||||||||
| 750 | |||||||||||||||||||||||||||||||||||||||||||
| 751 | =cut | ||||||||||||||||||||||||||||||||||||||||||