.\" Automatically generated by Pod::Man 4.14 (Pod::Simple 3.42) .\" .\" 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 .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . 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 "Dist::Zilla::Util::Test::KENTNL::dztest 3pm" .TH Dist::Zilla::Util::Test::KENTNL::dztest 3pm "2022-06-13" "perl v5.34.0" "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" Dist::Zilla::Util::Test::KENTNL::dztest \- Shared dist testing logic for easy dzil things .SH "VERSION" .IX Header "VERSION" version 1.005014 .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 3 \& use Test::More; \& use Test::DZil qw( simple_ini ); \& use Dist::Zilla::Util::Test::KENTNL qw( dztest ); \& \& my $test = dztest; \& \& ## utility method. \& $test\->add_file( \*(Aqdist.ini\*(Aq, simple_ini( .... )); \& \& ## build the dist \& # 1x subtest \& $test\->build_ok; \& \& ## assert prereqs are identical to the hash \& ## extracting them from distmeta \& # 1x subtest \& $test\->prereqs_deeply( { } ); \& \& ## Test for specific log messages by regex \& # 1x subtest \& # \- tests there are messages \& # \- each regex must match a message \& my @list = ( \& [ $regex, $indepdent_reason ], \& [ $regex ], \& ); \& $test\->has_messages( $reason, \e@list ); \& \& ## Test for any deep structure addressed \& ## By a Data::DPath expression \& # 1x subtest \& # \- asserts the expression returns a result \& # \- compares the structure against the expected one. \& $test\->meta_path_deeply( \& \*(Aq/author/*/[1]\*(Aq, \& [ \*(AqE. Xavier Ample \*(Aq ], \& \*(AqThe 1st author is the example author emitted by simple_ini\*(Aq \& ); \& \& ## Test for a file existing on the build side \& ## and return it if it exists. \& my $file = $test\->test_has_built_file(\*(Aqdist.ini\*(Aq); .Ve .SH "METHODS" .IX Header "METHODS" .ie n .SS """add_file""" .el .SS "\f(CWadd_file\fP" .IX Subsection "add_file" Add a file to the scratch directory to be built. .PP .Vb 5 \& # \->add_file( $path, $string ); \& # \->add_file( \e@path, $string ); \& $test\->add_file(\*(Aqdist.ini\*(Aq, simple_ini() ); \& $test\->add_file(\*(Aqlib/Foo.pm\*(Aq, $content ); \& $test\->add_file([ \*(Aqlib\*(Aq,\*(AqFoo.pm\*(Aq ], $content ); .Ve .ie n .SS """build_ok""" .el .SS "\f(CWbuild_ok\fP" .IX Subsection "build_ok" Build the dist safely, and report \f(CW\*(C`ok\*(C'\fR if the dist builds \f(CW\*(C`ok\*(C'\fR, spewing file listings via \f(CW\*(C`note\*(C'\fR .PP \&\f(CW\*(C`BAIL_OUT\*(C'\fR is triggered if any of \f(CW\*(C`add_file\*(C'\fR don't arrive in the intended location. .ie n .SS """prereqs_deeply""" .el .SS "\f(CWprereqs_deeply\fP" .IX Subsection "prereqs_deeply" Demand \f(CW\*(C`distmeta\*(C'\fR \f(CW\*(C`prereqs\*(C'\fR exactly match those specified. .PP .Vb 1 \& $test\->prereqs_deeply( { hash } ); .Ve .PP This is just a more memorable version of .PP .Vb 1 \& $test\->meta_path_deeply(\*(Aq/prereqs/\*(Aq, { }); .Ve .ie n .SS """has_messages""" .el .SS "\f(CWhas_messages\fP" .IX Subsection "has_messages" Test that there are messages, and all the given rules match messages. .PP .Vb 4 \& $test\->has_messages( \*(AqSome descriptor\*(Aq, [ \& [ $regex, $description ], \& [ $regex, $description ], \& ]); .Ve .ie n .SS """meta_path_deeply""" .el .SS "\f(CWmeta_path_deeply\fP" .IX Subsection "meta_path_deeply" .Vb 1 \& $test\->meta_path_deeply( $expression, $expected_data, $reason ); .Ve .PP Uses \f(CW$expression\fR as a \f(CW\*(C`Data::DPath\*(C'\fR expression to pick a \fI\s-1LIST\s0\fR of nodes from \f(CW\*(C`distmeta\*(C'\fR, and compare that \fI\s-1LIST\s0\fR vs \f(CW$expected_data\fR .PP .Vb 2 \& # Matches only the first author. \& $test\->meta_path_deeply(\*(Aq/author/*/[1]\*(Aq, [\*(AqSomeAuthorName \*(Aq], $reason ); \& \& # Matches all authors \& $test\->meta_path_deeply(\*(Aq/author/*/*\*(Aq, [\*(AqSomeAuthorName \*(Aq,\*(AqAuthor2\*(Aq, ..], $reason ); .Ve .ie n .SS """test_has_built_file""" .el .SS "\f(CWtest_has_built_file\fP" .IX Subsection "test_has_built_file" Test ( as in, \f(CW\*(C`Test::More::ok\*(C'\fR ) that a file exists in the \f(CW\*(C`dzil\*(C'\fR build output directory. .PP Also returns it if it exists. .PP .Vb 1 \& $test\->test_has_built_file(\*(Aqdist.ini\*(Aq); # ok/fail \& \& my $object = test\->test_has_built_file(\*(Aqdist.ini\*(Aq); # ok/fail + return .Ve .ie n .SS """create_plugin""" .el .SS "\f(CWcreate_plugin\fP" .IX Subsection "create_plugin" Create an instance of the named plugin and return it. .PP .Vb 4 \& my $t = dztest(); \& $t\->add_file(\*(Aqdist.ini\*(Aq, simple_ini( ... )); \& my $plugin = $t\->create_plugin(\*(AqGatherDir\*(Aq => { ignore_dotfiles => 1 }); \& # poke at $plugin here .Ve .PP Note: This lets you test plugins outside the requirement of inter-operating with \f(CW\*(C`dzil\*(C'\fR phases, but has the downside of not interacting with \f(CW\*(C`dzil\*(C'\fR phases, or even being \fI*seen*\fR by \f(CW\*(C`dzil\*(C'\fR phases. .PP But this is \s-1OK\s0 if you want to directly test a modules interface instead of doing it through the proxy of \f(CW\*(C`dzil\*(C'\fR .PP You can also subsequently create many such objects without requiring a \f(CW\*(C`dzil build\*(C'\fR penalty. .ie n .SS """source_file""" .el .SS "\f(CWsource_file\fP" .IX Subsection "source_file" Re-fetch content added with \f(CW\*(C`add_file\*(C'\fR. .PP You probably want \f(CW\*(C`built_file\*(C'\fR. .PP .Vb 2 \& $test\->source_file( $path ); \& $test\->source_file( \e@path ); .Ve .PP Returns \f(CW\*(C`undef\*(C'\fR if the file does not exist. .PP .Vb 3 \& if ( my $content = $test\->source_file(\*(Aqdist.ini\*(Aq) ) { \& print $content\->slurp_raw; \& } .Ve .ie n .SS """safe_build""" .el .SS "\f(CWsafe_build\fP" .IX Subsection "safe_build" Ensure the distribution is built safely, returns exceptions or \f(CW\*(C`undef\*(C'\fR. .PP .Vb 3 \& if ( $test\->safe_build ) { \& say "Failed build"; \& } .Ve .ie n .SS """safe_configure""" .el .SS "\f(CWsafe_configure\fP" .IX Subsection "safe_configure" Construct the internal builder object safely. Returns exceptions or \f(CW\*(C`undef\*(C'\fR. .PP .Vb 1 \& if( $test\->configure ) { say "configure failed" } .Ve .ie n .SS """built_file""" .el .SS "\f(CWbuilt_file\fP" .IX Subsection "built_file" Returns the named file if it exists in the build, \f(CW\*(C`undef\*(C'\fR otherwise. .PP .Vb 1 \& my $file = $test\->built_file(\*(Aqdist.ini\*(Aq); .Ve .ie n .SS """note_tempdir_files""" .el .SS "\f(CWnote_tempdir_files\fP" .IX Subsection "note_tempdir_files" Recursively walk \f(CW\*(C`tempdir\*(C'\fR and note its contents. .ie n .SS """note_builddir_files""" .el .SS "\f(CWnote_builddir_files\fP" .IX Subsection "note_builddir_files" Recursively walk \f(CW\*(C`builddir\*(C'\fR(output) and note its contents. .ie n .SS """has_message""" .el .SS "\f(CWhas_message\fP" .IX Subsection "has_message" Assert there are messages, and this single message exists: .PP .Vb 1 \& $test\->has_message( $regex, $description ); .Ve .ie n .SS """run_command""" .el .SS "\f(CWrun_command\fP" .IX Subsection "run_command" Execute a Dist::Zilla command in the constructed scratch directory. .PP .Vb 1 \& $test\->run_command([\*(Aqbuild\*(Aq,\*(Aqfoo\*(Aq]); .Ve .PP The syntax is technically: .PP .Vb 1 \& $test\->run_command( $argv, $arg ); .Ve .PP But I'm yet to work out the meaning of the latter. .SH "ATTRIBUTES" .IX Header "ATTRIBUTES" .ie n .SS """configure""" .el .SS "\f(CWconfigure\fP" .IX Subsection "configure" Construct the internal builder object. .PP .Vb 1 \& $test\->configure; .Ve .SH "AUTHOR" .IX Header "AUTHOR" Kent Fredric .SH "COPYRIGHT AND LICENSE" .IX Header "COPYRIGHT AND LICENSE" This software is copyright (c) 2017 by Kent Fredric . .PP This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.