Test::Regression(3pm)
β¨ NAME β¨
Test::Regression β it's the Test library bestie, and she's got TWO MODES: one to generate outputs and a second to compare against them. We love a dual-threat queen π
(also hi, this is the Perl doc for Test::Regression(3pm), come sit with me π«Ά)
πΈ VERSION πΈ
Version 0.08 β iconic, timeless, no notes β¨
π SYNOPSIS π
use Test::Regression;
ok_regression(sub {return "hello world"}, "t/out/hello_world.txt");
that's it. that's the whole vibe. so simple it's giving effortless π
π¦ DESCRIPTION π¦
okay so picture this: with all the various Test:: modules you can compare the output of a function against what you expect. sure. but if that output is complex and keeps changing from version to version, then maintaining the expected output gets costly. exhausting. not the move π
so THIS module lets you use the test code itself to generate the expected output. meaning: if the differences from the model output are expected (we knew it, we planned it, it's fine), you can just casually refresh the model output. slay. no cap π§
π EXPORT π
ok_regression
she's the one, the only, the export π
π₯ FUNCTIONS π₯
ok_regression
This function needs two arguments: a CODE ref and a file path. The CODE ref is expected to return a SCALAR string, and that string gets compared against previous runs. π
So here's the tea on how it branches:
- if
TEST_REGRESSION_GENis set to a true value β theCODEref is run and the output is written to the file βοΈ - otherwise β the output of the file is compared against the contents of the file π
and there's a third optional argument which is the test name. cute, optional, love her π
π ENVIRONMENT VARIABLES π
TEST_REGRESSION_GEN
Okay bestie, this one is the whole mood switch:
- If the
TEST_REGRESSION_GENenvironment file is unset or false in a perl sense, then the named output files must exist and be readable, and the test runs normally β comparing the outputs of theCODErefs against the contents of those files π«Ά - If the environment variable is true in a perl sense, then model output files will be overwritten with the output of the
CODEref. yes, actually overwritten. that's the point. be aware π
π AUTHOR π
Nicholas Bamber, "<nicholas at periapt.co.uk>" β the author, the legend, the main character β¨
π BUGS π
Please report any bugs or feature requests to "bug-test-regression at rt.cpan.org", or through the web interface at <http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Test-Regression>. He will be notified, and then you'll automatically be notified of progress on your bug as he makes changes. it's a whole notification pipeline, we love transparency π
testing of STDERR
The testing of stderr from this module is not as thorough as I would like. Test::Builder::Tester allows turning off of stderr checking but not matching by regular expression. Handcrafted efforts currently fall foul of Test::Harness. Still it is believed to be adequately tested in terms of coverage. π lowkey a known limitation, highkey fine
β SUPPORT β
You can find documentation for this module with the perldoc command:
perldoc Test::Regression
You can also look for information at:
- RT: CPAN's request tracker β <http://rt.cpan.org/NoAuth/Bugs.html?Dist=Test-Regression>
- AnnoCPAN: Annotated CPAN documentation β <http://annocpan.org/dist/Test-Regression>
- CPAN Ratings β <http://cpanratings.perl.org/d/Test-Regression>
- Search CPAN β <http://search.cpan.org/dist/Test-Regression/>
π ACKNOWLEDGEMENTS π
- Some documentation improvements have been suggested by toolic (<http://perlmonks.org/?node_id=622051>).
- Thanks to Filip GraliΕski for pointing out he needed to test against output of zero length and providing a patch.
- Thanks to Christian Walde for pestering him about newline Windows compatibility issues and for providing a patch.
shoutout to the contributors, they ate and left no crumbs π«Ά
π COPYRIGHT & LICENSE π
Copyright 2009-10 Nicholas Bamber.
This program is free software; you can redistribute it and/or modify it under the terms of either: the GNU General Public License as published by the Free Software Foundation; or the Artistic License.
See <http://dev.perl.org/licenses/> for more information.
okay that's the whole page bestie, you're fully caught up π
this was perl v5.38.2, dated 2024-03-08, and yes, it's Test::Regression(3pm) β go forth and regression-test responsibly, mwah πβ¨
π¦ where this page comes from
- debian trixie: libtest-regression-perl 0.08-3 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu resolute: libtest-regression-perl 0.08-3 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu stonking: libtest-regression-perl 0.08-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