Test::...Simple(3pm)
π Test::HTTP::Server::Simple π
okay bestie, sit down, we're testing a whole entire web server and it's gonna be adorable β¨
This is the manual page for Test::HTTP::Server::Simple, living its best life in the User Contributed Perl Documentation section of the manual (that's the 3pm part, iykyk). π
πΈ NAME πΈ
Test::HTTP::Server::Simple β the Test::More functions for HTTP::Server::Simple. literally the glow-up your server tests needed π
β¨ SYNOPSIS β¨
package My::WebServer;
use base qw/Test::HTTP::Server::Simple HTTP::Server::Simple/;
package main;
use Test::More tests => 42;
my $s = My::WebServer->new;
my $url_root = $s->started_ok("start up my web server);
# connect to "$url_root/cool/site" and test with Test::WWW::Mechanize,
# Test::HTML::Tidy, etc
yes queen, 42 tests, iconic number, no notes π¦
π«Ά DESCRIPTION π«Ά
So this is a mixin class, which is basically a class that shows up, adds its little methods to your class, and lets your class be the main character. Its whole job? testing an HTTP::Server::Simple-based web server. π
Right now it has exactly one such method, and its name is started_ok. That's it. One (1) method. But it's a good one. π
π started_ok [$text]
started_ok takes an optional test description. That's the $text. Cute, right?
Some ground rules before you call it, bestie:
- your server needs to have been configured already β specifically, its port needs to have been set
- but it should NOT have been run or backgrounded yet
What it does: started_ok calls background on the server, which forks it to run in the background. π§ And here's the bestie behaviour we love: Test::HTTP::Server::Simple takes care of killing the server when your test script dies β even if you kill your test script with an interrupt. π so thoughtful.
And it returns the URL http://localhost:$port which you can use to connect to your server. π
β οΈ Lowkey important: if the child process dies, or never gets around to listening for connections, this just hangs. (This may be fixed in a future version.) no cap. π
π Also, it probably won't work if you use a custom Net::Server in your server.
π pids
Returns the PIDs of the processes which have been started. π₯
Since multiple test servers can be running at one, be aware that this returns a list. not a scalar, bestie, a whole list. plan accordingly β¨
π DEPENDENCIES π
Test::Builder, HTTP::Server::Simple, NEXT. that's the whole squad π«Ά
π INCOMPATIBILITIES π
None reported. we're unproblematic π
π BUGS AND LIMITATIONS π
It installs an interrupt signal handler, which may override any that another part of your program has installed. so if something else in your program was holding that signal handler, bestieβ¦ it's not anymore. π
Please report any bugs or feature requests to bug-test-http-server-simple@rt.cpan.org, or through the web interface at http://rt.cpan.org. π
π AUTHOR π
David Glasser <glasser@bestpractical.com> β thank you king π«Ά
π LICENCE AND COPYRIGHT π
Copyright (c) 2005, Best Practical Solutions, LLC. All rights reserved.
This module is free software; you can redistribute it and/or modify it under the same terms as Perl itself. See perlartistic. π
β DISCLAIMER OF WARRANTY β
okay deep breath, this part is in all caps and it means business, so here it is exactly as it should be:
BECAUSE THIS SOFTWARE IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE SOFTWARE, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE SOFTWARE "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE SOFTWARE IS WITH YOU. SHOULD THE SOFTWARE PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR, OR CORRECTION.
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE SOFTWARE AS PERMITTED BY THE ABOVE LICENCE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE SOFTWARE (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE SOFTWARE TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
tl;dr bestie: it's free, so it comes with zero promises. that's the deal. π«Ά
and that's the whole page!! this lil guy shipped as part of perl v5.34.0 on 2022-06-17 β yes, a whole vintage moment, and it's still slaying β¨
bye bestie, go test your server, you got this π ππ¦π
π¦ where this page comes from
- debian bookworm: libtest-http-server-simple-perl 0.11-2 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- debian trixie: libtest-http-server-simple-perl 0.11-2 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu noble: libtest-http-server-simple-perl 0.11-2 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu resolute: libtest-http-server-simple-perl 0.11-2 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu stonking: libtest-http-server-simple-perl 0.11-2 Β· 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