Commit | Line | Data |
be160790 |
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 } } |
93b577b5 |
6 | use Capture::Tiny qw(capture_merged); |
be160790 |
7 | use File::Spec; |
93b577b5 |
8 | use File::Path qw(mkpath); |
be160790 |
9 | use Cwd; |
10 | use Config; |
11 | |
4f7dfe32 |
12 | use lib 't/lib'; use TempDir; |
13 | |
93b577b5 |
14 | use local::lib (); |
be160790 |
15 | |
93b577b5 |
16 | my @dirs = ( |
17 | 'plain', |
18 | 'with space', |
19 | 'with\backslash', |
20 | 'with space\and-bs', |
21 | ); |
be160790 |
22 | |
93b577b5 |
23 | my %dist_types = ( |
24 | EUMM => sub { |
25 | system($^X, 'Makefile.PL') && die "Makefile.PL failed"; |
26 | system($Config{make}, 'install') && die "$Config{make} install failed"; |
27 | }, |
28 | MB => sub { |
29 | system($^X, 'Build.PL') && die "Build.PL failed"; |
30 | system($^X, 'Build', 'install') && die "Build install failed"; |
31 | }, |
32 | ); |
33 | |
34 | plan tests => @dirs * keys(%dist_types) * 2; |
be160790 |
35 | |
36 | my $orig_dir = cwd; |
93b577b5 |
37 | for my $dir_base (@dirs) { |
38 | for my $dist_type (sort keys %dist_types) { |
39 | chdir $orig_dir; |
40 | my $temp = mk_temp_dir('test_local_lib-XXXXX'); |
41 | my $ll_dir = "$dist_type-$dir_base"; |
42 | mkpath(my $ll = "$temp/$ll_dir"); |
43 | local::lib->import($ll); |
44 | |
45 | chdir File::Spec->catdir($orig_dir, qw(t dist), $dist_type); |
46 | my $output = capture_merged { eval { |
47 | $dist_types{$dist_type}->(); |
be160790 |
48 | } }; |
93b577b5 |
49 | is $@, '', "installed $dist_type into '$ll_dir'" |
50 | or diag $output; |
51 | |
52 | my $dest_dir = local::lib->install_base_perl_path($ll); |
53 | my $file = File::Spec->catfile($dest_dir, "$dist_type.pm"); |
54 | (my $short_file = $file) =~ s/^\Q$ll/$ll_dir/; |
55 | ok( |
56 | -e $file, |
57 | "$dist_type - $dir_base - $dist_type.pm installed as '$short_file'", |
58 | ) or diag 'Files in ' . $dest_dir . ":\n", join("\n", do { |
59 | my $dh; |
60 | (opendir $dh, $dest_dir) ? readdir $dh : "doesn't exist"; |
61 | }); |
be160790 |
62 | } |
be160790 |
63 | } |