ExtUtils::MakeMaker 6.55_02
[p5sagit/p5-mst-13.2.git] / lib / ExtUtils / t / arch_check.t
CommitLineData
5bdf71cc 1#!/usr/bin/perl -w
2
e39d7803 3BEGIN {
4 if ($ENV{PERL_CORE}) {
5 chdir 't' if -d 't';
6 @INC = qw(../lib lib);
7 }
8}
9
5bdf71cc 10use strict;
11use lib 't/lib';
12
13use TieOut;
14use Test::More 'no_plan';
15
16use Config;
17use ExtUtils::MakeMaker;
18
19ok( my $stdout = tie *STDOUT, 'TieOut' );
20
21# Create a normalized MM object to test with
22my $mm = bless {}, "MM";
23$mm->{PERL_SRC} = 0;
24$mm->{UNINSTALLED_PERL} = 0;
25
26my $rel2abs = sub { $mm->rel2abs($mm->catfile(@_)) };
27
28ok $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
42Your perl and your Config.pm seem to have different ideas about the
43architecture they are running on.
44Perl thinks: [arch1]
45Config says: [$Config{archname}]
46This may or may not cause problems. Please check your installation of perl
47if you have problems building this extension.
48};
49
50}
51
52
53# Different file path separators [rt.cpan.org 46416]
54SKIP: {
c0956255 55 require File::Spec;
56 skip "Win32 test", 1 unless File::Spec->isa("File::Spec::Win32");
57
5bdf71cc 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{
c0956255 67 # Clear our log
68 $stdout->read;
69
5bdf71cc 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}