| 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
Condition33%1/3
defined $_[1] and $_[1] eq "osname"
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"
| |||||||||||||||||||||||||||||
| 15 | 1 | ▶ | die "an osname string must be passed" unless defined $_[2]; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||
| 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 | |||||||||||||||||||||||||||||