Test::PerlTidy(3pm)

πŸ“¦
this version Β· 2 versions
, in opensuse-leap 16.0

πŸ’– Test::PerlTidy πŸ’–

okay so bestie, this is the Test::PerlTidy manual page β€” it's the module that checks all your files are tidy ✨ (yes, that's literally the whole personality).

version 20230226 πŸŽ€


🌸 SYNOPSIS 🌸

# In a file like 't/perltidy.t':

use Test::PerlTidy qw( run_tests );

run_tests();

πŸ¦‹ DESCRIPTION πŸ¦‹

so there's this piece by Ken Arnold that made a rather unflattering comment, and I simply have to show you:

"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's sort of right in a way 😭 then again the piece he wrote was related to Python, which is somewhat strict about formatting itself. so, y'know. context.

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. no notes. periodt.


πŸ”₯ REASONS TO DO THIS πŸ”₯

  • If 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. (iconic, honestly)

πŸŽ€ HINTS πŸŽ€

  • If 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 WORKS ⭐

Runs perltidy on files and reports errors if any of the files differ after having been tidied. Does not permanently modify the files being tested β€” no cap, your files stay safe πŸ’œ

By default, perltidy will be run on files under the current directory and its subdirectories with extensions matching: .pm .pl .PL .t


πŸ‘‘ METHODS πŸ‘‘

🌈 run_tests ( [ %args ] )

This is the main entry point for running tests, bestie β€” this is the one you actually call.

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/'],
);
  • debug β€” set debug to a true value to enable additional diagnostic output, in particular info about any processing done as a result of specifying the exclude option. Default is false.
  • exclude β€” run_tests() will look for files to test under the current directory and its subdirectories. By default, it will exclude files in the ./blib/ directory. Set exclude to a listref of exclusion criteria if you need to specify additional rules by which files will be excluded.

If an item in the exclude list is a string, e.g. ./blib/, it will be assumed to be a path prefix. Files will be excluded if that string matches their path at the beginning.

If an item in the exclude list is a regex object, e.g. qr{\.t$}, files will be excluded if that regex matches their path.

Note that the paths of files to be tested are canonified using File::Spec->canonpath before any matching is attempted, which can impact how the exclusion rules apply. If your exclusion rules do not seem to be working, turn on the debug option to see the paths of the files that are being kept/excluded. πŸ‘€
  • path β€” set path to the path to the top-level directory which contains the files to be tested. Defaults to the current directory (i.e. .).
  • perltidyrc β€” by default, perltidy will attempt to read its options from the .perltidyrc file on your system. Set perltidyrc to the path to a custom file if you would like to control the perltidy options used during testing.
  • mute β€” by default, run_tests() will output diagnostics about any errors reported by perltidy, as well as any actual differences found between the pre-tidied and post-tidied files. Set mute to a true value to turn off that diagnostic output. 🀫
  • skip_all β€” set skip_all to a true value to skip all tests. Default is false.
  • perltidy_options β€” pass these to Perl::Tidy::perltidy(). (Added in version 20200411 .)

🧚 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 ALSO 🌟

Perl::Tidy


πŸ’œ ORIGINAL AUTHOR πŸ’œ

Edmund von der Burg, <evdb at ecclestoad.co.uk>


🫢 CONTRIBUTORS 🫢

  • Duncan 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/>

🌸 SUGGESTIONS 🌸

Please let me know if you have any comments or suggestions.

<http://ecclestoad.co.uk/>


Copyright 2007 Edmund von der Burg, all rights reserved.


✨ LICENSE ✨

This library is free software . You can redistribute it and/or modify it under the same terms as perl itself.


πŸ¦‹ SUPPORT πŸ¦‹

πŸ’» Websites

The 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.

  • MetaCPAN β€” a modern, open-source CPAN search engine, useful to view POD in HTML format.

<https://metacpan.org/release/Test-PerlTidy>

  • RT: CPAN's Bug Tracker β€” the RT ( Request Tracker ) website is the default bug/issue tracking system for CPAN.

<https://rt.cpan.org/Public/Dist/Display.html?Name=Test-PerlTidy>

  • CPANTS β€” the CPANTS is a website that analyzes the Kwalitee ( code metrics ) of a distribution.

<http://cpants.cpanauthors.org/dist/Test-PerlTidy>

  • CPAN Testers β€” the CPAN Testers is a network of smoke testers who run automated tests on uploaded CPAN distributions.

<http://www.cpantesters.org/distro/T/Test-PerlTidy>

  • CPAN Testers Matrix β€” the CPAN Testers Matrix is a website that provides a visual overview of the test results for a distribution on various Perls/platforms.

<http://matrix.cpantesters.org/?dist=Test-PerlTidy>

  • CPAN Testers Dependencies β€” the CPAN Testers Dependencies is a website that shows a chart of the test results of all dependencies for a distribution.

<http://deps.cpantesters.org/?module=Test::PerlTidy>

πŸ› Bugs / Feature Requests

Please 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. slay, automatic updates πŸ’…

πŸ“¦ Source Code

The 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

πŸ’… AUTHOR πŸ’…

Shlomi Fish <shlomif@cpan.org>


😭 BUGS 😭

Please 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. (fr fr, it makes everyone's life so much easier 🫢)


This 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.


okay that's the whole thing, you're fully caught up bestie πŸ’– this page was served up by perl v5.42.0, dated 2023-02-27, and it's the Test::PerlTidy(3pm) we've been vibing with the whole time. go make your files tidy, the formatting gestapo believes in you πŸ‘‘βœ¨

πŸ“¦ where this page comes from