67cfa174ee96dddf527b1980570d0da00a140dff
[p5sagit/local-lib.git] / t / install.t
1 use strict;
2 use warnings;
3 use Test::More;
4 BEGIN { plan skip_all => "Install Capture::Tiny to test installation"
5   unless eval { require Capture::Tiny; 1 } }
6 use Capture::Tiny qw(capture);
7 use File::Temp qw(tempdir);
8 use File::Spec;
9 use Cwd;
10 use Config;
11
12 plan tests => 2;
13
14 my $dir = tempdir('test_local_lib-XXXXX', DIR => Cwd::abs_path('t'), CLEANUP => 1);
15
16 use local::lib ();
17 local::lib->import($dir);
18
19 my $orig_dir = cwd;
20 SKIP: for my $dist_type (qw(EUMM MB)) {
21   chdir File::Spec->catdir($orig_dir, qw(t dist), $dist_type);
22   if ($dist_type eq 'EUMM') {
23     my ($stdout, $stderr) = capture { eval { 
24       system($^X, 'Makefile.PL') && die "Makefile.PL failed";
25       system($Config{make}, 'install') && die "$Config{make} install failed";
26     } };
27     diag $stdout, $stderr if $@;
28   } else {
29     my ($stdout, $stderr) = capture { eval {
30       system($^X, 'Build.PL') && die "Build.PL failed";
31       system($^X, 'Build', 'install') && die "Build install failed";
32     } };
33     diag $stdout, $stderr if $@;
34   }
35   ok(
36     -e File::Spec->catfile(
37       $dir, qw(lib perl5), "$dist_type.pm",
38     ),
39     "$dist_type.pm installed into the correct location",
40   );
41 }