Skip to content

Commit

Permalink
document port range used for testing
Browse files Browse the repository at this point in the history
  • Loading branch information
kraih committed Mar 17, 2012
1 parent 26d6096 commit f34fc89
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 6 deletions.
3 changes: 2 additions & 1 deletion lib/Mojo/IOLoop.pm
Expand Up @@ -491,7 +491,8 @@ them to finish writing all data in their write buffers.
my $port = Mojo::IOLoop->generate_port;
my $port = $loop->generate_port;
Find a free TCP port, this is a utility function primarily used for tests.
Find a free private TCP port in the range from C<49152> to C<65535>, this is
a utility function primarily used for tests.
=head2 C<is_running>
Expand Down
5 changes: 3 additions & 2 deletions lib/Mojo/IOLoop/Server.pm
Expand Up @@ -147,7 +147,7 @@ sub listen {
sub generate_port {

# Try private ports
for my $port ((49152 + int(rand 15000)) .. 65535) {
for my $port ((49152 + int(rand 16000)) .. 65535) {
IO::Socket::INET->new(
Listen => 5,
LocalAddr => '127.0.0.1',
Expand Down Expand Up @@ -338,7 +338,8 @@ Path to the TLS key file, defaults to a built-in test key.
my $port = $server->generate_port;
Find a free TCP port, this is a utility function primarily used for tests.
Find a free private TCP port in the range from C<49152> to C<65535>, this is
a utility function primarily used for tests.
=head2 C<start>
Expand Down
7 changes: 4 additions & 3 deletions t/mojo/hypnotoad.t
Expand Up @@ -36,7 +36,8 @@ use Mojolicious::Lite;
plugin Config => {
default => {
hypnotoad => {
listen => ['http://127.0.0.1:$port1', 'http://127.0.0.1:$port2'],
inactivity_timeout => 3,
listen => ['http://127.0.0.1:$port1', 'http://127.0.0.1:$port2'],
workers => 1
}
}
Expand Down Expand Up @@ -102,7 +103,8 @@ use Mojolicious::Lite;
plugin Config => {
default => {
hypnotoad => {
listen => ['http://127.0.0.1:$port1', 'http://127.0.0.1:$port2'],
inactivity_timeout => 3,
listen => ['http://127.0.0.1:$port1', 'http://127.0.0.1:$port2'],
workers => 1
}
}
Expand Down Expand Up @@ -176,7 +178,6 @@ is $tx->res->body, 'Hello World!', 'right content';

# Stop
open my $stop, '-|', $^X, "$prefix/hypnotoad", $script, '-s';
sleep 3;
sleep 1
while IO::Socket::INET->new(
Proto => 'tcp',
Expand Down

0 comments on commit f34fc89

Please sign in to comment.