.\" -*- mode: troff; coding: utf-8 -*- .\" Automatically generated by Pod::Man 5.01 (Pod::Simple 3.43) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" \*(C` and \*(C' are quotes in nroff, nothing in troff, for use with C<>. .ie n \{\ . ds C` "" . ds C' "" 'br\} .el\{\ . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is >0, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{\ . if \nF \{\ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{\ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" ======================================================================== .\" .IX Title "Test::Regression 3pm" .TH Test::Regression 3pm 2024-03-08 "perl v5.38.2" "User Contributed Perl Documentation" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH NAME Test::Regression \- Test library that can be run in two modes; one to generate outputs and a second to compare against them .SH VERSION .IX Header "VERSION" Version 0.08 .SH SYNOPSIS .IX Header "SYNOPSIS" .Vb 1 \& use Test::Regression; \& \& ok_regression(sub {return "hello world"}, "t/out/hello_world.txt"); .Ve .SH DESCRIPTION .IX Header "DESCRIPTION" 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. .SH EXPORT .IX Header "EXPORT" ok_regression .SH FUNCTIONS .IX Header "FUNCTIONS" .SS ok_regression .IX Subsection "ok_regression" This function requires two arguments: a CODE ref and a file path. The CODE ref is expected to return a SCALAR string which can be compared against previous runs. If the TEST_REGRESSION_GEN is set to a true value, then the CODE 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. .SH "ENVIRONMENT VARIABLES" .IX Header "ENVIRONMENT VARIABLES" .SS TEST_REGRESSION_GEN .IX Subsection "TEST_REGRESSION_GEN" 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 will run 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. .SH AUTHOR .IX Header "AUTHOR" Nicholas Bamber, \f(CW\*(C`\*(C'\fR .SH BUGS .IX Header "BUGS" Please report any bugs or feature requests to \f(CW\*(C`bug\-test\-regression at rt.cpan.org\*(C'\fR, or through the web interface at . I will be notified, and then you'll automatically be notified of progress on your bug as I make changes. .SS "testing of STDERR" .IX Subsection "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 I believe adequately tested in terms of coverage. .SH SUPPORT .IX Header "SUPPORT" You can find documentation for this module with the perldoc command. .PP .Vb 1 \& perldoc Test::Regression .Ve .PP You can also look for information at: .IP \(bu 4 RT: CPAN's request tracker .Sp .IP \(bu 4 AnnoCPAN: Annotated CPAN documentation .Sp .IP \(bu 4 CPAN Ratings .Sp .IP \(bu 4 Search CPAN .Sp .SH ACKNOWLEDGEMENTS .IX Header "ACKNOWLEDGEMENTS" .IP "Some documentation improvements have been suggested by toolic (http://perlmonks.org/?node_id=622051)." 4 .IX Item "Some documentation improvements have been suggested by toolic (http://perlmonks.org/?node_id=622051)." .PD 0 .IP "Thanks to Filip Graliński for pointing out I need to test against output of zero length and providing a patch." 4 .IX Item "Thanks to Filip Graliński for pointing out I need to test against output of zero length and providing a patch." .IP "Thanks to Christian Walde for pestering me about newline Windows compatibility issues and for providing a patch." 4 .IX Item "Thanks to Christian Walde for pestering me about newline Windows compatibility issues and for providing a patch." .PD .SH "COPYRIGHT & LICENSE" .IX Header "COPYRIGHT & LICENSE" Copyright 2009\-10 Nicholas Bamber. .PP 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. .PP See http://dev.perl.org/licenses/ for more information.