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