1Test::Signature(3) User Contributed Perl Documentation Test::Signature(3)
2
3
4
6 Test::Signature - Automated SIGNATURE testing
7
9 # This is actually the t/0-signature.t file from this distribution.
10 use Test::More tests => 1;
11 use Test::Signature;
12
13 signature_ok();
14
16 "Test::Signature" verifies that the "Module::Signature" generated
17 signature of a module is correct.
18
20 "Module::Signature" allows you to verify that a distribution has not
21 been tampered with. "Test::Signature" lets that be tested as part of
22 the distribution's test suite.
23
24 By default, if "Module::Signature" is not installed then it will just
25 say so and not fail the test. That can be overridden though.
26
27 IMPORTANT: This is not a substitute for the users verifying the
28 distribution themselves. By the time this module is run, the users will
29 have already run your Makefile.PL or Build.PL scripts which could have
30 been compromised.
31
32 This module is more for ensuring you've updated your signature
33 appropriately before distributing, and for preventing accidental errors
34 during transmission or packaging.
35
37 "signature_ok" is exported by default. "signature_force_ok" must be
38 explicitly exported.
39
40 signature_ok()
41 This will test that the "Module::Signature" generated signature is
42 valid for the distribution. It can be given two optional parameters.
43 The first is a name for the test. The default is "Valid signature".
44 The second is whether a lack of "Module::Signature" should be regarded
45 as a failure. The default is 0 meaning 'no'.
46
47 # Test with defaults
48 signature_ok()
49 # Test with custom name
50 signature_ok( "Is the signature valid?" );
51 # Test with custom name and force C<Module::Signature> to exist
52 signature_ok( "Is the signature valid?", 1 );
53 # Test without custom name, but forcing
54 signature_ok( undef, 1 );
55
56 signature_force_ok()
57 This is equivalent to calling "signature_ok( $name, 1 )" but is more
58 readable.
59
60 # These are equivalent:
61 signature_force_ok( "Is our signature valid?" );
62 signature_ok( "Is our signature valid?", 1);
63
64 # These are equivalent:
65 signature_force_ok();
66 signature_ok( undef, 1 );
67
69 MANIFEST and MANIFEST.SKIP
70 It is imperative that your MANIFEST and MANIFEST.SKIP files be accurate
71 and complete. If you are using "ExtUtils::MakeMaker" and you do not
72 have a MANIFEST.SKIP file, then don't worry about the rest of this. If
73 you do have a MANIFEST.SKIP file, or you use "Module::Build", you must
74 read this.
75
76 Since the test is run at "make test" time, the distribution has been
77 made. Thus your MANIFEST.SKIP file should have the entries listed
78 below.
79
80 If you're using "ExtUtils::MakeMaker", you should have, at least:
81
82 #defaults
83 ^Makefile$
84 ^blib/
85 ^blibdirs$
86 ^pm_to_blib$
87
88 These entries are part of the default set provided by
89 "ExtUtils::Manifest", which is ignored if you provide your own
90 MANIFEST.SKIP file.
91
92 If you are using "Module::Build", there is no default MANIFEST.SKIP so
93 you must provide your own. It must, minimally, contain:
94
95 ^Build$
96 ^Makefile$
97 ^_build/
98 ^blib/
99
100 If you don't have the correct entries, "Module::Signature" will
101 complain that you have:
102
103 ==> MISMATCHED content between MANIFEST and distribution files! <==
104
105 You should note this during normal development testing anyway.
106
107 Use with Test::Prereq
108 "Test::Prereq" tends to get a bit particular about modules. If you're
109 using the force option with "Test::Signature" then you will have to
110 specify that you expect "Module::Signature" as a prerequisite.
111 "Test::Signature" will not have it as a prerequisite since that would
112 defeat the point of having the force variant.
113
114 If you are using "ExtUtils::MakeMaker" you should have a line like the
115 following in your Makefile.PL:
116
117 'PREREQ_PM' => {
118 'Test::Signature' => '1.04',
119 'Module::Signature' => '0.22',
120 'Test::More' => '0.47',
121 },
122
123 If using "Module::Build", your Build.PL should have:
124
125 build_requires => {
126 'Test::Signature' => '1.04',
127 'Module::Signature' => '0.22',
128 'Test::More' => '0.47',
129 },
130
131 If you just want the default behaviour of testing the signature if and
132 only if the user already has "Module::Signature" installed, then you
133 will need something like the following code. The example uses
134 "Module::Build" format but it should be trivial for you to translate to
135 "ExtUtils::MakeMaker".
136
137 #!/usr/bin/perl -w
138 use strict;
139 use Module::Build 0.18;
140
141 my @extra_build;
142
143 eval { require Module::Signature };
144 if (!$@ or $Test::Prereq::VERSION)
145 {
146 push @extra_build, "Module::Signature" => '0.22'
147 }
148
149 my $m = Module::Build->new(
150 dist_name => 'WWW-Yahoo-Groups',
151 dist_version => '1.7.7',
152 license => 'perl',
153
154 requires => {
155 # various modules
156 'perl' => '5.6.0',
157 },
158 build_requires => {
159 'Test::More' => 0.47,
160 'Test::Prereq' => 0.19,
161 'Test::Prereq::Build' => 0.04,
162 'Test::Signature' => 1.04,
163 @extra_build,
164 },
165 );
166
167 $m->create_build_script;
168
169 If you have any questions on using this module with "Test::Prereq",
170 just email me (address below).
171
172 Use with Module::Install
173 "Module::Install" is a module to assist in the bundling of build
174 prerequisite modules in packages. Well, among other things.
175
176 "Test::Signature" is a perfect candidate for such a module. As it's a
177 module aimed purely at those writing modules rather than those using
178 them.
179
180 Here's a good way to use it:
181
182 Make a test file (say, t/00sig.t) that contains the following:
183
184 use lib 'inc';
185 use Test::More tests => 1;
186 use Test::Signature;
187 signature_ok();
188
189 In your Makefile.PL (or Build.PL if appropriate) add:
190
191 include 'Test::Signature';
192
193 And that's it! You don't have to specify it as a prerequisite or
194 anything like that because "Module::Install" will include it in your
195 distribution. And you don't have to worry about size because
196 "Module::Install" strips out all this waffling POD.
197
199 Arthur Bergman for suggesting the module.
200
201 Audrey Tang for writing Module::Signature, and making some suggestions.
202
203 Tels suggested testing network connectivity to Audrey; Audrey added
204 that to "Module::Signature" 0.16 and I (Iain Truskett) added it to this
205 module (as of 1.03).
206
208 Please report bugs at <bug-test-signature@rt.cpan.org> or via the web
209 interface at <http://rt.cpan.org>
210
212 Audrey Tang <cpan@audreyt.org> Original author: Iain Truskett
213 <spoon@cpan.org>, now passed away.
214
216 Copyright 2002, 2003 by Iain Truskett. Copyright 2003, 2007, 2015 by
217 Audrey Tang <cpan@audreyt.org>.
218
219 This library is free software; you can redistribute it and/or modify it
220 under the same terms as Perl itself.
221
223 perl, Module::Signature, Test::More.
224
225 Module::Build, ExtUtils::Manifest, ExtUtils::MakeMaker.
226
227 Test::Prereq, Module::Install.
228
229
230
231perl v5.32.0 2020-07-28 Test::Signature(3)