Fix random failures in CPANPLUS tests on Win32
[p5sagit/p5-mst-13.2.git] / lib / CPANPLUS / t / 21_CPANPLUS-Dist-No-Build.t
1 ### make sure we can find our conf.pl file
2 BEGIN { 
3     use FindBin; 
4     require "$FindBin::Bin/inc/conf.pl";
5 }
6
7 use strict;
8 use Test::More 'no_plan';
9
10 use CPANPLUS::Dist;
11 use CPANPLUS::Backend;
12 use CPANPLUS::Module::Fake;
13 use CPANPLUS::Module::Author::Fake;
14 use CPANPLUS::Internals::Constants;
15
16 my $Conf    = gimme_conf();
17 my $CB      = CPANPLUS::Backend->new( $Conf );
18
19 ### set the config so that we will ignore the build installer,
20 ### but prefer it anyway
21 {   CPANPLUS::Dist->_ignore_dist_types( INSTALLER_BUILD );
22     $Conf->set_conf( prefer_makefile => 0 );
23 }
24
25 my $Mod = $CB->module_tree( 'Foo::Bar::MB::NOXS' );
26
27 ok( $Mod,                   "Module object retrieved" );        
28 ok( not grep { $_ eq INSTALLER_BUILD } CPANPLUS::Dist->dist_types,
29                             "   Build installer not returned" );
30             
31 ### fetch the file first            
32 {   my $where = $Mod->fetch;
33     ok( -e $where,          "   Tarball '$where' exists" );
34 }
35     
36 ### extract it, silence warnings/messages    
37 {   local $CPANPLUS::Error::MSG_FH   = output_handle();    
38     local $CPANPLUS::Error::ERROR_FH = output_handle();
39
40     my $where = $Mod->extract;
41     ok( -e $where,          "   Tarball extracted to '$where'" );
42 }
43
44 ### check the installer type 
45 {   is( $Mod->status->installer_type, INSTALLER_MM, 
46                             "Proper installer type found" );
47
48     my $err = CPANPLUS::Error->stack_as_string;
49     like( $err, '/'.INSTALLER_MM.'/',
50                             "   Error mentions " . INSTALLER_MM );
51     like( $err, '/'.INSTALLER_BUILD.'/',
52                             "   Error mentions " . INSTALLER_BUILD );
53     like( $err, qr/but might not be able to install/,
54                             "   Error mentions install warning" );
55 }
56
57 END { 1 while unlink output_file()  }