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