Test::...Simple(3pm)

πŸ“¦
version 0.11 Β· 4 versions
, in debian bookworm, debian trixie, ubuntu noble, ubuntu resolute, ubuntu stonking

πŸ’– 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 🫢


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