.\" Automatically generated by Pod::Man 4.14 (Pod::Simple 3.40) .\" .\" 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 "POE-GEN-TESTS 1p" .TH POE-GEN-TESTS 1p "2020-12-29" "perl v5.32.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" poe\-gen\-tests \- generate standard POE tests for third\-party modules .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 5 \& poe\-gen\-tests \-\-dirbase t/loops \e \& \-\-loop Glib \e \& \-\-loop Kqueue \e \& \-\-loop Event::Lib \e \& \-\-loop POE::XS::Loop::Poll .Ve .SH "DESCRIPTION" .IX Header "DESCRIPTION" This program and the accompanying POE::Test::Loop::* modules make up \&\s-1POE\s0's tests for POE::Loop subclasses. These tests are designed to run identically regardless of the current event loop. \s-1POE\s0 uses them to test the event loops it bundles: .PP .Vb 5 \& POE::Loop::Gtk \& POE::Loop::IO_Poll (\-\-loop IO::Poll) \& POE::Loop::Tk \& POE::Loop::Event \& POE::Loop::Select .Ve .PP Developers of other POE::Loop modules are encouraged use this package to generate over 420 comprehensive tests for their own work. .SH "USAGE" .IX Header "USAGE" poe-gen-tests creates test files for one or more event loops beneath the directory specified in \-\-dirbase. For example, .PP .Vb 1 \& poe\-gen\-tests \-\-dirbase t/loops \-\-loop Select .Ve .PP generates the following test files: .PP .Vb 10 \& t/loops/select/all_errors.t \& t/loops/select/comp_tcp.t \& t/loops/select/comp_tcp_concurrent.t \& t/loops/select/connect_errors.t \& t/loops/select/k_alarms.t \& t/loops/select/k_aliases.t \& t/loops/select/k_detach.t \& t/loops/select/k_selects.t \& t/loops/select/k_sig_child.t \& t/loops/select/k_signals.t \& t/loops/select/k_signals_rerun.t \& t/loops/select/sbk_signal_init.t \& t/loops/select/ses_nfa.t \& t/loops/select/ses_session.t \& t/loops/select/wheel_accept.t \& t/loops/select/wheel_curses.t \& t/loops/select/wheel_readline.t \& t/loops/select/wheel_readwrite.t \& t/loops/select/wheel_run.t \& t/loops/select/wheel_sf_ipv6.t \& t/loops/select/wheel_sf_tcp.t \& t/loops/select/wheel_sf_udp.t \& t/loops/select/wheel_sf_unix.t \& t/loops/select/wheel_tail.t .Ve .PP The \-\-loop parameter is either a POE::Loop::... class name or the event loop class that will complete the POE::Loop::... package name. .PP .Vb 2 \& poe\-gen\-tests \-\-dirbase t/loops \-\-loop Event::Lib \& poe\-gen\-tests \-\-dirbase t/loops \-\-loop POE::Loop::Event_Lib .Ve .PP poe-gen-tests looks for a \*(L"=for poe_tests\*(R" or \*(L"=begin poe_tests\*(R" section within the POE::Loop class being tested. If defined, this section should include a single function, \fBskip_tests()\fR, that determines whether any given test should be skipped. .PP Please see perlpod for syntax for \*(L"=for\*(R" and \*(L"=begin\*(R". Also see \&\s-1PODDITIES\s0 for notable differences between POE::Test::Loop's \s-1POD\s0 support and the standard. .PP \&\fBskip_tests()\fR is called with one parameter, the base name of the test about to be executed. It returns false if the test should run, or a message that will be displayed to the user explaining why the test will be skipped. This message is passed directly to Test::More's \&\fBplan()\fR along with \*(L"skip_all\*(R". The logic is essentially: .PP .Vb 3 \& if (my $why = skip_tests("k_signals_rerun")) { \& plan skip_all => $why; \& } .Ve .PP \&\fBskip_tests()\fR should load any modules required by the event loop. See most of the examples below. .SS "Example poe_tests Directives" .IX Subsection "Example poe_tests Directives" POE::Loop::Event checks whether the Event module exists and can be loaded, then whether specific tests can run under specific operating systems. .PP .Vb 10 \& =for poe_tests \& sub skip_tests { \& return "Event tests require the Event module" if ( \& do { eval "use Event"; $@ } \& ); \& my $test_name = shift; \& if ($test_name eq "k_signals_rerun" and $^O eq "MSWin32") { \& return "This test crashes Perl when run with Tk on $^O"; \& } \& if ($test_name eq "wheel_readline" and $^O eq "darwin") { \& return "Event skips two of its own tests for the same reason"; \& } \& } .Ve .PP POE::Loop::Gtk checks whether \s-1DISPLAY\s0 is set, which implies that X is running. It then checks whether Gtk is available, loadable, and safely initializable before skipping specific tests. .PP .Vb 10 \& =for poe_tests \& sub skip_tests { \& my $test_name = shift; \& return "Gtk needs a DISPLAY (set one today, okay?)" unless ( \& defined $ENV{DISPLAY} and length $ENV{DISPLAY} \& ); \& return "Gtk tests require the Gtk module" if do { eval "use Gtk"; $@ }; \& return "Gtk init failed. Is DISPLAY valid?" unless defined Gtk\->init_check; \& if ($test_name eq "z_rt39872_sigchld_stop") { \& return "Gdk crashes"; \& } \& return; \& } .Ve .PP POE::Loop::IO_Poll checks for system compatibility before verifying that IO::Poll is available and loadable. .PP .Vb 7 \& =for poe_tests \& sub skip_tests { \& return "IO::Poll is not 100% compatible with $^O" if $^O eq "MSWin32"; \& return "IO::Poll tests require the IO::Poll module" if ( \& do { eval "use IO::Poll"; $@ } \& ); \& } .Ve .PP POE::Loop::Select has no specific requirements. .PP .Vb 2 \& =for poe_tests \& sub skip_tests { return } .Ve .PP POE::Loop::Tk needs an X display (except on Windows). Tk is not safe for \fBfork()\fR, so skip tests that require forking. And finally, check whether the Tk module is available, loadable, and runnable. .PP .Vb 10 \& =for poe_tests \& sub skip_tests { \& return "Tk needs a DISPLAY (set one today, okay?)" unless ( \& (defined $ENV{DISPLAY} and length $ENV{DISPLAY}) or $^O eq "MSWin32" \& ); \& my $test_name = shift; \& if ($test_name eq "k_signals_rerun" and $^O eq "MSWin32") { \& return "This test crashes Perl when run with Tk on $^O"; \& } \& return "Tk tests require the Tk module" if do { eval "use Tk"; $@ }; \& my $m = eval { Tk::MainWindow\->new() }; \& if ($@) { \& my $why = $@; \& $why =~ s/ at .*//; \& return "Tk couldn\*(Aqt be initialized: $why"; \& } \& return; \& } .Ve .SH "INSTALL SCRIPT INTEGRATION" .IX Header "INSTALL SCRIPT INTEGRATION" The POE::Loop tests started out as part of the \s-1POE\s0 distribution. All the recommendations and examples that follow are written and tested against ExtUtils::MakeMaker because that's what \s-1POE\s0 uses. Please adjust these recipes according to your taste and preference. .SS "Calling the Test Generator" .IX Subsection "Calling the Test Generator" Tests need to be generated prior to the user or \s-1CPAN\s0 shell running \&\*(L"make test\*(R". A tidy way to do this might be to create a new Makefile target and include that as a dependency for \*(L"make test\*(R". \s-1POE\s0 takes a simpler approach, calling the script from its Makefile.PL: .PP .Vb 5 \& system( \& $^X, "poe\-gen\-tests", "\-\-dirbase", "t/30_loops", \& "\-\-loop", "Event", "\-\-loop", "Gtk", "\-\-loop", "IO::Poll", \& "\-\-loop", "Select", "\-\-loop", "Tk", \& ) and die $!; .Ve .PP The previous approach generates tests at install time, so it's not necessary to include the generated files in the \s-1MANIFEST.\s0 Test directories should also be excluded from the \s-1MANIFEST.\s0 poe-gen-tests will create the necessary paths. .PP It's also possible to generate the tests prior to \*(L"make dist\*(R". The distribution's \s-1MANIFEST\s0 must include the generated files in this case. .PP Most people will not need to add the generated tests to their repositories. .SH "Running the Tests" .IX Header "Running the Tests" By default, ExtUtils::MakeMaker generates Makefiles that only run tests matching t/*.t. However authors are allowed to specify other test locations. Add the following parameter to \fBWriteMakefile()\fR so that the tests generated above will be executed: .PP .Vb 3 \& tests => { \& TESTS => "t/*.t t/30_loops/*/*.t", \& } .Ve .SH "CLEANING UP" .IX Header "CLEANING UP" Makefiles will not clean up files that aren't present in the \s-1MANIFEST.\s0 This includes tests generated at install time. If this bothers you, you'll need to add directives to include the generated tests in the \&\*(L"clean\*(R" and \*(L"distclean\*(R" targets. .PP .Vb 3 \& clean => { \& FILES => "t/30_loops/*/* t/30_loops/*", \& } .Ve .PP This assumes the \*(L"t/30_loops\*(R" directory contains only generated tests. It's recommended that generated and hand-coded tests not coexist in the same directory. .PP It seems like a good idea to delete the deeper directories and files before their parents. .SH "Skipping Network Tests" .IX Header "Skipping Network Tests" Some generated tests require a network to be present and accessible. Those tests will be skipped unless the file \*(L"run_network_tests\*(R" is present in the main distribution directory. You can include that file in your distribution's tarball, but it's better create it at install time after asking the user. Here's how \s-1POE\s0 does it. Naturally you're free to do it some other way. .PP .Vb 1 \& # Switch to default behavior if STDIN isn\*(Aqt a tty. \& \& unless (\-t STDIN) { \& warn( \& "\en", \& "=============================================\en\en", \& "STDIN is not a terminal. Assuming \-\-default.\en\en", \& "=============================================\en\en", \& ); \& push @ARGV, "\-\-default"; \& } \& \& # Remind the user she can use \-\-default. \& \& unless (grep /^\-\-default$/, @ARGV) { \& warn( \& "\en", \& "================================================\en\en", \& "Prompts may be bypassed with the \-\-default flag.\en\en", \& "================================================\en\en", \& ); \& } \& \& # Should we run the network tests? \& \& my $prompt = ( \& "Some of POE\*(Aqs tests require a functional network.\en" . \& "You can skip these tests if you\*(Aqd like.\en\en" . \& "Would you like to skip the network tests?" \& ); \& \& my $ret = "n"; \& if (grep /^\-\-default$/, @ARGV) { \& print $prompt, " [$ret] $ret\en\en"; \& } \& else { \& $ret = prompt($prompt, "n"); \& } \& \& my $marker = \*(Aqrun_network_tests\*(Aq; \& unlink $marker; \& unless ($ret =~ /^Y$/i) { \& open(TOUCH,"+>$marker") and close TOUCH; \& } \& \& print "\en"; .Ve .SH "Skipping Other Tests" .IX Header "Skipping Other Tests" \&\s-1POE\s0's loop tests will enable or disable tests based on the event loop's capabilities. Distributions and event loops may set these variables to signal which tests are okay to run. .SS "\s-1POE_LOOP_USES_POLL\s0" .IX Subsection "POE_LOOP_USES_POLL" Some platforms do not support \fBpoll()\fR on certain kinds of filehandles. Event loops that use \fBpoll()\fR should set this environment variable to a true value. It will cause the tests to skip this troublesome combination. .SS "\s-1PODDITIES\s0" .IX Subsection "PODDITIES" Previous versions of POE::Test::Loops documented \*(L"=for poe_tests\*(R" sections terminated by =cut and containing blank lines. This is incorrect \s-1POD\s0 syntax, and it's the reason the \fBskip_tests()\fR functions showed up in perldoc and on search.cpan.org. The following syntax is wrong and should not have been used. I'm so sorry. .PP .Vb 1 \& =for poe_tests \& \& sub skip_tests { ... } \& \& =cut .Ve .PP The proper syntax is to terminate \*(L"=for poe_tests\*(R" with a blank line: .PP .Vb 4 \& =for poe_tests \& sub skip_tests { \& ... \& } .Ve .PP Multi-line tests containing blank lines can be specified using \s-1POD\s0's \&\*(L"=begin poe_tests\*(R" terminated by \*(L"=end poe_tests\*(R". .PP .Vb 1 \& =begin poe_tests \& \& sub skip_tests { \& ... \& } \& \& =end poe_tests .Ve .PP All three syntaxes above are supported as of POE::Test::Loops version 1.034. The incorrect =for syntax is deprecated and will be removed in some future release. .SH "SEE ALSO" .IX Header "SEE ALSO" POE::Test::Loops, POE::Loop, perlpod. .SS "\s-1BUG TRACKER\s0" .IX Subsection "BUG TRACKER" https://rt.cpan.org/Dist/Display.html?Status=Active&Queue=POE\-Test\-Loops .SS "\s-1REPOSITORY\s0" .IX Subsection "REPOSITORY" https://poe.svn.sourceforge.net/svnroot/poe/trunk/poe\-test\-loops .SS "\s-1OTHER RESOURCES\s0" .IX Subsection "OTHER RESOURCES" http://search.cpan.org/dist/POE\-Test\-Loops/ .SH "AUTHOR & COPYRIGHT" .IX Header "AUTHOR & COPYRIGHT" Rocco Caputo . Benjamin Smith . Countless other people. .PP These tests are Copyright 1998\-2013 by Rocco Caputo, Benjamin Smith, and countless contributors. All rights are reserved. These tests are free software; you may redistribute them and/or modify them under the same terms as Perl itself. .PP Thanks to Martijn van Beers for beta testing and suggestions.