summaryrefslogtreecommitdiff
path: root/lib/ExtUtils/t/arch_check.t
blob: a4fe88b0bacefd0460032d8a0b45504c05b147a5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
#!/usr/bin/perl -w

BEGIN {
    if ($ENV{PERL_CORE}) {
        chdir 't' if -d 't';
        @INC = qw(../lib lib);
    }
}

use strict;
use lib 't/lib';

use TieOut;
use Test::More 'no_plan';

use Config;
use ExtUtils::MakeMaker;

ok( my $stdout = tie *STDOUT, 'TieOut' );    

# Create a normalized MM object to test with
my $mm = bless {}, "MM";
$mm->{PERL_SRC} = 0;
$mm->{UNINSTALLED_PERL} = 0;

my $rel2abs = sub { $mm->rel2abs($mm->catfile(@_)) };

ok $mm->arch_check(
    $rel2abs->(qw(. t testdata reallylongdirectoryname arch1 Config.pm)),
    $rel2abs->(qw(. t testdata reallylongdirectoryname arch1 Config.pm)),
);


# Different architecures.
{
    ok !$mm->arch_check(
        $rel2abs->(qw(. t testdata reallylongdirectoryname arch1 Config.pm)),
        $rel2abs->(qw(. t testdata reallylongdirectoryname arch2 Config.pm)),
    );

    like $stdout->read, qr{\Q
Your perl and your Config.pm seem to have different ideas about the 
architecture they are running on.
Perl thinks: [arch1]
Config says: [$Config{archname}]
This may or may not cause problems. Please check your installation of perl 
if you have problems building this extension.
};

}


# Different file path separators [rt.cpan.org 46416]
SKIP: {
    skip "Can't load File::Spec::Win32" unless eval "require File::Spec::Win32";
    local @File::Spec::ISA = qw(File::Spec::Win32);
    ok $mm->arch_check(
        "/_64/perl1004/lib/Config.pm",
        '\\_64\\perl1004\\lib\\Config.pm',
    );
}


# PERL_SRC is set, no check is done
{
    local $mm->{PERL_SRC} = 1;
    ok $mm->arch_check(
      $rel2abs->(qw(. t testdata reallylongdirectoryname arch1 Config.pm)),
      $rel2abs->(qw(. t testdata reallylongdirectoryname arch2 Config.pm)),
    );

    is $stdout->read, '';
}


# UNINSTALLED_PERL is set, no message is sent
{
    local $mm->{UNINSTALLED_PERL} = 1;
    ok !$mm->arch_check(
      $rel2abs->(qw(. t testdata reallylongdirectoryname arch1 Config.pm)),
      $rel2abs->(qw(. t testdata reallylongdirectoryname arch2 Config.pm)),
    );

    like $stdout->read, qr{^Have .*\nWant .*$};
}