1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69
|
#!perl -w
use strict;
use Test::More;
use FindBin qw($Bin);
use File::Spec;
use Config;
use File::Find;
use File::Copy qw(copy);
my $dist_dir = File::Spec->join($Bin, '..', 'example');
chdir $dist_dir or die "Cannot chdir to $dist_dir: $!";
# workaround subdir auto-building :(
copy "MyMakefile.PL" => "Makefile.PL";
END {
unlink 'Makefile.PL';
}
my $make = $Config{make};
my $out;
ok($out = `$^X Makefile.PL`, "$^X Makefile.PL");
is $?, 0, '... success' or diag $out;
ok($out = `$make`, $make);
is $?, 0, '... success' or diag $out;
ok($out = `$make test`, "$make test");
is $?, 0, '... success' or diag $out;
ok -e 'ppport.h', 'ppport.h exists';
my %h_files;
find sub{
$h_files{$_} = File::Spec->canonpath($File::Find::name) if / \.h \z/xms;
}, qw(blib);
is scalar(keys %h_files), 3, 'two head files are installed';
ok exists $h_files{'foo.h'}, 'foo.h exists';
ok exists $h_files{'bar.h'}, 'bar.h exists';
ok exists $h_files{'baz.h'}, 'baz.h exists';
sub f2rx{
my $f = quotemeta( File::Spec->join(@_) );
return qr/$f/xmsi;
}
like $h_files{'foo.h'}, f2rx(qw(Foo foo.h));
like $h_files{'bar.h'}, f2rx(qw(Foo bar.h));
like $h_files{'baz.h'}, f2rx(qw(Foo foo baz.h));
my $Makefile = do{
local *MF;
open MF, 'Makefile' or die $!;
local $/;
<MF>;
};
like $Makefile, qr/\b foo_is_ok \b/xms, 'Makefile includes foo_is_ok()';
like $Makefile, qr/\b bar_is_ok \b/xms, 'Makefile includes bar_is_ok()';
ok scalar `$make realclean`, "$make realclean";
is $?, 0, '... success';
done_testing;
|