~ubuntu-branches/ubuntu/trusty/libtest-version-perl/trusty-proposed

« back to all changes in this revision

Viewing changes to t/000-report-versions-tiny.t

  • Committer: Package Import Robot
  • Author(s): gregor herrmann
  • Date: 2013-11-24 16:46:18 UTC
  • Revision ID: package-import@ubuntu.com-20131124164618-0lklop9yf8nju25b
Tags: upstream-1.002004
ImportĀ upstreamĀ versionĀ 1.002004

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
use strict;
 
2
use warnings;
 
3
use Test::More 0.88;
 
4
# This is a relatively nice way to avoid Test::NoWarnings breaking our
 
5
# expectations by adding extra tests, without using no_plan.  It also helps
 
6
# avoid any other test module that feels introducing random tests, or even
 
7
# test plans, is a nice idea.
 
8
our $success = 0;
 
9
END { $success && done_testing; }
 
10
 
 
11
# List our own version used to generate this
 
12
my $v = "\nGenerated by Dist::Zilla::Plugin::ReportVersions::Tiny v1.10\n";
 
13
 
 
14
eval {                     # no excuses!
 
15
    # report our Perl details
 
16
    my $want = '5.006';
 
17
    $v .= "perl: $] (wanted $want) on $^O from $^X\n\n";
 
18
};
 
19
defined($@) and diag("$@");
 
20
 
 
21
# Now, our module version dependencies:
 
22
sub pmver {
 
23
    my ($module, $wanted) = @_;
 
24
    $wanted = " (want $wanted)";
 
25
    my $pmver;
 
26
    eval "require $module;";
 
27
    if ($@) {
 
28
        if ($@ =~ m/Can't locate .* in \@INC/) {
 
29
            $pmver = 'module not found.';
 
30
        } else {
 
31
            diag("${module}: $@");
 
32
            $pmver = 'died during require.';
 
33
        }
 
34
    } else {
 
35
        my $version;
 
36
        eval { $version = $module->VERSION; };
 
37
        if ($@) {
 
38
            diag("${module}: $@");
 
39
            $pmver = 'died during VERSION check.';
 
40
        } elsif (defined $version) {
 
41
            $pmver = "$version";
 
42
        } else {
 
43
            $pmver = '<undef>';
 
44
        }
 
45
    }
 
46
 
 
47
    # So, we should be good, right?
 
48
    return sprintf('%-45s => %-10s%-15s%s', $module, $pmver, $wanted, "\n");
 
49
}
 
50
 
 
51
eval { $v .= pmver('Carp','any version') };
 
52
eval { $v .= pmver('Exporter','any version') };
 
53
eval { $v .= pmver('ExtUtils::MakeMaker','6.30') };
 
54
eval { $v .= pmver('File::Find::Rule::Perl','any version') };
 
55
eval { $v .= pmver('File::Spec','any version') };
 
56
eval { $v .= pmver('IO::Handle','any version') };
 
57
eval { $v .= pmver('IPC::Open3','any version') };
 
58
eval { $v .= pmver('Module::Metadata','any version') };
 
59
eval { $v .= pmver('Test::Builder','any version') };
 
60
eval { $v .= pmver('Test::Exception','any version') };
 
61
eval { $v .= pmver('Test::More','0.88') };
 
62
eval { $v .= pmver('Test::Tester','any version') };
 
63
eval { $v .= pmver('parent','any version') };
 
64
eval { $v .= pmver('strict','any version') };
 
65
eval { $v .= pmver('version','0.86') };
 
66
eval { $v .= pmver('warnings','any version') };
 
67
 
 
68
 
 
69
# All done.
 
70
$v .= <<'EOT';
 
71
 
 
72
Thanks for using my code.  I hope it works for you.
 
73
If not, please try and include this output in the bug report.
 
74
That will help me reproduce the issue and solve your problem.
 
75
 
 
76
EOT
 
77
 
 
78
diag($v);
 
79
ok(1, "we really didn't test anything, just reporting data");
 
80
$success = 1;
 
81
 
 
82
# Work around another nasty module on CPAN. :/
 
83
no warnings 'once';
 
84
$Template::Test::NO_FLUSH = 1;
 
85
exit 0;