ExtUtils::MakeMaker 6.55_02
[p5sagit/p5-mst-13.2.git] / lib / ExtUtils / t / arch_check.t
1 #!/usr/bin/perl -w
2
3 BEGIN {
4     if ($ENV{PERL_CORE}) {
5         chdir 't' if -d 't';
6         @INC = qw(../lib lib);
7     }
8 }
9
10 use strict;
11 use lib 't/lib';
12
13 use TieOut;
14 use Test::More 'no_plan';
15
16 use Config;
17 use ExtUtils::MakeMaker;
18
19 ok( my $stdout = tie *STDOUT, 'TieOut' );    
20
21 # Create a normalized MM object to test with
22 my $mm = bless {}, "MM";
23 $mm->{PERL_SRC} = 0;
24 $mm->{UNINSTALLED_PERL} = 0;
25
26 my $rel2abs = sub { $mm->rel2abs($mm->catfile(@_)) };
27
28 ok $mm->arch_check(
29     $rel2abs->(qw(. t testdata reallylongdirectoryname arch1 Config.pm)),
30     $rel2abs->(qw(. t testdata reallylongdirectoryname arch1 Config.pm)),
31 );
32
33
34 # Different architecures.
35 {
36     ok !$mm->arch_check(
37         $rel2abs->(qw(. t testdata reallylongdirectoryname arch1 Config.pm)),
38         $rel2abs->(qw(. t testdata reallylongdirectoryname arch2 Config.pm)),
39     );
40
41     like $stdout->read, qr{\Q
42 Your perl and your Config.pm seem to have different ideas about the 
43 architecture they are running on.
44 Perl thinks: [arch1]
45 Config says: [$Config{archname}]
46 This may or may not cause problems. Please check your installation of perl 
47 if you have problems building this extension.
48 };
49
50 }
51
52
53 # Different file path separators [rt.cpan.org 46416]
54 SKIP: {
55     require File::Spec;
56     skip "Win32 test", 1 unless File::Spec->isa("File::Spec::Win32");
57
58     ok $mm->arch_check(
59         "/_64/perl1004/lib/Config.pm",
60         '\\_64\\perl1004\\lib\\Config.pm',
61     );
62 }
63
64
65 # PERL_SRC is set, no check is done
66 {
67     # Clear our log
68     $stdout->read;
69
70     local $mm->{PERL_SRC} = 1;
71     ok $mm->arch_check(
72       $rel2abs->(qw(. t testdata reallylongdirectoryname arch1 Config.pm)),
73       $rel2abs->(qw(. t testdata reallylongdirectoryname arch2 Config.pm)),
74     );
75
76     is $stdout->read, '';
77 }
78
79
80 # UNINSTALLED_PERL is set, no message is sent
81 {
82     local $mm->{UNINSTALLED_PERL} = 1;
83     ok !$mm->arch_check(
84       $rel2abs->(qw(. t testdata reallylongdirectoryname arch1 Config.pm)),
85       $rel2abs->(qw(. t testdata reallylongdirectoryname arch2 Config.pm)),
86     );
87
88     like $stdout->read, qr{^Have .*\nWant .*$};
89 }