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