blib/lib/Devel/FakeOSName.pm

filter: Statementstmt 100% 24 / 24 Branchbran 50.0% 3 / 6 Conditioncond 33.3% 1 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 100% 5 / 5 Podpod n/a totaltotal 82.5% 33 / 40 CC 5 SCAR 9.9
CC
5
Cov
85%
__ANON__
4.3
import
2.0
BEGIN
1.0
CRAP 2.7
↑ Summary
1 package Devel::FakeOSName;
2  
3 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 1 require Config;
7  
8 1 $Devel::FakeOSName::VERSION = '0.01';
9  
10 {
11 1 my $orig_STORE = *Config::STORE{CODE};
12 1 undef &Config::STORE;
13 1 ▶ *Config::STORE = sub {
Subroutine __ANON__: called CC=4 SCAR=14.6
14 1 ▶ goto &$orig_STORE unless defined $_[1] && $_[1] eq 'osname';
Branch: 1 branch
BranchTrueFalseTotal
unless defined $_[1] and $_[1] eq "osname" 0 1 1
Condition33%1/3
defined $_[1] and $_[1] eq "osname"
!ll&&!rl&&r
001
MC/DC0%0/2
defined $_[1] and $_[1] eq "osname"
defined $_[1] $_[1] eq "osname"
Truth table33%1/3
A and B
A= defined $_[1]B= $_[1] eq "osname"
ABresult
0X0
100
111
15 1 ▶ die "an osname string must be passed" unless defined $_[2];
Branch: 1 branch
BranchTrueFalseTotal
unless defined $_[2] 0 1 1
16  
17 # modify it once and immediately reset to the normal read-only state
18 1 $_[0]->{osname} = $_[2];
19 #undef &Config::STORE; # can't undef an active sub
20 1 ▶ no warnings 'redefine';
Subroutine BEGIN: called CC=1 SCAR=0.0
21 1 *Config::STORE = $orig_STORE;
22 1 return $_[2];
23 1 };
24 }
25  
26 1 ▶sub import {
Subroutine import: called CC=2 SCAR=7.1
27 1 my($package, $os) = @_;
28  
29 1 ▶ return unless $os;
Branch: 1 branch
BranchTrueFalseTotal
unless $os 0 1 1
30  
31 # read/write
32 1 $^O = $Config::Config{osname} = $os;
33 }
34  
35  
36 1 1;
37  
38 =pod
39  
40 =head1 NAME
41  
42 Devel::FakeOSName - Make Perl think it runs on a different OS
43  
44 =head1 SYNOPSIS
45  
46 # build us Makefile for aix
47 perl -MDevel::FakeOSName=aix Makefile.PL
48  
49 =head1 DESCRIPTION
50  
51 Sometimes your code includes code specific to an OS that you don't
52 have an access to, but you want to see what happens if it was to run
53 on that other OS.
54  
55 Currently mostly useful for looking at generated Makefiles. Needs much
56 more work to be really useful.
57  
58 =head1 TODO
59  
60 Currently the module just modifies $^O and $Config{osname}. Could
61 probably somehow supply overrides for other %Config::Config values and
62 ExtUtils::Embed.
63  
64 Patches are welcome.
65  
66 =cut
67  
↑ Summary