Test::...kpoints(3pm)

πŸ“¦
version 0.17 Β· 5 versions
, in ubuntu noble, ubuntu resolute, ubuntu stonking

πŸ’– 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>

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