Commit | Line | Data |
---|---|---|
04c692a8 | 1 | =encoding utf8 |
35c336e6 | 2 | |
04c692a8 DR |
3 | =for comment |
4 | Consistent formatting of this file is achieved with: | |
5 | perl ./Porting/podtidy pod/perlhack.pod | |
35c336e6 | 6 | |
04c692a8 | 7 | =head1 NAME |
35c336e6 | 8 | |
04c692a8 | 9 | perlhack - How to hack on Perl |
35c336e6 | 10 | |
04c692a8 | 11 | =head1 DESCRIPTION |
35c336e6 | 12 | |
531e2078 | 13 | This document explains how Perl development works. It includes details |
04c692a8 DR |
14 | about the Perl 5 Porters email list, the Perl repository, the Perlbug |
15 | bug tracker, patch guidelines, and commentary on Perl development | |
16 | philosophy. | |
f7e1e956 | 17 | |
04c692a8 | 18 | =head1 SUPER QUICK PATCH GUIDE |
f7e1e956 | 19 | |
04c692a8 DR |
20 | If you just want to submit a single small patch like a pod fix, a test |
21 | for a bug, comment fixes, etc., it's easy! Here's how: | |
f7e1e956 | 22 | |
04c692a8 | 23 | =over 4 |
e018f8be | 24 | |
04c692a8 | 25 | =item * Check out the source repository |
e018f8be | 26 | |
531e2078 | 27 | The perl source is in a git repository. You can clone the repository |
04c692a8 | 28 | with the following command: |
e018f8be | 29 | |
04c692a8 | 30 | % git clone git://perl5.git.perl.org/perl.git perl |
e018f8be | 31 | |
69434957 S |
32 | =item * Ensure you're following the latest advice |
33 | ||
34 | In case the advice in this guide has been updated recently, read the | |
35 | latest version directly from the perl source: | |
36 | ||
37 | % perldoc pod/perlhack.pod | |
38 | ||
04c692a8 | 39 | =item * Make your change |
e018f8be | 40 | |
04c692a8 | 41 | Hack, hack, hack. |
7205a85d | 42 | |
04c692a8 | 43 | =item * Test your change |
e018f8be | 44 | |
04c692a8 | 45 | You can run all the tests with the following commands: |
b26492ee | 46 | |
04c692a8 DR |
47 | % ./Configure -des -Dusedevel |
48 | % make test | |
7205a85d | 49 | |
04c692a8 | 50 | Keep hacking until the tests pass. |
b26492ee | 51 | |
04c692a8 | 52 | =item * Commit your change |
e018f8be | 53 | |
b6538e4f | 54 | Committing your work will save the change I<on your local system>: |
7205a85d | 55 | |
04c692a8 | 56 | % git commit -a -m 'Commit message goes here' |
e018f8be | 57 | |
04c692a8 | 58 | Make sure the commit message describes your change in a single |
531e2078 | 59 | sentence. For example, "Fixed spelling errors in perlhack.pod". |
e018f8be | 60 | |
04c692a8 | 61 | =item * Send your change to perlbug |
7a834142 | 62 | |
04c692a8 DR |
63 | The next step is to submit your patch to the Perl core ticket system |
64 | via email. | |
7a834142 | 65 | |
84788b0a S |
66 | If your changes are in a single git commit, run the following commands |
67 | to write the file as a MIME attachment and send it with a meaningful | |
5c70016e | 68 | subject: |
e018f8be | 69 | |
7eac65da | 70 | % git format-patch -1 --attach |
e4583015 S |
71 | % ./perl -Ilib utils/perlbug -s "[PATCH] $( |
72 | git log -1 --oneline HEAD)" -f 0001-*.patch | |
e018f8be | 73 | |
04c692a8 | 74 | The perlbug program will ask you a few questions about your email |
531e2078 | 75 | address and the patch you're submitting. Once you've answered them it |
84b19098 | 76 | will submit your patch via email. |
e018f8be | 77 | |
84788b0a S |
78 | If your changes are in multiple commits, generate a patch file |
79 | containing them all, and attach that: | |
2d1c9392 | 80 | |
84788b0a S |
81 | % git format-patch origin/blead --attach --stdout > patches |
82 | % ./perl -Ilib utils/perlbug -f patches | |
2d1c9392 | 83 | |
84788b0a S |
84 | When prompted, pick a subject that summarizes your changes overall and |
85 | has "[PATCH]" at the beginning. | |
2d1c9392 | 86 | |
04c692a8 | 87 | =item * Thank you |
e018f8be | 88 | |
04c692a8 DR |
89 | The porters appreciate the time you spent helping to make Perl better. |
90 | Thank you! | |
e018f8be | 91 | |
e99cf3f0 S |
92 | =item * Next time |
93 | ||
94 | The next time you wish to make a patch, you need to start from the | |
95 | latest perl in a pristine state. Check you don't have any local changes | |
96 | or added files in your perl check-out which you wish to keep, then run | |
97 | these commands: | |
98 | ||
99 | % git pull | |
100 | % git reset --hard origin/blead | |
101 | % git clean -dxf | |
102 | ||
cce04beb | 103 | =back |
e018f8be | 104 | |
04c692a8 | 105 | =head1 BUG REPORTING |
cc0710ff | 106 | |
9e6670f3 | 107 | If you want to report a bug in Perl, you must use the F<perlbug> |
531e2078 | 108 | command line tool. This tool will ensure that your bug report includes |
9e6670f3 | 109 | all the relevant system and configuration information. |
7205a85d | 110 | |
04c692a8 | 111 | To browse existing Perl bugs and patches, you can use the web interface |
a8d15a22 | 112 | at L<http://rt.perl.org/>. |
244d9cb7 | 113 | |
04c692a8 | 114 | Please check the archive of the perl5-porters list (see below) and/or |
531e2078 | 115 | the bug tracking system before submitting a bug report. Often, you'll |
04c692a8 | 116 | find that the bug has been reported already. |
244d9cb7 | 117 | |
04c692a8 | 118 | You can log in to the bug tracking system and comment on existing bug |
531e2078 FC |
119 | reports. If you have additional information regarding an existing bug, |
120 | please add it. This will help the porters fix the bug. | |
7205a85d | 121 | |
04c692a8 | 122 | =head1 PERL 5 PORTERS |
7205a85d | 123 | |
04c692a8 | 124 | The perl5-porters (p5p) mailing list is where the Perl standard |
531e2078 | 125 | distribution is maintained and developed. The people who maintain Perl |
9e6670f3 DR |
126 | are also referred to as the "Perl 5 Porters", "p5p" or just the |
127 | "porters". | |
a75f557c | 128 | |
04c692a8 | 129 | A searchable archive of the list is available at |
531e2078 | 130 | L<http://www.xray.mpe.mpg.de/mailing-lists/perl5-porters/>. There is |
04c692a8 DR |
131 | also another archive at |
132 | L<http://archive.develooper.com/perl5-porters@perl.org/>. | |
7205a85d | 133 | |
04c692a8 | 134 | =head2 perl-changes mailing list |
7205a85d | 135 | |
04c692a8 DR |
136 | The perl5-changes mailing list receives a copy of each patch that gets |
137 | submitted to the maintenance and development branches of the perl | |
531e2078 | 138 | repository. See L<http://lists.perl.org/list/perl5-changes.html> for |
04c692a8 | 139 | subscription and archive information. |
244d9cb7 | 140 | |
37bf3a91 DR |
141 | =head2 #p5p on IRC |
142 | ||
143 | Many porters are also active on the L<irc://irc.perl.org/#p5p> channel. | |
144 | Feel free to join the channel and ask questions about hacking on the | |
145 | Perl core. | |
146 | ||
04c692a8 | 147 | =head1 GETTING THE PERL SOURCE |
244d9cb7 | 148 | |
04c692a8 | 149 | All of Perl's source code is kept centrally in a Git repository at |
a44b8c28 S |
150 | I<perl5.git.perl.org>. The repository contains many Perl revisions |
151 | from Perl 1 onwards and all the revisions from Perforce, the previous | |
04c692a8 | 152 | version control system. |
244d9cb7 | 153 | |
04c692a8 DR |
154 | For much more detail on using git with the Perl repository, please see |
155 | L<perlgit>. | |
244d9cb7 | 156 | |
04c692a8 | 157 | =head2 Read access via Git |
244d9cb7 | 158 | |
531e2078 | 159 | You will need a copy of Git for your computer. You can fetch a copy of |
04c692a8 | 160 | the repository using the git protocol: |
244d9cb7 | 161 | |
04c692a8 | 162 | % git clone git://perl5.git.perl.org/perl.git perl |
244d9cb7 | 163 | |
04c692a8 DR |
164 | This clones the repository and makes a local copy in the F<perl> |
165 | directory. | |
7205a85d | 166 | |
04c692a8 DR |
167 | If you cannot use the git protocol for firewall reasons, you can also |
168 | clone via http, though this is much slower: | |
7205a85d | 169 | |
04c692a8 | 170 | % git clone http://perl5.git.perl.org/perl.git perl |
7205a85d | 171 | |
04c692a8 | 172 | =head2 Read access via the web |
7205a85d | 173 | |
531e2078 | 174 | You may access the repository over the web. This allows you to browse |
04c692a8 | 175 | the tree, see recent commits, subscribe to RSS feeds for the changes, |
531e2078 FC |
176 | search for particular commits and more. You may access it at |
177 | L<http://perl5.git.perl.org/perl.git>. A mirror of the repository is | |
a8d15a22 | 178 | found at L<http://github.com/mirrors/perl>. |
7205a85d | 179 | |
04c692a8 | 180 | =head2 Read access via rsync |
7205a85d | 181 | |
04c692a8 DR |
182 | You can also choose to use rsync to get a copy of the current source |
183 | tree for the bleadperl branch and all maintenance branches: | |
7205a85d | 184 | |
7eac65da S |
185 | % rsync -avz rsync://perl5.git.perl.org/perl-current . |
186 | % rsync -avz rsync://perl5.git.perl.org/perl-5.12.x . | |
187 | % rsync -avz rsync://perl5.git.perl.org/perl-5.10.x . | |
188 | % rsync -avz rsync://perl5.git.perl.org/perl-5.8.x . | |
189 | % rsync -avz rsync://perl5.git.perl.org/perl-5.6.x . | |
190 | % rsync -avz rsync://perl5.git.perl.org/perl-5.005xx . | |
7205a85d | 191 | |
a8d15a22 | 192 | (Add the C<--delete> option to remove leftover files.) |
7205a85d | 193 | |
04c692a8 | 194 | To get a full list of the available sync points: |
7205a85d | 195 | |
7eac65da | 196 | % rsync perl5.git.perl.org:: |
7205a85d | 197 | |
04c692a8 | 198 | =head2 Write access via git |
7205a85d | 199 | |
04c692a8 DR |
200 | If you have a commit bit, please see L<perlgit> for more details on |
201 | using git. | |
7205a85d | 202 | |
04c692a8 | 203 | =head1 PATCHING PERL |
7205a85d | 204 | |
04c692a8 | 205 | If you're planning to do more extensive work than a single small fix, |
531e2078 | 206 | we encourage you to read the documentation below. This will help you |
04c692a8 DR |
207 | focus your work and make your patches easier to incorporate into the |
208 | Perl source. | |
244d9cb7 | 209 | |
04c692a8 | 210 | =head2 Submitting patches |
244d9cb7 | 211 | |
531e2078 FC |
212 | If you have a small patch to submit, please submit it via perlbug. You |
213 | can also send email directly to perlbug@perl.org. Please note that | |
04c692a8 DR |
214 | messages sent to perlbug may be held in a moderation queue, so you |
215 | won't receive a response immediately. | |
244d9cb7 | 216 | |
04c692a8 | 217 | You'll know your submission has been processed when you receive an |
531e2078 FC |
218 | email from our ticket tracking system. This email will give you a |
219 | ticket number. Once your patch has made it to the ticket tracking | |
04c692a8 | 220 | system, it will also be sent to the perl5-porters@perl.org list. |
244d9cb7 | 221 | |
531e2078 | 222 | Patches are reviewed and discussed on the p5p list. Simple, |
04c692a8 DR |
223 | uncontroversial patches will usually be applied without any discussion. |
224 | When the patch is applied, the ticket will be updated and you will | |
531e2078 | 225 | receive email. In addition, an email will be sent to the p5p list. |
244d9cb7 | 226 | |
531e2078 | 227 | In other cases, the patch will need more work or discussion. That will |
04c692a8 | 228 | happen on the p5p list. |
244d9cb7 | 229 | |
04c692a8 | 230 | You are encouraged to participate in the discussion and advocate for |
531e2078 | 231 | your patch. Sometimes your patch may get lost in the shuffle. It's |
04c692a8 | 232 | appropriate to send a reminder email to p5p if no action has been taken |
531e2078 | 233 | in a month. Please remember that the Perl 5 developers are all |
04c692a8 | 234 | volunteers, and be polite. |
244d9cb7 | 235 | |
04c692a8 | 236 | Changes are always applied directly to the main development branch, |
a44b8c28 S |
237 | called "blead". Some patches may be backported to a maintenance |
238 | branch. If you think your patch is appropriate for the maintenance | |
239 | branch, please explain why when you submit it. | |
244d9cb7 | 240 | |
04c692a8 | 241 | =head2 Getting your patch accepted |
244d9cb7 | 242 | |
84c2f6fd DR |
243 | If you are submitting a code patch there are several things that you |
244 | can do to help the Perl 5 Porters accept your patch. | |
244d9cb7 | 245 | |
a126fb62 DR |
246 | =head3 Patch style |
247 | ||
248 | If you used git to check out the Perl source, then using C<git | |
531e2078 | 249 | format-patch> will produce a patch in a style suitable for Perl. The |
a126fb62 | 250 | C<format-patch> command produces one patch file for each commit you |
a44b8c28 S |
251 | made. If you prefer to send a single patch for all commits, you can |
252 | use C<git diff>. | |
a126fb62 | 253 | |
9d440a18 | 254 | % git checkout blead |
a126fb62 DR |
255 | % git pull |
256 | % git diff blead my-branch-name | |
257 | ||
258 | This produces a patch based on the difference between blead and your | |
531e2078 | 259 | current branch. It's important to make sure that blead is up to date |
a126fb62 DR |
260 | before producing the diff, that's why we call C<git pull> first. |
261 | ||
531e2078 | 262 | We strongly recommend that you use git if possible. It will make your |
a126fb62 DR |
263 | life easier, and ours as well. |
264 | ||
265 | However, if you're not using git, you can still produce a suitable | |
531e2078 FC |
266 | patch. You'll need a pristine copy of the Perl source to diff against. |
267 | The porters prefer unified diffs. Using GNU C<diff>, you can produce a | |
a126fb62 DR |
268 | diff like this: |
269 | ||
270 | % diff -Npurd perl.pristine perl.mine | |
271 | ||
272 | Make sure that you C<make realclean> in your copy of Perl to remove any | |
273 | build artifacts, or you may get a confusing result. | |
274 | ||
04c692a8 | 275 | =head3 Commit message |
244d9cb7 | 276 | |
04c692a8 | 277 | As you craft each patch you intend to submit to the Perl core, it's |
531e2078 | 278 | important to write a good commit message. This is especially important |
04c692a8 | 279 | if your submission will consist of a series of commits. |
244d9cb7 | 280 | |
04c692a8 | 281 | The first line of the commit message should be a short description |
531e2078 | 282 | without a period. It should be no longer than the subject line of an |
a8d15a22 | 283 | email, 50 characters being a good rule of thumb. |
f7e1e956 | 284 | |
a8d15a22 | 285 | A lot of Git tools (Gitweb, GitHub, git log --pretty=oneline, ...) will |
04c692a8 DR |
286 | only display the first line (cut off at 50 characters) when presenting |
287 | commit summaries. | |
7cd58830 | 288 | |
04c692a8 DR |
289 | The commit message should include a description of the problem that the |
290 | patch corrects or new functionality that the patch adds. | |
7cd58830 | 291 | |
04c692a8 DR |
292 | As a general rule of thumb, your commit message should help a |
293 | programmer who knows the Perl core quickly understand what you were | |
294 | trying to do, how you were trying to do it, and why the change matters | |
295 | to Perl. | |
7cd58830 | 296 | |
04c692a8 | 297 | =over 4 |
7cd58830 | 298 | |
04c692a8 | 299 | =item * Why |
7cd58830 | 300 | |
04c692a8 | 301 | Your commit message should describe why the change you are making is |
531e2078 | 302 | important. When someone looks at your change in six months or six |
04c692a8 | 303 | years, your intent should be clear. |
7cd58830 | 304 | |
04c692a8 | 305 | If you're deprecating a feature with the intent of later simplifying |
531e2078 | 306 | another bit of code, say so. If you're fixing a performance problem or |
04c692a8 DR |
307 | adding a new feature to support some other bit of the core, mention |
308 | that. | |
7cd58830 | 309 | |
04c692a8 | 310 | =item * What |
7cd58830 | 311 | |
04c692a8 DR |
312 | Your commit message should describe what part of the Perl core you're |
313 | changing and what you expect your patch to do. | |
7cd58830 | 314 | |
04c692a8 | 315 | =item * How |
7cd58830 | 316 | |
04c692a8 DR |
317 | While it's not necessary for documentation changes, new tests or |
318 | trivial patches, it's often worth explaining how your change works. | |
319 | Even if it's clear to you today, it may not be clear to a porter next | |
320 | month or next year. | |
d7889f52 | 321 | |
04c692a8 | 322 | =back |
d7889f52 | 323 | |
04c692a8 | 324 | A commit message isn't intended to take the place of comments in your |
531e2078 | 325 | code. Commit messages should describe the change you made, while code |
04c692a8 | 326 | comments should describe the current state of the code. |
d7889f52 | 327 | |
04c692a8 | 328 | If you've just implemented a new feature, complete with doc, tests and |
531e2078 | 329 | well-commented code, a brief commit message will often suffice. If, |
04c692a8 DR |
330 | however, you've just changed a single character deep in the parser or |
331 | lexer, you might need to write a small novel to ensure that future | |
332 | readers understand what you did and why you did it. | |
d7889f52 | 333 | |
04c692a8 | 334 | =head3 Comments, Comments, Comments |
d7889f52 | 335 | |
a44b8c28 S |
336 | Be sure to adequately comment your code. While commenting every line |
337 | is unnecessary, anything that takes advantage of side effects of | |
04c692a8 DR |
338 | operators, that creates changes that will be felt outside of the |
339 | function being patched, or that others may find confusing should be | |
a44b8c28 S |
340 | documented. If you are going to err, it is better to err on the side |
341 | of adding too many comments than too few. | |
d7889f52 | 342 | |
04c692a8 DR |
343 | The best comments explain I<why> the code does what it does, not I<what |
344 | it does>. | |
d7889f52 | 345 | |
04c692a8 | 346 | =head3 Style |
d7889f52 | 347 | |
04c692a8 DR |
348 | In general, please follow the particular style of the code you are |
349 | patching. | |
d7889f52 | 350 | |
04c692a8 DR |
351 | In particular, follow these general guidelines for patching Perl |
352 | sources: | |
cce04beb | 353 | |
04c692a8 | 354 | =over 4 |
d7889f52 JH |
355 | |
356 | =item * | |
357 | ||
04c692a8 | 358 | 8-wide tabs (no exceptions!) |
d7889f52 JH |
359 | |
360 | =item * | |
361 | ||
04c692a8 | 362 | 4-wide indents for code, 2-wide indents for nested CPP #defines |
ee9468a2 | 363 | |
cce04beb | 364 | =item * |
ee9468a2 | 365 | |
04c692a8 | 366 | Try hard not to exceed 79-columns |
bc028b6b | 367 | |
ee9468a2 RGS |
368 | =item * |
369 | ||
04c692a8 | 370 | ANSI C prototypes |
d7889f52 JH |
371 | |
372 | =item * | |
373 | ||
04c692a8 | 374 | Uncuddled elses and "K&R" style for indenting control constructs |
0bec6c03 | 375 | |
04c692a8 | 376 | =item * |
d7889f52 | 377 | |
04c692a8 | 378 | No C++ style (//) comments |
d7889f52 JH |
379 | |
380 | =item * | |
381 | ||
04c692a8 | 382 | Mark places that need to be revisited with XXX (and revisit often!) |
27565cb6 JH |
383 | |
384 | =item * | |
385 | ||
04c692a8 DR |
386 | Opening brace lines up with "if" when conditional spans multiple lines; |
387 | should be at end-of-line otherwise | |
27565cb6 | 388 | |
04c692a8 | 389 | =item * |
27565cb6 | 390 | |
04c692a8 DR |
391 | In function definitions, name starts in column 0 (return value is on |
392 | previous line) | |
27565cb6 | 393 | |
04c692a8 | 394 | =item * |
27565cb6 | 395 | |
04c692a8 DR |
396 | Single space after keywords that are followed by parens, no space |
397 | between function name and following paren | |
606fd33d | 398 | |
27565cb6 JH |
399 | =item * |
400 | ||
04c692a8 DR |
401 | Avoid assignments in conditionals, but if they're unavoidable, use |
402 | extra paren, e.g. "if (a && (b = c)) ..." | |
27565cb6 JH |
403 | |
404 | =item * | |
405 | ||
04c692a8 | 406 | "return foo;" rather than "return(foo);" |
27565cb6 JH |
407 | |
408 | =item * | |
409 | ||
04c692a8 | 410 | "if (!foo) ..." rather than "if (foo == FALSE) ..." etc. |
606fd33d | 411 | |
a8bd0d47 KW |
412 | =item * |
413 | ||
414 | Do not declare variables using "register". It may be counterproductive | |
415 | with modern compilers, and is deprecated in C++, under which the Perl | |
416 | source is regularly compiled. | |
417 | ||
5b48d9bb KW |
418 | =item * |
419 | ||
420 | In-line functions that are in headers that are accessible to XS code | |
421 | need to be able to compile without warnings with commonly used extra | |
422 | compilation flags, such as gcc's C<-Wswitch-default> which warns | |
423 | whenever a switch statement does not have a "default" case. The use of | |
a44b8c28 S |
424 | these extra flags is to catch potential problems in legal C code, and |
425 | is often used by Perl aggregators, such as Linux distributors. | |
5b48d9bb | 426 | |
606fd33d | 427 | =back |
27565cb6 | 428 | |
04c692a8 | 429 | =head3 Test suite |
d7889f52 | 430 | |
a8d15a22 | 431 | If your patch changes code (rather than just changing documentation), |
04c692a8 | 432 | you should also include one or more test cases which illustrate the bug |
531e2078 | 433 | you're fixing or validate the new functionality you're adding. In |
04c692a8 DR |
434 | general, you should update an existing test file rather than create a |
435 | new one. | |
2bbc8d55 | 436 | |
04c692a8 DR |
437 | Your test suite additions should generally follow these guidelines |
438 | (courtesy of Gurusamy Sarathy <gsar@activestate.com>): | |
2bbc8d55 | 439 | |
04c692a8 | 440 | =over 4 |
0bec6c03 | 441 | |
04c692a8 | 442 | =item * |
0bec6c03 | 443 | |
531e2078 | 444 | Know what you're testing. Read the docs, and the source. |
ee9468a2 RGS |
445 | |
446 | =item * | |
447 | ||
04c692a8 | 448 | Tend to fail, not succeed. |
0bec6c03 | 449 | |
04c692a8 | 450 | =item * |
0bec6c03 | 451 | |
04c692a8 | 452 | Interpret results strictly. |
27565cb6 | 453 | |
04c692a8 | 454 | =item * |
27565cb6 | 455 | |
04c692a8 | 456 | Use unrelated features (this will flush out bizarre interactions). |
27565cb6 | 457 | |
04c692a8 | 458 | =item * |
27565cb6 | 459 | |
04c692a8 | 460 | Use non-standard idioms (otherwise you are not testing TIMTOWTDI). |
27565cb6 | 461 | |
04c692a8 | 462 | =item * |
d7889f52 | 463 | |
04c692a8 DR |
464 | Avoid using hardcoded test numbers whenever possible (the EXPECTED/GOT |
465 | found in t/op/tie.t is much more maintainable, and gives better failure | |
466 | reports). | |
d7889f52 | 467 | |
04c692a8 | 468 | =item * |
d7889f52 | 469 | |
04c692a8 | 470 | Give meaningful error messages when a test fails. |
d7889f52 | 471 | |
04c692a8 | 472 | =item * |
d7889f52 | 473 | |
531e2078 | 474 | Avoid using qx// and system() unless you are testing for them. If you |
04c692a8 | 475 | do use them, make sure that you cover _all_ perl platforms. |
d7889f52 | 476 | |
04c692a8 | 477 | =item * |
0bec6c03 | 478 | |
04c692a8 | 479 | Unlink any temporary files you create. |
63796a85 | 480 | |
04c692a8 | 481 | =item * |
0bec6c03 | 482 | |
04c692a8 | 483 | Promote unforeseen warnings to errors with $SIG{__WARN__}. |
0bec6c03 | 484 | |
04c692a8 | 485 | =item * |
0bec6c03 | 486 | |
04c692a8 DR |
487 | Be sure to use the libraries and modules shipped with the version being |
488 | tested, not those that were already installed. | |
d7889f52 | 489 | |
04c692a8 | 490 | =item * |
d7889f52 | 491 | |
04c692a8 | 492 | Add comments to the code explaining what you are testing for. |
d7889f52 | 493 | |
04c692a8 | 494 | =item * |
d7889f52 | 495 | |
531e2078 | 496 | Make updating the '1..42' string unnecessary. Or make sure that you |
04c692a8 | 497 | update it. |
d7889f52 | 498 | |
04c692a8 | 499 | =item * |
d7889f52 | 500 | |
04c692a8 | 501 | Test _all_ behaviors of a given operator, library, or function. |
d7889f52 | 502 | |
04c692a8 | 503 | Test all optional arguments. |
d7889f52 | 504 | |
04c692a8 | 505 | Test return values in various contexts (boolean, scalar, list, lvalue). |
d7889f52 | 506 | |
04c692a8 | 507 | Use both global and lexical variables. |
d7889f52 | 508 | |
04c692a8 | 509 | Don't forget the exceptional, pathological cases. |
0bec6c03 | 510 | |
cce04beb | 511 | =back |
0bec6c03 | 512 | |
04c692a8 | 513 | =head2 Patching a core module |
ee9468a2 | 514 | |
04c692a8 DR |
515 | This works just like patching anything else, with one extra |
516 | consideration. | |
63796a85 | 517 | |
a8d15a22 | 518 | Modules in the F<cpan/> directory of the source tree are maintained |
531e2078 | 519 | outside of the Perl core. When the author updates the module, the |
24b68a05 DG |
520 | updates are simply copied into the core. See that module's |
521 | documentation or its listing on L<http://search.cpan.org/> for more | |
522 | information on reporting bugs and submitting patches. | |
523 | ||
524 | In most cases, patches to modules in F<cpan/> should be sent upstream | |
9e6670f3 DR |
525 | and should not be applied to the Perl core individually. If a patch to |
526 | a file in F<cpan/> absolutely cannot wait for the fix to be made | |
7e5887a1 DG |
527 | upstream, released to CPAN and copied to blead, you must add (or |
528 | update) a C<CUSTOMIZED> entry in the F<"Porting/Maintainers.pl"> file | |
529 | to flag that a local modification has been made. See | |
530 | F<"Porting/Maintainers.pl"> for more details. | |
63796a85 | 531 | |
04c692a8 DR |
532 | In contrast, modules in the F<dist/> directory are maintained in the |
533 | core. | |
63796a85 | 534 | |
04c692a8 | 535 | =head2 Updating perldelta |
63796a85 | 536 | |
04c692a8 DR |
537 | For changes significant enough to warrant a F<pod/perldelta.pod> entry, |
538 | the porters will greatly appreciate it if you submit a delta entry | |
a44b8c28 S |
539 | along with your actual change. Significant changes include, but are |
540 | not limited to: | |
63796a85 | 541 | |
04c692a8 | 542 | =over 4 |
63796a85 | 543 | |
04c692a8 | 544 | =item * |
63796a85 | 545 | |
04c692a8 | 546 | Adding, deprecating, or removing core features |
ee9468a2 | 547 | |
04c692a8 | 548 | =item * |
ee9468a2 | 549 | |
04c692a8 | 550 | Adding, deprecating, removing, or upgrading core or dual-life modules |
ee9468a2 | 551 | |
04c692a8 | 552 | =item * |
ee9468a2 | 553 | |
04c692a8 | 554 | Adding new core tests |
ee9468a2 | 555 | |
04c692a8 | 556 | =item * |
ee9468a2 | 557 | |
04c692a8 | 558 | Fixing security issues and user-visible bugs in the core |
cce04beb | 559 | |
04c692a8 | 560 | =item * |
ad7244db | 561 | |
04c692a8 | 562 | Changes that might break existing code, either on the perl or C level |
ad7244db JH |
563 | |
564 | =item * | |
565 | ||
04c692a8 | 566 | Significant performance improvements |
ad7244db JH |
567 | |
568 | =item * | |
569 | ||
04c692a8 DR |
570 | Adding, removing, or significantly changing documentation in the |
571 | F<pod/> directory | |
ad7244db | 572 | |
cce04beb | 573 | =item * |
ad7244db | 574 | |
04c692a8 | 575 | Important platform-specific changes |
d7889f52 | 576 | |
cce04beb DG |
577 | =back |
578 | ||
04c692a8 | 579 | Please make sure you add the perldelta entry to the right section |
531e2078 | 580 | within F<pod/perldelta.pod>. More information on how to write good |
04c692a8 DR |
581 | perldelta entries is available in the C<Style> section of |
582 | F<Porting/how_to_write_a_perldelta.pod>. | |
d7889f52 | 583 | |
04c692a8 | 584 | =head2 What makes for a good patch? |
d7889f52 | 585 | |
531e2078 | 586 | New features and extensions to the language can be contentious. There |
04c692a8 DR |
587 | is no specific set of criteria which determine what features get added, |
588 | but here are some questions to consider when developing a patch: | |
d7889f52 | 589 | |
04c692a8 | 590 | =head3 Does the concept match the general goals of Perl? |
d7889f52 | 591 | |
04c692a8 | 592 | Our goals include, but are not limited to: |
d7889f52 | 593 | |
04c692a8 | 594 | =over 4 |
d7889f52 | 595 | |
04c692a8 | 596 | =item 1. |
d7889f52 | 597 | |
04c692a8 | 598 | Keep it fast, simple, and useful. |
cce04beb | 599 | |
04c692a8 | 600 | =item 2. |
cce04beb | 601 | |
04c692a8 | 602 | Keep features/concepts as orthogonal as possible. |
902b9dbf | 603 | |
04c692a8 | 604 | =item 3. |
902b9dbf | 605 | |
04c692a8 | 606 | No arbitrary limits (platforms, data sizes, cultures). |
a958818a | 607 | |
04c692a8 | 608 | =item 4. |
ac036724 | 609 | |
04c692a8 | 610 | Keep it open and exciting to use/patch/advocate Perl everywhere. |
a958818a | 611 | |
04c692a8 | 612 | =item 5. |
a958818a | 613 | |
04c692a8 | 614 | Either assimilate new technologies, or build bridges to them. |
a958818a | 615 | |
04c692a8 | 616 | =back |
a958818a | 617 | |
04c692a8 | 618 | =head3 Where is the implementation? |
a958818a | 619 | |
531e2078 | 620 | All the talk in the world is useless without an implementation. In |
04c692a8 | 621 | almost every case, the person or people who argue for a new feature |
531e2078 | 622 | will be expected to be the ones who implement it. Porters capable of |
04c692a8 DR |
623 | coding new features have their own agendas, and are not available to |
624 | implement your (possibly good) idea. | |
a1b65709 | 625 | |
04c692a8 | 626 | =head3 Backwards compatibility |
37c0adeb | 627 | |
531e2078 | 628 | It's a cardinal sin to break existing Perl programs. New warnings can |
04c692a8 | 629 | be contentious--some say that a program that emits warnings is not |
531e2078 | 630 | broken, while others say it is. Adding keywords has the potential to |
04c692a8 DR |
631 | break programs, changing the meaning of existing token sequences or |
632 | functions might break programs. | |
f50e5b73 | 633 | |
04c692a8 DR |
634 | The Perl 5 core includes mechanisms to help porters make backwards |
635 | incompatible changes more compatible such as the L<feature> and | |
531e2078 | 636 | L<deprecate> modules. Please use them when appropriate. |
902b9dbf | 637 | |
04c692a8 | 638 | =head3 Could it be a module instead? |
902b9dbf | 639 | |
04c692a8 | 640 | Perl 5 has extension mechanisms, modules and XS, specifically to avoid |
531e2078 | 641 | the need to keep changing the Perl interpreter. You can write modules |
04c692a8 DR |
642 | that export functions, you can give those functions prototypes so they |
643 | can be called like built-in functions, you can even write XS code to | |
644 | mess with the runtime data structures of the Perl interpreter if you | |
645 | want to implement really complicated things. | |
902b9dbf | 646 | |
04c692a8 DR |
647 | Whenever possible, new features should be prototyped in a CPAN module |
648 | before they will be considered for the core. | |
902b9dbf | 649 | |
04c692a8 | 650 | =head3 Is the feature generic enough? |
902b9dbf | 651 | |
04c692a8 DR |
652 | Is this something that only the submitter wants added to the language, |
653 | or is it broadly useful? Sometimes, instead of adding a feature with a | |
654 | tight focus, the porters might decide to wait until someone implements | |
655 | the more generalized feature. | |
902b9dbf | 656 | |
04c692a8 | 657 | =head3 Does it potentially introduce new bugs? |
902b9dbf | 658 | |
04c692a8 DR |
659 | Radical rewrites of large chunks of the Perl interpreter have the |
660 | potential to introduce new bugs. | |
902b9dbf | 661 | |
04c692a8 | 662 | =head3 How big is it? |
902b9dbf | 663 | |
531e2078 | 664 | The smaller and more localized the change, the better. Similarly, a |
04c692a8 | 665 | series of small patches is greatly preferred over a single large patch. |
902b9dbf | 666 | |
04c692a8 | 667 | =head3 Does it preclude other desirable features? |
902b9dbf | 668 | |
04c692a8 | 669 | A patch is likely to be rejected if it closes off future avenues of |
531e2078 | 670 | development. For instance, a patch that placed a true and final |
04c692a8 DR |
671 | interpretation on prototypes is likely to be rejected because there are |
672 | still options for the future of prototypes that haven't been addressed. | |
902b9dbf | 673 | |
04c692a8 | 674 | =head3 Is the implementation robust? |
902b9dbf | 675 | |
04c692a8 | 676 | Good patches (tight code, complete, correct) stand more chance of going |
531e2078 | 677 | in. Sloppy or incorrect patches might be placed on the back burner |
04c692a8 DR |
678 | until the pumpking has time to fix, or might be discarded altogether |
679 | without further notice. | |
902b9dbf | 680 | |
04c692a8 | 681 | =head3 Is the implementation generic enough to be portable? |
902b9dbf | 682 | |
531e2078 | 683 | The worst patches make use of system-specific features. It's highly |
04c692a8 DR |
684 | unlikely that non-portable additions to the Perl language will be |
685 | accepted. | |
902b9dbf | 686 | |
04c692a8 | 687 | =head3 Is the implementation tested? |
902b9dbf | 688 | |
04c692a8 DR |
689 | Patches which change behaviour (fixing bugs or introducing new |
690 | features) must include regression tests to verify that everything works | |
691 | as expected. | |
902b9dbf | 692 | |
04c692a8 DR |
693 | Without tests provided by the original author, how can anyone else |
694 | changing perl in the future be sure that they haven't unwittingly | |
695 | broken the behaviour the patch implements? And without tests, how can | |
696 | the patch's author be confident that his/her hard work put into the | |
697 | patch won't be accidentally thrown away by someone in the future? | |
902b9dbf | 698 | |
04c692a8 | 699 | =head3 Is there enough documentation? |
902b9dbf | 700 | |
04c692a8 | 701 | Patches without documentation are probably ill-thought out or |
531e2078 | 702 | incomplete. No features can be added or changed without documentation, |
04c692a8 DR |
703 | so submitting a patch for the appropriate pod docs as well as the |
704 | source code is important. | |
902b9dbf | 705 | |
04c692a8 | 706 | =head3 Is there another way to do it? |
902b9dbf | 707 | |
04c692a8 | 708 | Larry said "Although the Perl Slogan is I<There's More Than One Way to |
531e2078 | 709 | Do It>, I hesitate to make 10 ways to do something". This is a tricky |
04c692a8 DR |
710 | heuristic to navigate, though--one man's essential addition is another |
711 | man's pointless cruft. | |
902b9dbf | 712 | |
04c692a8 | 713 | =head3 Does it create too much work? |
902b9dbf | 714 | |
04c692a8 DR |
715 | Work for the pumpking, work for Perl programmers, work for module |
716 | authors, ... Perl is supposed to be easy. | |
902b9dbf | 717 | |
04c692a8 | 718 | =head3 Patches speak louder than words |
902b9dbf | 719 | |
531e2078 | 720 | Working code is always preferred to pie-in-the-sky ideas. A patch to |
04c692a8 DR |
721 | add a feature stands a much higher chance of making it to the language |
722 | than does a random feature request, no matter how fervently argued the | |
a44b8c28 S |
723 | request might be. This ties into "Will it be useful?", as the fact |
724 | that someone took the time to make the patch demonstrates a strong | |
725 | desire for the feature. | |
c406981e | 726 | |
04c692a8 | 727 | =head1 TESTING |
c406981e | 728 | |
04c692a8 DR |
729 | The core uses the same testing style as the rest of Perl, a simple |
730 | "ok/not ok" run through Test::Harness, but there are a few special | |
731 | considerations. | |
c406981e | 732 | |
531e2078 | 733 | There are three ways to write a test in the core: L<Test::More>, |
a44b8c28 S |
734 | F<t/test.pl> and ad hoc C<print $test ? "ok 42\n" : "not ok 42\n">. |
735 | The decision of which to use depends on what part of the test suite | |
736 | you're working on. This is a measure to prevent a high-level failure | |
737 | (such as Config.pm breaking) from causing basic functionality tests to | |
738 | fail. | |
c406981e | 739 | |
04c692a8 DR |
740 | The F<t/test.pl> library provides some of the features of |
741 | L<Test::More>, but avoids loading most modules and uses as few core | |
742 | features as possible. | |
902b9dbf | 743 | |
9e6670f3 DR |
744 | If you write your own test, use the L<Test Anything |
745 | Protocol|http://testanything.org>. | |
902b9dbf MLF |
746 | |
747 | =over 4 | |
748 | ||
bb52f720 | 749 | =item * F<t/base>, F<t/comp> and F<t/opbasic> |
902b9dbf | 750 | |
04c692a8 | 751 | Since we don't know if require works, or even subroutines, use ad hoc |
531e2078 | 752 | tests for these three. Step carefully to avoid using the feature being |
a44b8c28 S |
753 | tested. Tests in F<t/opbasic>, for instance, have been placed there |
754 | rather than in F<t/op> because they test functionality which | |
755 | F<t/test.pl> presumes has already been demonstrated to work. | |
902b9dbf | 756 | |
a8d15a22 | 757 | =item * F<t/cmd>, F<t/run>, F<t/io> and F<t/op> |
902b9dbf | 758 | |
04c692a8 DR |
759 | Now that basic require() and subroutines are tested, you can use the |
760 | F<t/test.pl> library. | |
902b9dbf | 761 | |
a8d15a22 | 762 | You can also use certain libraries like Config conditionally, but be |
04c692a8 | 763 | sure to skip the test gracefully if it's not there. |
902b9dbf | 764 | |
04c692a8 | 765 | =item * Everything else |
902b9dbf | 766 | |
04c692a8 | 767 | Now that the core of Perl is tested, L<Test::More> can and should be |
531e2078 | 768 | used. You can also use the full suite of core modules in the tests. |
902b9dbf MLF |
769 | |
770 | =back | |
771 | ||
a8d15a22 | 772 | When you say "make test", Perl uses the F<t/TEST> program to run the |
a44b8c28 S |
773 | test suite (except under Win32 where it uses F<t/harness> instead). |
774 | All tests are run from the F<t/> directory, B<not> the directory which | |
775 | contains the test. This causes some problems with the tests in | |
776 | F<lib/>, so here's some opportunity for some patching. | |
902b9dbf | 777 | |
531e2078 | 778 | You must be triply conscious of cross-platform concerns. This usually |
04c692a8 DR |
779 | boils down to using L<File::Spec> and avoiding things like C<fork()> |
780 | and C<system()> unless absolutely necessary. | |
7a834142 | 781 | |
04c692a8 | 782 | =head2 Special C<make test> targets |
07aa3531 | 783 | |
04c692a8 | 784 | There are various special make targets that can be used to test Perl |
531e2078 FC |
785 | slightly differently than the standard "test" target. Not all them are |
786 | expected to give a 100% success rate. Many of them have several | |
04c692a8 DR |
787 | aliases, and many of them are not available on certain operating |
788 | systems. | |
07aa3531 | 789 | |
04c692a8 | 790 | =over 4 |
d44161bf | 791 | |
04c692a8 | 792 | =item * test_porting |
7a834142 | 793 | |
04c692a8 DR |
794 | This runs some basic sanity tests on the source tree and helps catch |
795 | basic errors before you submit a patch. | |
7a834142 | 796 | |
04c692a8 | 797 | =item * minitest |
51a35ef1 | 798 | |
04c692a8 DR |
799 | Run F<miniperl> on F<t/base>, F<t/comp>, F<t/cmd>, F<t/run>, F<t/io>, |
800 | F<t/op>, F<t/uni> and F<t/mro> tests. | |
51a35ef1 | 801 | |
499cea6b | 802 | =item * test.valgrind check.valgrind |
51a35ef1 | 803 | |
04c692a8 | 804 | (Only in Linux) Run all the tests using the memory leak + naughty |
531e2078 | 805 | memory access tool "valgrind". The log files will be named |
04c692a8 | 806 | F<testname.valgrind>. |
83f0ef60 | 807 | |
04c692a8 | 808 | =item * test_harness |
83f0ef60 | 809 | |
04c692a8 | 810 | Run the test suite with the F<t/harness> controlling program, instead |
531e2078 | 811 | of F<t/TEST>. F<t/harness> is more sophisticated, and uses the |
04c692a8 | 812 | L<Test::Harness> module, thus using this test target supposes that perl |
531e2078 | 813 | mostly works. The main advantage for our purposes is that it prints a |
a44b8c28 S |
814 | detailed summary of failed tests at the end. Also, unlike F<t/TEST>, |
815 | it doesn't redirect stderr to stdout. | |
83f0ef60 | 816 | |
04c692a8 DR |
817 | Note that under Win32 F<t/harness> is always used instead of F<t/TEST>, |
818 | so there is no special "test_harness" target. | |
83f0ef60 | 819 | |
04c692a8 DR |
820 | Under Win32's "test" target you may use the TEST_SWITCHES and |
821 | TEST_FILES environment variables to control the behaviour of | |
531e2078 | 822 | F<t/harness>. This means you can say |
83f0ef60 | 823 | |
04c692a8 DR |
824 | nmake test TEST_FILES="op/*.t" |
825 | nmake test TEST_SWITCHES="-torture" TEST_FILES="op/*.t" | |
83f0ef60 | 826 | |
78087e0a R |
827 | =item * test-notty test_notty |
828 | ||
829 | Sets PERL_SKIP_TTY_TEST to true before running normal test. | |
830 | ||
83f0ef60 JH |
831 | =back |
832 | ||
04c692a8 | 833 | =head2 Parallel tests |
83f0ef60 | 834 | |
04c692a8 | 835 | The core distribution can now run its regression tests in parallel on |
531e2078 | 836 | Unix-like platforms. Instead of running C<make test>, set C<TEST_JOBS> |
04c692a8 | 837 | in your environment to the number of tests to run in parallel, and run |
531e2078 | 838 | C<make test_harness>. On a Bourne-like shell, this can be done as |
07aa3531 | 839 | |
04c692a8 | 840 | TEST_JOBS=3 make test_harness # Run 3 tests in parallel |
07aa3531 | 841 | |
04c692a8 DR |
842 | An environment variable is used, rather than parallel make itself, |
843 | because L<TAP::Harness> needs to be able to schedule individual | |
844 | non-conflicting test scripts itself, and there is no standard interface | |
845 | to C<make> utilities to interact with their job schedulers. | |
51a35ef1 | 846 | |
9e6670f3 | 847 | Note that currently some test scripts may fail when run in parallel |
a44b8c28 S |
848 | (most notably F<ext/IO/t/io_dir.t>). If necessary, run just the |
849 | failing scripts again sequentially and see if the failures go away. | |
51a35ef1 | 850 | |
04c692a8 | 851 | =head2 Running tests by hand |
51a35ef1 | 852 | |
9e6670f3 DR |
853 | You can run part of the test suite by hand by using one of the |
854 | following commands from the F<t/> directory: | |
51a35ef1 | 855 | |
04c692a8 | 856 | ./perl -I../lib TEST list-of-.t-files |
51a35ef1 | 857 | |
04c692a8 | 858 | or |
51a35ef1 | 859 | |
04c692a8 | 860 | ./perl -I../lib harness list-of-.t-files |
51a35ef1 | 861 | |
a8d15a22 | 862 | (If you don't specify test scripts, the whole test suite will be run.) |
51a35ef1 | 863 | |
04c692a8 | 864 | =head2 Using F<t/harness> for testing |
51a35ef1 | 865 | |
9e6670f3 | 866 | If you use C<harness> for testing, you have several command line |
531e2078 | 867 | options available to you. The arguments are as follows, and are in the |
9e6670f3 | 868 | order that they must appear if used together. |
51a35ef1 | 869 | |
04c692a8 DR |
870 | harness -v -torture -re=pattern LIST OF FILES TO TEST |
871 | harness -v -torture -re LIST OF PATTERNS TO MATCH | |
07aa3531 | 872 | |
a8d15a22 | 873 | If C<LIST OF FILES TO TEST> is omitted, the file list is obtained from |
531e2078 | 874 | the manifest. The file list may include shell wildcards which will be |
04c692a8 | 875 | expanded out. |
07aa3531 | 876 | |
04c692a8 | 877 | =over 4 |
4ae3d70a | 878 | |
04c692a8 | 879 | =item * -v |
4ae3d70a | 880 | |
04c692a8 DR |
881 | Run the tests under verbose mode so you can see what tests were run, |
882 | and debug output. | |
51a35ef1 | 883 | |
04c692a8 | 884 | =item * -torture |
4ae3d70a | 885 | |
04c692a8 | 886 | Run the torture tests as well as the normal set. |
4ae3d70a | 887 | |
04c692a8 | 888 | =item * -re=PATTERN |
6c41479b | 889 | |
a44b8c28 S |
890 | Filter the file list so that all the test files run match PATTERN. |
891 | Note that this form is distinct from the B<-re LIST OF PATTERNS> form | |
892 | below in that it allows the file list to be provided as well. | |
6c41479b | 893 | |
04c692a8 | 894 | =item * -re LIST OF PATTERNS |
6c41479b | 895 | |
04c692a8 | 896 | Filter the file list so that all the test files run match |
531e2078 | 897 | /(LIST|OF|PATTERNS)/. Note that with this form the patterns are joined |
04c692a8 DR |
898 | by '|' and you cannot supply a list of files, instead the test files |
899 | are obtained from the MANIFEST. | |
6c41479b | 900 | |
04c692a8 | 901 | =back |
6c41479b | 902 | |
04c692a8 | 903 | You can run an individual test by a command similar to |
6c41479b | 904 | |
a8d15a22 | 905 | ./perl -I../lib path/to/foo.t |
6c41479b | 906 | |
04c692a8 DR |
907 | except that the harnesses set up some environment variables that may |
908 | affect the execution of the test: | |
6c41479b JH |
909 | |
910 | =over 4 | |
911 | ||
04c692a8 | 912 | =item * PERL_CORE=1 |
6c41479b | 913 | |
a8d15a22 | 914 | indicates that we're running this test as part of the perl core test |
531e2078 | 915 | suite. This is useful for modules that have a dual life on CPAN. |
6c41479b | 916 | |
04c692a8 | 917 | =item * PERL_DESTRUCT_LEVEL=2 |
6c41479b | 918 | |
04c692a8 | 919 | is set to 2 if it isn't set already (see |
a8d15a22 | 920 | L<perlhacktips/PERL_DESTRUCT_LEVEL>). |
6c41479b | 921 | |
04c692a8 | 922 | =item * PERL |
6c41479b | 923 | |
04c692a8 DR |
924 | (used only by F<t/TEST>) if set, overrides the path to the perl |
925 | executable that should be used to run the tests (the default being | |
926 | F<./perl>). | |
6c41479b | 927 | |
04c692a8 | 928 | =item * PERL_SKIP_TTY_TEST |
6c41479b | 929 | |
a44b8c28 S |
930 | if set, tells to skip the tests that need a terminal. It's actually |
931 | set automatically by the Makefile, but can also be forced artificially | |
932 | by running 'make test_notty'. | |
6c41479b | 933 | |
04c692a8 | 934 | =back |
6c41479b | 935 | |
04c692a8 | 936 | =head3 Other environment variables that may influence tests |
6c41479b | 937 | |
04c692a8 | 938 | =over 4 |
6c41479b | 939 | |
04c692a8 | 940 | =item * PERL_TEST_Net_Ping |
6c41479b | 941 | |
04c692a8 | 942 | Setting this variable runs all the Net::Ping modules tests, otherwise |
531e2078 | 943 | some tests that interact with the outside world are skipped. See |
04c692a8 | 944 | L<perl58delta>. |
6c41479b | 945 | |
04c692a8 | 946 | =item * PERL_TEST_NOVREXX |
cce04beb | 947 | |
04c692a8 | 948 | Setting this variable skips the vrexx.t tests for OS2::REXX. |
cce04beb | 949 | |
04c692a8 | 950 | =item * PERL_TEST_NUMCONVERTS |
cce04beb | 951 | |
04c692a8 | 952 | This sets a variable in op/numconvert.t. |
cce04beb | 953 | |
ff5db609 TC |
954 | =item * PERL_TEST_MEMORY |
955 | ||
956 | Setting this variable includes the tests in F<t/bigmem/>. This should | |
a44b8c28 S |
957 | be set to the number of gigabytes of memory available for testing, eg. |
958 | C<PERL_TEST_MEMORY=4> indicates that tests that require 4GiB of | |
ff5db609 TC |
959 | available memory can be run safely. |
960 | ||
04c692a8 | 961 | =back |
cce04beb | 962 | |
04c692a8 DR |
963 | See also the documentation for the Test and Test::Harness modules, for |
964 | more environment variables that affect testing. | |
cce04beb | 965 | |
04c692a8 | 966 | =head1 MORE READING FOR GUTS HACKERS |
cce04beb | 967 | |
04c692a8 | 968 | To hack on the Perl guts, you'll need to read the following things: |
cce04beb | 969 | |
04c692a8 | 970 | =over 4 |
cce04beb | 971 | |
04c692a8 | 972 | =item * L<perlsource> |
b8ddf6b3 | 973 | |
531e2078 | 974 | An overview of the Perl source tree. This will help you find the files |
04c692a8 | 975 | you're looking for. |
b8ddf6b3 | 976 | |
04c692a8 | 977 | =item * L<perlinterp> |
b8ddf6b3 | 978 | |
04c692a8 DR |
979 | An overview of the Perl interpreter source code and some details on how |
980 | Perl does what it does. | |
b8ddf6b3 | 981 | |
04c692a8 | 982 | =item * L<perlhacktut> |
b8ddf6b3 | 983 | |
04c692a8 | 984 | This document walks through the creation of a small patch to Perl's C |
531e2078 | 985 | code. If you're just getting started with Perl core hacking, this will |
04c692a8 | 986 | help you understand how it works. |
b8ddf6b3 | 987 | |
04c692a8 | 988 | =item * L<perlhacktips> |
b8ddf6b3 | 989 | |
531e2078 | 990 | More details on hacking the Perl core. This document focuses on lower |
04c692a8 DR |
991 | level details such as how to write tests, compilation issues, |
992 | portability, debugging, etc. | |
b8ddf6b3 | 993 | |
04c692a8 | 994 | If you plan on doing serious C hacking, make sure to read this. |
b8ddf6b3 | 995 | |
04c692a8 | 996 | =item * L<perlguts> |
b8ddf6b3 | 997 | |
04c692a8 | 998 | This is of paramount importance, since it's the documentation of what |
531e2078 | 999 | goes where in the Perl source. Read it over a couple of times and it |
04c692a8 DR |
1000 | might start to make sense - don't worry if it doesn't yet, because the |
1001 | best way to study it is to read it in conjunction with poking at Perl | |
1002 | source, and we'll do that later on. | |
b8ddf6b3 | 1003 | |
04c692a8 DR |
1004 | Gisle Aas's "illustrated perlguts", also known as I<illguts>, has very |
1005 | helpful pictures: | |
9965345d | 1006 | |
04c692a8 | 1007 | L<http://search.cpan.org/dist/illguts/> |
9965345d | 1008 | |
04c692a8 | 1009 | =item * L<perlxstut> and L<perlxs> |
f1fac472 | 1010 | |
04c692a8 DR |
1011 | A working knowledge of XSUB programming is incredibly useful for core |
1012 | hacking; XSUBs use techniques drawn from the PP code, the portion of | |
531e2078 | 1013 | the guts that actually executes a Perl program. It's a lot gentler to |
04c692a8 DR |
1014 | learn those techniques from simple examples and explanation than from |
1015 | the core itself. | |
f1fac472 | 1016 | |
04c692a8 | 1017 | =item * L<perlapi> |
f1fac472 | 1018 | |
04c692a8 DR |
1019 | The documentation for the Perl API explains what some of the internal |
1020 | functions do, as well as the many macros used in the source. | |
f1fac472 | 1021 | |
04c692a8 | 1022 | =item * F<Porting/pumpkin.pod> |
f1fac472 | 1023 | |
04c692a8 DR |
1024 | This is a collection of words of wisdom for a Perl porter; some of it |
1025 | is only useful to the pumpkin holder, but most of it applies to anyone | |
1026 | wanting to go about Perl development. | |
f1fac472 | 1027 | |
04c692a8 | 1028 | =back |
f1fac472 | 1029 | |
04c692a8 | 1030 | =head1 CPAN TESTERS AND PERL SMOKERS |
f1fac472 | 1031 | |
04c692a8 DR |
1032 | The CPAN testers ( http://testers.cpan.org/ ) are a group of volunteers |
1033 | who test CPAN modules on a variety of platforms. | |
b8ddf6b3 | 1034 | |
a8d15a22 | 1035 | Perl Smokers ( http://www.nntp.perl.org/group/perl.daily-build/ and |
04c692a8 DR |
1036 | http://www.nntp.perl.org/group/perl.daily-build.reports/ ) |
1037 | automatically test Perl source releases on platforms with various | |
1038 | configurations. | |
f1fac472 | 1039 | |
531e2078 | 1040 | Both efforts welcome volunteers. In order to get involved in smoke |
04c692a8 | 1041 | testing of the perl itself visit |
531e2078 | 1042 | L<http://search.cpan.org/dist/Test-Smoke/>. In order to start smoke |
04c692a8 DR |
1043 | testing CPAN modules visit |
1044 | L<http://search.cpan.org/dist/CPANPLUS-YACSmoke/> or | |
1045 | L<http://search.cpan.org/dist/minismokebox/> or | |
1046 | L<http://search.cpan.org/dist/CPAN-Reporter/>. | |
f1fac472 | 1047 | |
04c692a8 | 1048 | =head1 WHAT NEXT? |
a422fd2d | 1049 | |
04c692a8 DR |
1050 | If you've read all the documentation in the document and the ones |
1051 | listed above, you're more than ready to hack on Perl. | |
a422fd2d | 1052 | |
04c692a8 | 1053 | Here's some more recommendations |
a422fd2d | 1054 | |
04c692a8 | 1055 | =over 4 |
a422fd2d SC |
1056 | |
1057 | =item * | |
1058 | ||
1059 | Subscribe to perl5-porters, follow the patches and try and understand | |
1060 | them; don't be afraid to ask if there's a portion you're not clear on - | |
1061 | who knows, you may unearth a bug in the patch... | |
1062 | ||
1063 | =item * | |
1064 | ||
04c692a8 | 1065 | Do read the README associated with your operating system, e.g. |
531e2078 | 1066 | README.aix on the IBM AIX OS. Don't hesitate to supply patches to that |
04c692a8 | 1067 | README if you find anything missing or changed over a new OS release. |
a1f349fd MB |
1068 | |
1069 | =item * | |
1070 | ||
a422fd2d | 1071 | Find an area of Perl that seems interesting to you, and see if you can |
a44b8c28 S |
1072 | work out how it works. Scan through the source, and step over it in |
1073 | the debugger. Play, poke, investigate, fiddle! You'll probably get to | |
04c692a8 DR |
1074 | understand not just your chosen area but a much wider range of |
1075 | F<perl>'s activity as well, and probably sooner than you'd think. | |
a422fd2d SC |
1076 | |
1077 | =back | |
1078 | ||
04c692a8 | 1079 | =head2 "The Road goes ever on and on, down from the door where it began." |
a422fd2d | 1080 | |
04c692a8 | 1081 | If you can do these things, you've started on the long road to Perl |
531e2078 | 1082 | porting. Thanks for wanting to help make Perl better - and happy |
04c692a8 | 1083 | hacking! |
a422fd2d | 1084 | |
4ac71550 TC |
1085 | =head2 Metaphoric Quotations |
1086 | ||
1087 | If you recognized the quote about the Road above, you're in luck. | |
1088 | ||
04c692a8 | 1089 | Most software projects begin each file with a literal description of |
531e2078 | 1090 | each file's purpose. Perl instead begins each with a literary allusion |
04c692a8 | 1091 | to that file's purpose. |
4ac71550 | 1092 | |
04c692a8 | 1093 | Like chapters in many books, all top-level Perl source files (along |
9e6670f3 DR |
1094 | with a few others here and there) begin with an epigrammatic |
1095 | inscription that alludes, indirectly and metaphorically, to the | |
1096 | material you're about to read. | |
4ac71550 | 1097 | |
a8d15a22 | 1098 | Quotations are taken from writings of J.R.R. Tolkien pertaining to his |
531e2078 | 1099 | Legendarium, almost always from I<The Lord of the Rings>. Chapters and |
4ac71550 TC |
1100 | page numbers are given using the following editions: |
1101 | ||
1102 | =over 4 | |
1103 | ||
04c692a8 | 1104 | =item * |
4ac71550 | 1105 | |
531e2078 | 1106 | I<The Hobbit>, by J.R.R. Tolkien. The hardcover, 70th-anniversary |
04c692a8 DR |
1107 | edition of 2007 was used, published in the UK by Harper Collins |
1108 | Publishers and in the US by the Houghton Mifflin Company. | |
4ac71550 TC |
1109 | |
1110 | =item * | |
1111 | ||
531e2078 | 1112 | I<The Lord of the Rings>, by J.R.R. Tolkien. The hardcover, |
04c692a8 DR |
1113 | 50th-anniversary edition of 2004 was used, published in the UK by |
1114 | Harper Collins Publishers and in the US by the Houghton Mifflin | |
1115 | Company. | |
4ac71550 TC |
1116 | |
1117 | =item * | |
1118 | ||
04c692a8 DR |
1119 | I<The Lays of Beleriand>, by J.R.R. Tolkien and published posthumously |
1120 | by his son and literary executor, C.J.R. Tolkien, being the 3rd of the | |
531e2078 | 1121 | 12 volumes in Christopher's mammoth I<History of Middle Earth>. Page |
04c692a8 DR |
1122 | numbers derive from the hardcover edition, first published in 1983 by |
1123 | George Allen & Unwin; no page numbers changed for the special 3-volume | |
1124 | omnibus edition of 2002 or the various trade-paper editions, all again | |
1125 | now by Harper Collins or Houghton Mifflin. | |
4ac71550 TC |
1126 | |
1127 | =back | |
1128 | ||
04c692a8 DR |
1129 | Other JRRT books fair game for quotes would thus include I<The |
1130 | Adventures of Tom Bombadil>, I<The Silmarillion>, I<Unfinished Tales>, | |
1131 | and I<The Tale of the Children of Hurin>, all but the first | |
531e2078 | 1132 | posthumously assembled by CJRT. But I<The Lord of the Rings> itself is |
04c692a8 DR |
1133 | perfectly fine and probably best to quote from, provided you can find a |
1134 | suitable quote there. | |
4ac71550 | 1135 | |
04c692a8 DR |
1136 | So if you were to supply a new, complete, top-level source file to add |
1137 | to Perl, you should conform to this peculiar practice by yourself | |
1138 | selecting an appropriate quotation from Tolkien, retaining the original | |
1139 | spelling and punctuation and using the same format the rest of the | |
531e2078 | 1140 | quotes are in. Indirect and oblique is just fine; remember, it's a |
04c692a8 | 1141 | metaphor, so being meta is, after all, what it's for. |
4ac71550 | 1142 | |
e8cd7eae GS |
1143 | =head1 AUTHOR |
1144 | ||
04c692a8 DR |
1145 | This document was originally written by Nathan Torkington, and is |
1146 | maintained by the perl5-porters mailing list. | |
b16c2e4a | 1147 |