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