![]() |
![]()
| ![]() |
![]()
NAMETest::PerlTidy - check that all your files are tidy. VERSIONversion 20230226 SYNOPSIS# In a file like 't/perltidy.t': use Test::PerlTidy qw( run_tests ); run_tests(); DESCRIPTIONThis rather unflattering comment was made in a piece by Ken Arnold: "Perl is a vast swamp of lexical and syntactic swill and nobody knows how to format even their own code well, but it's the only major language I can think of (with the possible exception of the recent, yet very Java-like C#) that doesn't have at least one style that's good enough." http://www.artima.com/weblogs/viewpost.jsp?thread=74230 Hmmm... He is sort of right in a way. Then again the piece he wrote was related to Python which is somewhat strict about formatting itself. Fear not though - now you too can have your very own formatting gestapo in the form of Test::PerlTidy! Simply add a test file as suggested above and any file ending in .pl, .pm, .t or .PL will cause a test fail unless it is exactly as perltidy would like it to be. REASONS TO DO THISIf the style is mandated in tests then it will be adhered to. If perltidy decides what is a good style then there should be no quibbling. If the style never changes then cvs diffs stop catching changes that are not really there. Readability might even improve. HINTSIf you want to change the default style then muck around with '.perltidyrc'; To quickly make a file work then try 'perltidy -b the_messy_file.pl'. HOW IT WORKSRuns perltidy on files and reports errors if any of the files differ after having been tidied. Does not permanently modify the files being tested. By default, perltidy will be run on files under the current directory and its subdirectories with extensions matching: ".pm .pl .PL .t" METHODSrun_tests ( [ %args ] )This is the main entry point for running tests. A number of options can be specified when running the tests, e.g.: run_tests( path => $start_dir, perltidyrc => $path_to_config_file, exclude => [ qr{\.t$}, 'inc/'], );
list_files ( [ start_path | %args ] )Generate the list of files to be tested. Generally not called directly. load_file ( path_to_file )Load the file to be tested from disk and return the contents. Generally not called directly. is_file_tidy ( path_to_file [ , path_to_perltidyrc ] [, $named_args] )Test if a file is tidy or not. Generally not called directly. $named_args can be a hash ref which may have a key called 'perltidy_options' that refers to a hash ref of options that will be passed to Perl::Tidy::perltidy(). ($named_args was added in version 20200411). SEE ALSOPerl::Tidy ORIGINAL AUTHOREdmund von der Burg, "<evdb at ecclestoad.co.uk>" CONTRIBUTORSDuncan J. Ferguson, "<duncan_j_ferguson at yahoo.co.uk>" Stephen, "<stephen at enterity.com>" Larry Leszczynski, "<larryl at cpan.org>" Shlomi Fish, <https://www.shlomifish.org/> SUGGESTIONSPlease let me know if you have any comments or suggestions. <http://ecclestoad.co.uk/> COPYRIGHTCopyright 2007 Edmund von der Burg, all rights reserved. LICENSEThis library is free software . You can redistribute it and/or modify it under the same terms as perl itself. SUPPORTWebsitesThe following websites have more information about this module, and may be of help to you. As always, in addition to those websites please use your favorite search engine to discover more resources.
Bugs / Feature RequestsPlease report any bugs or feature requests by email to "bug-test-perltidy at rt.cpan.org", or through the web interface at <https://rt.cpan.org/Public/Bug/Report.html?Queue=Test-PerlTidy>. You will be automatically notified of any progress on the request by the system. Source CodeThe code is open to the world, and available for you to hack on. Please feel free to browse it and play with it, or whatever. If you want to contribute patches, please send me a diff or prod me to pull from your repository :) <https://github.com/shlomif/test-perltidy> git clone https://github.com/shlomif/Test-PerlTidy AUTHORShlomi Fish <shlomif@cpan.org> BUGSPlease report any bugs or feature requests on the bugtracker website <https://github.com/shlomif/test-perltidy/issues> When submitting a bug or request, please include a test-file or a patch to an existing test-file that illustrates the bug or desired feature. COPYRIGHT AND LICENSEThis software is copyright (c) 2023 by Edmund von der Burg. This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.
|