1Prereq(3) User Contributed Perl Documentation Prereq(3)
2
3
4
6 Test::Prereq - check if Makefile.PL has the right pre-requisites
7
9 # if you use Makefile.PL
10 use Test::More;
11 eval "use Test::Prereq";
12 plan skip_all => "Test::Prereq required to test dependencies" if $@;
13 prereq_ok();
14
15 # specify a perl version, test name, or module names to skip
16 prereq_ok( $version, $name, \@skip );
17
18 # if you use Module::Build
19 use Test::More;
20 eval "use Test::Prereq::Build";
21 plan skip_all => "Test::Prereq::Build required to test dependencies" if $@;
22 prereq_ok();
23
24 # or from the command line for a one-off check
25 perl -MTest::Prereq -eprereq_ok
26
28 The prereq_ok() function examines the modules it finds in blib/lib/,
29 blib/script, and the test files it finds in t/ (and test.pl). It
30 figures out which modules they use, skips the modules that are in the
31 Perl core, and compares the remaining list of modules to those in the
32 PREREQ_PM section of Makefile.PL.
33
34 If you use Module::Build instead, see Test::Prereq::Build instead.
35
36 Modules Test::Prereq can't find
37 Module::Info only tells Test::Prereq which modules you used, not which
38 distribution they came in. This can be a problem for things in
39 packages like libnet, libwww, Tk, and so on. At the moment Test::Prereq
40 asks CPAN.pm to expand anything in PREREQ_PM to see if one of the
41 distributions you explicity list contains the module you actually used.
42 This might fail in some cases. Please send me anything that does not
43 do what you think it should.
44
45 Test::Prereq only asks CPAN.pm for help if it needs it, since CPAN.pm
46 can be slow if it has to fetch things from the network. Once it fetches
47 the right things, it should be much faster.
48
49 Problem with Module::Info
50 Module::Info appears to do something weird if a file it analyzes does
51 not use (or require) any modules. You may get a message like
52
53 Can't locate object method "name" via package "B::NULL" at
54 /usr/perl5.8.0/lib/site_perl/5.8.0/B/Module/Info.pm line 176.
55
56 Also, if a file cannot compile, Module::Info dumps a lot of text to the
57 terminal. You probably want to bail out of testing if the files do not
58 compile, though.
59
60 Problem with CPANPLUS
61 CPANPLUS apparently does some weird things, and since it is still young
62 and not part of the Standard Library, Test::Prereq's tests do not do
63 the right thing under it (for some reason). Test::Prereq cheats by
64 ignoring CPANPLUS completely in the tests---at least until someone has
65 a better solution. If you do not like that, you can set
66 $EXCLUDE_CPANPLUS to a false value.
67
68 You should be able to do a 'make test' manually to make everything
69 work, though.
70
71 Warning about redefining ExtUtils::MakeMaker::WriteMakefile
72 Test::Prereq has its own version of ExtUtils::MakeMaker::WriteMakefile
73 so it can run the Makefile.PL and get the argument list of that
74 function. You may see warnings about this.
75
77 prereq_ok( [ VERSION, [ NAME [, SKIP_ARRAY] ] ] )
78 Tests Makefile.PL to ensure all non-core module dependencies are in
79 PREREQ_PM. If you haven't set a testing plan already, prereq_ok()
80 creates a plan of one test.
81
82 If you don't specify a version, prereq_ok assumes you want to
83 compare the list of prerequisite modules to version 5.008005.
84
85 Valid versions come from Module::CoreList (which uses $[).
86
87 #!/usr/bin/perl
88 use Module::CoreList;
89 print map "$_\n", sort keys %Module::CoreList::version;
90
91
92 5.00307
93 5.004
94 5.00405
95 5.005
96 5.00503
97 5.00504
98 5.006
99 5.006001
100 5.006002
101 5.007003
102 5.008
103 5.008001
104 5.008002
105 5.008003
106 5.008004
107 5.008005
108 5.009
109 5.009001
110
111 prereq_ok attempts to remove modules found in blib and libraries
112 found in t from the reported prerequisites.
113
114 The optional third argument is an array reference to a list of
115 names that prereq_ok should ignore. You might want to use this if
116 your tests do funny things with require.
117
119 * set up a couple fake module distributions to test
120
121 * warn about things that show up in PREREQ_PM unnecessarily
122
124 This source is in Github:
125
126 http://github.com/briandfoy/test-prereq
127
129 Many thanks to:
130
131 Andy Lester, Slavin Rezic, Randal Schwartz, Iain Truskett, Dylan Martin
132
134 brian d foy, "<bdfoy@cpan.org>"
135
137 Copyright 2002-2009, brian d foy, All rights reserved
138
139 This software is available under the same terms as perl.
140
141
142
143perl v5.10.1 2009-06-01 Prereq(3)