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