Test library that can be run in two modes; one to generate outputs and a second to compare against them
Version 0.07
use Test::Regression; ok_regression(sub {return "hello world"}, "t/out/hello_world.txt");
Using the various Test:: modules you can compare the output of a function against what you expect. However if the output is complex and changes from version to version, maintenance of the expected output could be costly. This module allows one to use the test code to generate the expected output, so that if the differences with model output are expected, one can easily refresh the model output.
ok_regression
This function requires two arguments: a \s-1CODE\s0 ref and a file path. The \s-1CODE\s0 ref is expected to return a \s-1SCALAR\s0 string which can be compared against previous runs. If the \s-1TEST_REGRESSION_GEN\s0 is set to a true value, then the \s-1CODE\s0 ref is run and the output written to the file. Otherwise the output of the file is compared against the contents of the file. There is a third optional argument which is the test name.
If the \s-1TEST_REGRESSION_GEN\s0 environment file is unset or false in a perl sense, then the named output files must exist and be readable and the test will run normally comparing the outputs of the \s-1CODE\s0 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 \s-1CODE\s0 ref.
Nicholas Bamber, \*(C`<nicholas at periapt.co.uk>\*(C'
Please report any bugs or feature requests to \*(C`bug-test-regression at rt.cpan.org\*(C', or through the web interface at http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Test-Regression <http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Test-Regression>. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.
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 I believe adequately tested in terms of coverage.
You can find documentation for this module with the perldoc command.
perldoc Test::Regression
You can also look for information at:
\s-1RT:\s0 \s-1CPAN\s0's request tracker http://rt.cpan.org/NoAuth/Bugs.html?Dist=Test-Regression <http://rt.cpan.org/NoAuth/Bugs.html?Dist=Test-Regression>
AnnoCPAN: Annotated \s-1CPAN\s0 documentation http://annocpan.org/dist/Test-Regression <http://annocpan.org/dist/Test-Regression>
\s-1CPAN\s0 Ratings http://cpanratings.perl.org/d/Test-Regression <http://cpanratings.perl.org/d/Test-Regression>
Search \s-1CPAN\s0 http://search.cpan.org/dist/Test-Regression/ <http://search.cpan.org/dist/Test-Regression/>
Copyright 2009-10 Nicholas Bamber.
This program is free software; you can redistribute it and/or modify it under the terms of either: the \s-1GNU\s0 General Public License as published by the Free Software Foundation; or the Artistic License.
See http://dev.perl.org/licenses/ for more information.