File Coverage

blib/lib/Module/Release/Prereq.pm
Criterion Covered Total %
statement 14 21 66.6
branch 1 4 25.0
condition 1 4 25.0
subroutine 5 6 83.3
pod 1 1 100.0
total 22 36 61.1


line stmt bran cond sub pod time code
1 1     1   33256 use v5.16;
  1         4  
2              
3             package Module::Release::Prereq;
4              
5 1     1   6 use strict;
  1         2  
  1         25  
6 1     1   5 use warnings;
  1         2  
  1         36  
7 1     1   4 use Exporter qw(import);
  1         2  
  1         438  
8              
9             our @EXPORT = qw( check_prereqs _get_prereq_ignore_list );
10              
11             our $VERSION = '2.128';
12              
13             =encoding utf8
14              
15             =head1 NAME
16              
17             Module::Release::Prereq - Check pre-requisites list in build file
18              
19             =head1 SYNOPSIS
20              
21             The release script automatically loads this module and checks your
22             prerequisite declaration against what you actually used in the
23             tests.
24              
25             =head1 DESCRIPTION
26              
27             =over 4
28              
29             =item check_prereqs
30              
31             Run `perl -MTest::Prereq -eprereq_ok`. If it doesn't see "^ok 1"
32             it dies.
33              
34             It looks in local_name to get the name of the distribution file.
35              
36             =cut
37              
38              
39             my %Prereq_modules = (
40             '' => 'Test::Prereq',
41             'Makefile.PL' => 'Test::Prereq',
42             'Build.PL' => 'Test::Prereq::Build',
43             );
44              
45             sub check_prereqs {
46 1     1 1 1114 my $prereqs_type = $_[0]->config->makefile_PL;
47 1   50     32 my $test_prereqs = $Prereq_modules{$prereqs_type // ''} || 'Test::Prereq';
48              
49 1 50       181 eval "require $test_prereqs; 1 " or
50             $_[0]->_die( "You need $test_prereqs to check prereqs" );
51              
52 0           $_[0]->_print( "Checking prereqs with $test_prereqs... " );
53              
54 0           my $perl = $_[0]->{perl};
55              
56 0           my @ignore = $_[0]->_get_prereq_ignore_list;
57              
58 0           my $messages = $_[0]->run(
59             qq|$perl -M$test_prereqs -e "prereq_ok( undef, undef, [ qw(@ignore) ] )"|
60             );
61              
62 0 0         $_[0]->_die( "Prereqs had a problem:\n$messages\n" )
63             unless $messages =~ m/^ok 1 - Prereq test/m;
64              
65 0           $_[0]->_print( "done\n" );
66             }
67              
68             sub _get_prereq_ignore_list {
69 0   0 0     my @ignore = split /\s+/, $_[0]->config->ignore_prereqs || '';
70             }
71              
72             =back
73              
74             =head1 SEE ALSO
75              
76             L
77              
78             =head1 SOURCE AVAILABILITY
79              
80             This source is in GitHub
81              
82             https://github.com/briandfoy/module-release
83              
84             =head1 AUTHOR
85              
86             brian d foy, C<< >>
87              
88             =head1 COPYRIGHT AND LICENSE
89              
90             Copyright © 2007-2021, brian d foy C<< >>. All rights reserved.
91              
92             This program is free software; you can redistribute it and/or modify
93             it under the Artistic License 2.0.
94              
95             =cut
96              
97             1;