POE-GEN-TESTS(1p)
β¨ POE-GEN-TESTS(1p) β¨
okay bestie, sit down, hydrate, and let me tell you about poe-gen-tests π this is the POE-GEN-TESTS(1p) manual page and it's a whole vibe.
πΈ NAME πΈ
poe-gen-tests β generate standard POE tests for third-party modules
π SYNOPSIS π
poe-gen-tests --dirbase t/loops \
--loop Glib \
--loop Kqueue \
--loop Event::Lib \
--loop POE::XS::Loop::Poll
π¦ DESCRIPTION π¦
So this program, plus its lil besties the POE::Test::Loop::* modules, together make up POE's tests for POE::Loop subclasses. The whole point of these tests is that they run identically no matter which event loop is currently in the building. POE uses them to test the event loops it bundles:
POE::Loop::Gtk
POE::Loop::IO_Poll (--loop IO::Poll)
POE::Loop::Tk
POE::Loop::Event
POE::Loop::Select
And if you're out here developing your own POE::Loop modules?? bestie you are so invited β you're encouraged to use this package to generate over 420 comprehensive tests for your own work. four hundred and twenty. no cap. π₯
π USAGE π
poe-gen-tests creates test files for one or more event loops, all nestled beneath the directory you specify in --dirbase. For example:
poe-gen-tests --dirbase t/loops --loop Select
generates the following test files:
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
look at that list. twenty-four files, all lowercase, all slaying β¨
The --loop parameter is either a POE::Loop::... class name or the event loop class that will complete the POE::Loop::... package name. Both of these are valid, and they mean the same thing:
poe-gen-tests --dirbase t/loops --loop Event::Lib
poe-gen-tests --dirbase t/loops --loop POE::Loop::Event_Lib
poe-gen-tests goes looking for a "=for poe_tests" or "=begin poe_tests" section inside the POE::Loop class it's testing. If that section is defined, it should include a single function, skip_tests(), and that function is the one that decides whether any given test should be skipped. it's giving gatekeeper but in a helpful way π«Ά
Please go look at perlpod for the syntax of "=for" and "=begin". Also peep PODDITIES for the notable differences between POE::Test::Loop's POD support and the standard. (iykyk)
skip_tests() gets called with one parameter: the base name of the test that's about to be executed. It returns false if the test should run, or a message that gets shown to the user explaining why the test is getting skipped. That message goes straight into Test::More's plan() along with "skip_all". The logic is essentially:
if (my $why = skip_tests("k_signals_rerun")) {
plan skip_all => $why;
}
skip_tests() should load any modules the event loop requires. See most of the examples below π
π Example poe_tests Directives π
POE::Loop::Event checks whether the Event module exists and can be loaded, and then whether specific tests can run under specific operating systems.
=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";
}
}
POE::Loop::Gtk checks whether DISPLAY is set, which implies that X is running. Then it checks whether Gtk is available, loadable, and safely initializable before skipping specific tests.
=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;
}
POE::Loop::IO_Poll checks for system compatibility before verifying that IO::Poll is available and loadable.
=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"; $@ }
);
}
POE::Loop::Select has no specific requirements. icon behavior honestly.
=for poe_tests
sub skip_tests { return }
POE::Loop::Tk needs an X display (except on Windows, obviously π). Tk is not safe for fork(), so tests that require forking get skipped. And finally, it checks whether the Tk module is available, loadable, and runnable.
=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't be initialized: $why";
}
return;
}
π INSTALL SCRIPT INTEGRATION π
The POE::Loop tests started out as part of the POE distribution. Every recommendation and example that follows was written and tested against ExtUtils::MakeMaker, because that's what POE uses. Please adjust these recipes according to your taste and preference β it's your kitchen, bestie, cook how you like π
π§ Calling the Test Generator π§
Tests need to be generated before the user or the CPAN shell runs "make test". A tidy way to do this might be to create a new Makefile target and include that as a dependency for "make test". POE takes a simpler approach, calling the script from its Makefile.PL:
system(
$^X, "poe-gen-tests", "--dirbase", "t/30_loops",
"--loop", "Event", "--loop", "Gtk", "--loop", "IO::Poll",
"--loop", "Select", "--loop", "Tk",
) and die $!;
The previous approach generates tests at install time, so it's not necessary to include the generated files in the MANIFEST. Test directories should also be excluded from the MANIFEST. poe-gen-tests will create the necessary paths for you. it's giving main character energy, it does the work π
It's also possible to generate the tests prior to "make dist". In that case, the distribution's MANIFEST must include the generated files.
Most people will not need to add the generated tests to their repositories. (thank god, right?)
β 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 WriteMakefile() so that the tests generated above will actually get executed:
tests => {
TESTS => "t/*.t t/30_loops/*/*.t",
}
π CLEANING UP π
Makefiles will not clean up files that aren't present in the MANIFEST. And that includes tests generated at install time. If this bothers you (and honestly? valid), you'll need to add directives to include the generated tests in the "clean" and "distclean" targets.
clean => {
FILES => "t/30_loops/*/* t/30_loops/*",
}
This assumes the "t/30_loops" directory contains only generated tests. It's recommended that generated and hand-coded tests not coexist in the same directory β keep your eras separate, bestie, no crossover episodes π
It seems like a good idea to delete the deeper directories and files before their parents.
πΈ Skipping Network Tests πΈ
Some generated tests require a network to be present and accessible. Those tests will be skipped unless the file "run_network_tests" is present in the main distribution directory. You can include that file in your distribution's tarball, but it's better to create it at install time after asking the user. Here's how POE does it. Naturally you're free to do it some other way. π
# Switch to default behavior if STDIN isn't a tty.
unless (-t STDIN) {
warn(
"\n",
"=============================================\n\n",
"STDIN is not a terminal. Assuming --default.\n\n",
"=============================================\n\n",
);
push @ARGV, "--default";
}
# Remind the user she can use --default.
unless (grep /^--default$/, @ARGV) {
warn(
"\n",
"================================================\n\n",
"Prompts may be bypassed with the --default flag.\n\n",
"================================================\n\n",
);
}
# Should we run the network tests?
my $prompt = (
"Some of POE's tests require a functional network.\n" .
"You can skip these tests if you'd like.\n\n" .
"Would you like to skip the network tests?"
);
my $ret = "n";
if (grep /^--default$/, @ARGV) {
print $prompt, " [$ret] $ret\n\n";
}
else {
$ret = prompt($prompt, "n");
}
my $marker = 'run_network_tests';
unlink $marker;
unless ($ret =~ /^Y$/i) {
open(TOUCH,"+>$marker") and close TOUCH;
}
print "\n";
okay don't go anywhere bestie, we're literally only halfway β part 2 is loading π
β¨ Skipping Other Tests β¨
okay so POE's loop tests are lowkey doing a vibe check on your event loop and enabling or disabling tests based on what it can actually handle. Distributions and event loops can set these variables to signal which tests are okay to run. no cap. π
πΈ POE_LOOP_USES_POLL πΈ
Some platforms do not support poll() on certain kinds of filehandles. If your event loop uses poll(), bestie, you should set this environment variable to a true value. That makes the tests skip this troublesome combination. periodt. π«Ά
π PODDITIES π
Previous versions of POE::Test::Loops documented =for poe_tests sections terminated by =cut and containing blank lines. This is incorrect POD syntax, and it's literally the reason the skip_tests() 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. π
=for poe_tests
sub skip_tests { ... }
=cut
The proper syntax is to terminate =for poe_tests with a blank line:
=for poe_tests
sub skip_tests {
...
}
Multi-line tests containing blank lines can be specified using POD's =begin poe_tests terminated by =end poe_tests.
=begin poe_tests
sub skip_tests {
...
}
=end poe_tests
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. so yeah, don't use it, bestie. π
π SEE ALSO π
POE::Test::LoopsPOE::Loopperlpod
π BUG TRACKER π
https://rt.cpan.org/Dist/Display.html?Status=Active&Queue=POE-Test-Loops
π¦ REPOSITORY π¦
https://poe.svn.sourceforge.net/svnroot/poe/trunk/poe-test-loops
π OTHER RESOURCES π
http://search.cpan.org/dist/POE-Test-Loops/
π AUTHOR & COPYRIGHT π
Rocco Caputo <rcaputo@cpan.org>. Benjamin Smith <bsmith@cpan.org>. Countless other people. iconic. π
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. π«Ά
Thanks to Martijn van Beers for beta testing and suggestions. πΈ
and that's the whole page, bestie. the footer says perl v5.36.0, dated 2022-11-19, and it's POE-GEN-TESTS(1p). slay. π
π¦ where this page comes from
- debian bookworm: libpoe-test-loops-perl 1.360-3 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- debian trixie: libpoe-test-loops-perl 1.360-3 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu noble: libpoe-test-loops-perl 1.360-3 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu resolute: libpoe-test-loops-perl 1.360-3 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu stonking: libpoe-test-loops-perl 1.360-3 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms