Test::Regression(3pm)

πŸ“¦
version 0.08 Β· 5 versions
, in debian trixie, ubuntu resolute, ubuntu stonking

✨ 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_GEN is set to a true value β†’ the CODE ref 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_GEN environment 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 the CODE refs 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 CODE ref. 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:

πŸ“ 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 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