~ubuntu-branches/ubuntu/trusty/libyaml-tiny-perl/trusty-proposed

« back to all changes in this revision

Viewing changes to t/00-report-prereqs.t

  • Committer: Package Import Robot
  • Author(s): gregor herrmann
  • Date: 2013-10-05 16:34:12 UTC
  • mfrom: (1.2.12)
  • Revision ID: package-import@ubuntu.com-20131005163412-1zjgne628pa7n8k9
Tags: 1.56-1
* Team upload.
* New upstream release.
* Update build dependencies.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#!perl
 
2
 
 
3
use strict;
 
4
use warnings;
 
5
 
 
6
use Test::More tests => 1;
 
7
 
 
8
use ExtUtils::MakeMaker;
 
9
use File::Spec::Functions;
 
10
use List::Util qw/max/;
 
11
 
 
12
my @modules = qw(
 
13
  Carp
 
14
  Exporter
 
15
  ExtUtils::MakeMaker
 
16
  File::Spec
 
17
  File::Spec::Functions
 
18
  IO::Handle
 
19
  IPC::Open3
 
20
  List::Util
 
21
  Module::Build::Tiny
 
22
  Scalar::Util
 
23
  Test::More
 
24
  perl
 
25
  strict
 
26
  vars
 
27
  warnings
 
28
);
 
29
 
 
30
# replace modules with dynamic results from MYMETA.json if we can
 
31
# (hide CPAN::Meta from prereq scanner)
 
32
my $cpan_meta = "CPAN::Meta";
 
33
if ( -f "MYMETA.json" && eval "require $cpan_meta" ) { ## no critic
 
34
  if ( my $meta = eval { CPAN::Meta->load_file("MYMETA.json") } ) {
 
35
    my $prereqs = $meta->prereqs;
 
36
    delete $prereqs->{develop};
 
37
    my %uniq = map {$_ => 1} map { keys %$_ } map { values %$_ } values %$prereqs;
 
38
    $uniq{$_} = 1 for @modules; # don't lose any static ones
 
39
    @modules = sort keys %uniq;
 
40
  }
 
41
}
 
42
 
 
43
my @reports = [qw/Version Module/];
 
44
 
 
45
for my $mod ( @modules ) {
 
46
  next if $mod eq 'perl';
 
47
  my $file = $mod;
 
48
  $file =~ s{::}{/}g;
 
49
  $file .= ".pm";
 
50
  my ($prefix) = grep { -e catfile($_, $file) } @INC;
 
51
  if ( $prefix ) {
 
52
    my $ver = MM->parse_version( catfile($prefix, $file) );
 
53
    $ver = "undef" unless defined $ver; # Newer MM should do this anyway
 
54
    push @reports, [$ver, $mod];
 
55
  }
 
56
  else {
 
57
    push @reports, ["missing", $mod];
 
58
  }
 
59
}
 
60
 
 
61
if ( @reports ) {
 
62
  my $vl = max map { length $_->[0] } @reports;
 
63
  my $ml = max map { length $_->[1] } @reports;
 
64
  splice @reports, 1, 0, ["-" x $vl, "-" x $ml];
 
65
  diag "Prerequisite Report:\n", map {sprintf("  %*s %*s\n",$vl,$_->[0],-$ml,$_->[1])} @reports;
 
66
}
 
67
 
 
68
pass;
 
69
 
 
70
# vim: ts=2 sts=2 sw=2 et: