Stateful PerlIO implemented [Was: [perl #22261] Was: Unrecognised BOM...]
[p5sagit/p5-mst-13.2.git] / lib / ExtUtils / t / Install.t
CommitLineData
479d2113 1#!/usr/bin/perl -w
2
3# Test ExtUtils::Install.
4
5BEGIN {
6 if( $ENV{PERL_CORE} ) {
50192506 7 @INC = ('../../lib', '../lib', 'lib');
479d2113 8 }
9 else {
10 unshift @INC, 't/lib';
11 }
12}
13chdir 't';
14
15use strict;
16use TieOut;
17use File::Path;
18use File::Spec;
19
ab00ffcd 20use Test::More tests => 21;
479d2113 21
22BEGIN { use_ok('ExtUtils::Install') }
23
24# Check exports.
25foreach my $func (qw(install uninstall pm_to_blib install_default)) {
26 can_ok(__PACKAGE__, $func);
27}
28
29
30chdir 'Big-Dummy';
31
32my $stdout = tie *STDOUT, 'TieOut';
33pm_to_blib( { 'lib/Big/Dummy.pm' => 'blib/lib/Big/Dummy.pm' },
34 'blib/lib/auto'
35 );
36ok( -d 'blib/lib', 'pm_to_blib created blib dir' );
37ok( -r 'blib/lib/Big/Dummy.pm', ' copied .pm file' );
38ok( -r 'blib/lib/auto', ' created autosplit dir' );
39is( $stdout->read, "cp lib/Big/Dummy.pm blib/lib/Big/Dummy.pm\n" );
40
41pm_to_blib( { 'lib/Big/Dummy.pm' => 'blib/lib/Big/Dummy.pm' },
42 'blib/lib/auto'
43 );
44ok( -d 'blib/lib', 'second run, blib dir still there' );
45ok( -r 'blib/lib/Big/Dummy.pm', ' .pm file still there' );
46ok( -r 'blib/lib/auto', ' autosplit still there' );
47is( $stdout->read, "Skip blib/lib/Big/Dummy.pm (unchanged)\n" );
48
ab00ffcd 49install( { 'blib/lib' => 'install-test/lib/perl',
50 read => 'install-test/packlist',
51 write => 'install-test/packlist'
52 },
53 0, 1);
54ok( ! -d 'install-test/lib/perl', 'install made dir - dry run' );
55ok( ! -r 'install-test/lib/perl/Big/Dummy.pm', ' .pm file installed - dry run' );
56ok( ! -r 'install-test/packlist', ' packlist exists - dry run' );
479d2113 57
58install( { 'blib/lib' => 'install-test/lib/perl',
59 read => 'install-test/packlist',
60 write => 'install-test/packlist'
61 } );
62ok( -d 'install-test/lib/perl', 'install made dir' );
63ok( -r 'install-test/lib/perl/Big/Dummy.pm', ' .pm file installed' );
64ok( -r 'install-test/packlist', ' packlist exists' );
65
66open(PACKLIST, 'install-test/packlist' );
67my %packlist = map { chomp; ($_ => 1) } <PACKLIST>;
68close PACKLIST;
69
70# On case-insensitive filesystems (ie. VMS), the keys of the packlist might
71# be lowercase. :(
72my $native_dummy = File::Spec->catfile(qw(install-test lib perl Big Dummy.pm));
73is( keys %packlist, 1 );
74is( lc((keys %packlist)[0]), lc $native_dummy, 'packlist written' );
75
76END { rmtree 'blib' }