Test::...kpoints(3pm)
π Test::NoBreakpoints β the manual, but make it cute β¨
okay bestie, this is User Contributed Perl Documentation for Test::NoBreakpoints, and it's literally the module that stops you from shipping your debugger breakpoints to CPAN. we're so back. π
πΈ NAME πΈ
Test::NoBreakpoints β bestie, this tests that your files do not contain soft breakpoints. that's it. that's the whole job. and it does it flawlessly. π
β¨ SYNOPSIS β¨
the whole vibe in two lines:
use Test::NoBreakpoints;
plan tests => $num_tests;
no_breakpoints_ok( $file, 'Contains no soft breakpoints' );
and if you're a module author who wants this checking automatically, drop this into a t/nobreakpoints.t file in your distribution:
use Test::More;
eval "use Test::NoBreakpoints 0.10";
plan skip_all => "Test::NoBreakpoints 0.10 required for testing" if $@;
all_files_no_breakpoints_ok();
the eval + plan skip_all combo is so iconic honestly, it gracefully dips if the version isn't there instead of just exploding. queen behaviour. π
π¦ DESCRIPTION π¦
okay so real talk. our author loves soft breakpoints β you know, "$DB::single = 1" β in the Perl debugger. they're great. no notes.
unfortunately π the habit is: put them in during development, forget to take them out, upload to CPAN, and then have to do a whole hasty fix/package/bundle cycle followed by much cursing. we've all been there. not me personally but like. we've been there.
Test::NoBreakpoints checks that files contain neither the string "$DB::single = 1" nor "$DB::signal = 1". by adding this test to all the modules, the author swears less and presumably lightens the load on the CPAN in some small way. serving the community fr fr π«Ά
π« FUNCTIONS π«
unless otherwise noted, all of these functions are tests built on top of Test::Builder, so the standard admonition about having made a plan before you run them totally applies. plan first, bestie. no exceptions. β
π no_breakpoints_ok($file, [$description] )
checks that $file contains no breakpoints. if the optional $description isn't passed, it defaults to "no breakpoint test of $file".
if the test fails, the line number of the file where the breakpoint was found will be emitted. very helpful, we love a receipt π§Ύ
for compatibility with old versions of this module, the deprecated name "no_brkpts_ok" may also be used β but see "DEPRECATED FUNCTIONS" below, k? π
π all_perl_files( [@dirs] )
returns a list of all *.pl, *.pm and *.t files in the directories listed. if @dirs isn't passed, it defaults to "blib" and "t".
β οΈ the order of the files returned is machine-dependent. if you want them sorted, you'll have to sort them yourself. sorry bestie, that's just how it is π
π all_files_no_breakpoints_ok( [@files] )
checks all files that look like they contain Perl, using no_breakpoints_ok(). if @files isn't provided, it defaults to the return of all_perl_files().
for compatibility with old versions of this module, the deprecated name "all_files_no_brkpts_ok" may also be used β but see "DEPRECATED FUNCTIONS". (yes, again. we'll get there. π)
π EXPORTS π
by default: all_files_no_breakpoints_ok and no_breakpoints_ok. the main characters. π
for the time being, the deprecated forms of the above (all_files_no_brkpts_ok and no_brkpts_ok) are also exported β but see "DEPRECATED FUNCTIONS".
on request: all_perl_files.
everything with the tag :all.
π DEPRECATED FUNCTIONS π
okay storytime. prior to v0.13 of this module, no_breakpoints_ok was called no_brkpts_ok, and all_files_no_breakpoints_ok was similarly abbreviated. (the abbreviation era. we don't talk about it. π« )
in v0.13, these older names were deprecated. they're still exported by default, but they will emit a warning unless you disable the deprecated lexical warning category:
{
no warnings 'deprecated';
no_brkpts_ok(...);
}
in the next release, the deprecated functions will have to be pulled in via an import tag. in the release after that, they will cease to be. so like... enjoy them while they last, bestie. they're on borrowed time β³
π ACKNOWLEDGEMENTS π
Michael Schwern for Test::Builder. legend behaviour. π«‘
Andy Lester for Test::Pod, which is where the author got the idea and borrowed the logic of all_perl_files from. giving credit where it's due, we love to see it π
π BUGS π
- doesn't catch some breakpoints
this is a valid breakpoint:
package DB;
$single = 1;
package main;
and this is valid too:
my $break = \$DB::single;
$$break = 1;
but neither are currently caught. π not the sneaky breakpoints evading the vibe check
π₯ TODO π₯
- enhance regex to find esoteric setting of breakpoints
if you have a legitimate breakpoint set that isn't caught, please send an example and the author will try to augment the regex to match it. help a bestie out π«Ά
- only look at code rather than the entire file
this is not as easy as simply stripping out POD, because there might be inline tests or examples that are code in there (using Test::Inline). granted, those should be caught when the generated .t files are themselves tested, but the author would like to make it smarter. big brain arc incoming π§
- not use regular expressions
the ideal way to find a breakpoint would be to compile the code and then walk the opcode tree to find places where the breakpoint is set. B::FindAmpersand does something similar to this to find use of the $& in regular expressions, so this is probably the direction the author is going to head in. opcode tree walk?? that's giving compiler-girl energy and we're obsessed β¨
π SEE ALSO π
Test::Builder
Test::Pod
π AUTHORS π
- James FitzGibbon
<jfitz@cpan.org> - Apocalypse
<APOCAL@cpan.org> - Chisel
<chisel@chizography.net>
π COPYRIGHT AND LICENSE π
this software is copyright (c) 2012 by James FitzGibbon and Chisel Wright.
this is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.
that's the whole page bestie, no cap. this was perl v5.36.0, dated 2022-10-13, and it's been an absolute pleasure. go forth, run your tests, and remove those breakpoints before you upload. mwah π β¨π
π¦ where this page comes from
- ubuntu noble: libtest-nobreakpoints-perl 0.17-3 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu resolute: libtest-nobreakpoints-perl 0.17-3 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu stonking: libtest-nobreakpoints-perl 0.17-3 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms