r18917 - in /branches/upstream/libtest-http-server-simple-perl: ./ current/ current/lib/ current/lib/Test/ current/lib/Test/HTTP/ current/lib/Test/HTTP/Server/ current/t/

yvesago-guest at users.alioth.debian.org yvesago-guest at users.alioth.debian.org
Sun Apr 20 14:56:38 UTC 2008


Author: yvesago-guest
Date: Sun Apr 20 14:56:38 2008
New Revision: 18917

URL: http://svn.debian.org/wsvn/?sc=1&rev=18917
Log:
[svn-inject] Installing original source of libtest-http-server-simple-perl

Added:
    branches/upstream/libtest-http-server-simple-perl/
    branches/upstream/libtest-http-server-simple-perl/current/
    branches/upstream/libtest-http-server-simple-perl/current/Changes
    branches/upstream/libtest-http-server-simple-perl/current/MANIFEST
    branches/upstream/libtest-http-server-simple-perl/current/META.yml
    branches/upstream/libtest-http-server-simple-perl/current/Makefile.PL
    branches/upstream/libtest-http-server-simple-perl/current/README
    branches/upstream/libtest-http-server-simple-perl/current/SIGNATURE
    branches/upstream/libtest-http-server-simple-perl/current/lib/
    branches/upstream/libtest-http-server-simple-perl/current/lib/Test/
    branches/upstream/libtest-http-server-simple-perl/current/lib/Test/HTTP/
    branches/upstream/libtest-http-server-simple-perl/current/lib/Test/HTTP/Server/
    branches/upstream/libtest-http-server-simple-perl/current/lib/Test/HTTP/Server/Simple.pm
    branches/upstream/libtest-http-server-simple-perl/current/t/
    branches/upstream/libtest-http-server-simple-perl/current/t/00.load.t
    branches/upstream/libtest-http-server-simple-perl/current/t/01.basic.t
    branches/upstream/libtest-http-server-simple-perl/current/t/pod-coverage.t
    branches/upstream/libtest-http-server-simple-perl/current/t/pod.t

Added: branches/upstream/libtest-http-server-simple-perl/current/Changes
URL: http://svn.debian.org/wsvn/branches/upstream/libtest-http-server-simple-perl/current/Changes?rev=18917&op=file
==============================================================================
--- branches/upstream/libtest-http-server-simple-perl/current/Changes (added)
+++ branches/upstream/libtest-http-server-simple-perl/current/Changes Sun Apr 20 14:56:38 2008
@@ -1,0 +1,24 @@
+Revision history for Test-HTTP-Server-Simple
+
+0.06 Tue Nov 13 16:38:40 EST 2007
+    META.yml SHA1 SUM issue
+
+0.05 Tue May  8 12:30:09 EDT 2007
+
+
+    No functionality changes. Just some releng cleanups
+
+0.04
+       Patch from SMUELLER to add Win32 Support - http://rt.cpan.org/Public/Bug/Display.html?id=19564
+
+0.03  Wed Jul  5 22:55:39 2006
+       Kill "waiting for child to start up" message.
+
+0.02  Tue Aug 02 18:16:00 2005
+       Change API to make it a mixin.
+       Make child signal parent when it's ready, and make the parent-killing-child
+       be much nicer than a -9.
+
+0.01  Thu Jun 16 18:16:56 2005
+       Initial release.
+

Added: branches/upstream/libtest-http-server-simple-perl/current/MANIFEST
URL: http://svn.debian.org/wsvn/branches/upstream/libtest-http-server-simple-perl/current/MANIFEST?rev=18917&op=file
==============================================================================
--- branches/upstream/libtest-http-server-simple-perl/current/MANIFEST (added)
+++ branches/upstream/libtest-http-server-simple-perl/current/MANIFEST Sun Apr 20 14:56:38 2008
@@ -1,0 +1,11 @@
+Changes
+lib/Test/HTTP/Server/Simple.pm
+Makefile.PL
+MANIFEST			This list of files
+META.yml
+README
+SIGNATURE
+t/00.load.t
+t/01.basic.t
+t/pod-coverage.t
+t/pod.t

Added: branches/upstream/libtest-http-server-simple-perl/current/META.yml
URL: http://svn.debian.org/wsvn/branches/upstream/libtest-http-server-simple-perl/current/META.yml?rev=18917&op=file
==============================================================================
--- branches/upstream/libtest-http-server-simple-perl/current/META.yml (added)
+++ branches/upstream/libtest-http-server-simple-perl/current/META.yml Sun Apr 20 14:56:38 2008
@@ -1,0 +1,18 @@
+--- #YAML:1.0
+name:                Test-HTTP-Server-Simple
+version:             0.06
+abstract:            Test::More functions for HTTP::Server::Simple
+license:             ~
+generated_by:        ExtUtils::MakeMaker version 6.36
+distribution_type:   module
+requires:     
+    HTTP::Server::Simple:          0
+    NEXT:                          0
+    Test::Builder:                 0
+    Test::Builder::Tester:         1.04
+    Test::More:                    0
+meta-spec:
+    url:     http://module-build.sourceforge.net/META-spec-v1.2.html
+    version: 1.2
+author:
+    - David Glasser <glasser at bestpractical.com>

Added: branches/upstream/libtest-http-server-simple-perl/current/Makefile.PL
URL: http://svn.debian.org/wsvn/branches/upstream/libtest-http-server-simple-perl/current/Makefile.PL?rev=18917&op=file
==============================================================================
--- branches/upstream/libtest-http-server-simple-perl/current/Makefile.PL (added)
+++ branches/upstream/libtest-http-server-simple-perl/current/Makefile.PL Sun Apr 20 14:56:38 2008
@@ -1,0 +1,20 @@
+use strict;
+use warnings;
+use ExtUtils::MakeMaker;
+
+WriteMakefile(
+    NAME                => 'Test::HTTP::Server::Simple',
+    AUTHOR              => 'David Glasser <glasser at bestpractical.com>',
+    VERSION_FROM        => 'lib/Test/HTTP/Server/Simple.pm',
+    ABSTRACT_FROM       => 'lib/Test/HTTP/Server/Simple.pm',
+    PL_FILES            => {},
+    PREREQ_PM => {
+        'Test::More' => 0,
+        'Test::Builder' => 0,
+        'Test::Builder::Tester' => 1.04,
+	'HTTP::Server::Simple' => 0,
+	'NEXT' => 0,
+    },
+    dist                => { COMPRESS => 'gzip -9f', SUFFIX => 'gz', },
+    clean               => { FILES => 'Test-HTTP-Server-Simple-*' },
+);

Added: branches/upstream/libtest-http-server-simple-perl/current/README
URL: http://svn.debian.org/wsvn/branches/upstream/libtest-http-server-simple-perl/current/README?rev=18917&op=file
==============================================================================
--- branches/upstream/libtest-http-server-simple-perl/current/README (added)
+++ branches/upstream/libtest-http-server-simple-perl/current/README Sun Apr 20 14:56:38 2008
@@ -1,0 +1,34 @@
+Test-HTTP-Server-Simple version 0.03
+
+Provides some very basic test functions for HTTP::Server::Simple.
+Currently, just deals with cleanly backgrounding and killing a child
+server process.
+
+
+INSTALLATION
+
+To install this module, run the following commands:
+
+    perl Makefile.PL
+    make
+    make test
+    make install
+
+
+Alternatively, to install with Module::Build, you can use the following commands:
+
+    perl Build.PL
+    ./Build
+    ./Build test
+    ./Build install
+
+
+
+
+COPYRIGHT AND LICENCE
+
+Copyright (C) 2005, Best Practical Solutions LLC.
+
+This library is free software; you can redistribute it and/or modify
+it under the same terms as Perl itself.
+

Added: branches/upstream/libtest-http-server-simple-perl/current/SIGNATURE
URL: http://svn.debian.org/wsvn/branches/upstream/libtest-http-server-simple-perl/current/SIGNATURE?rev=18917&op=file
==============================================================================
--- branches/upstream/libtest-http-server-simple-perl/current/SIGNATURE (added)
+++ branches/upstream/libtest-http-server-simple-perl/current/SIGNATURE Sun Apr 20 14:56:38 2008
@@ -1,0 +1,33 @@
+This file contains message digests of all files listed in MANIFEST,
+signed via the Module::Signature module, version 0.55.
+
+To verify the content in this distribution, first make sure you have
+Module::Signature installed, then type:
+
+    % cpansign -v
+
+It will check each file's integrity, as well as the signature's
+validity.  If "==> Signature verified OK! <==" is not displayed,
+the distribution may already have been compromised, and you should
+not run its Makefile.PL or Build.PL.
+
+-----BEGIN PGP SIGNED MESSAGE-----
+Hash: SHA1
+
+SHA1 1340ccd0b5dd311c1a93b4c508ed7f43ae0392ab Changes
+SHA1 fde2e498ced242649142d34769cdb32ec5ba17dd MANIFEST
+SHA1 17bd72441eedc4d39a838e0e8ca7c49582ad0081 META.yml
+SHA1 bc05af0bffcf1216bc552bd0e62608902e7b15bf Makefile.PL
+SHA1 fa0e7c54e60cea400aab16e8f4b3044958a87790 README
+SHA1 eaf47e05bc02ecee3a220447f25e4b7aaa4800f3 lib/Test/HTTP/Server/Simple.pm
+SHA1 6c3fc19c093bda0b4e8077ebb7ceec2f8944b7d2 t/00.load.t
+SHA1 1bdea5dc9c47d345d49089a684f2c59190ad4747 t/01.basic.t
+SHA1 6da39b48ce64b584e4c3274bff96fc76ff484820 t/pod-coverage.t
+SHA1 0190346d7072d458c8a10a45c19f86db641dcc48 t/pod.t
+-----BEGIN PGP SIGNATURE-----
+Version: GnuPG v1.4.6 (GNU/Linux)
+
+iD8DBQFHOhqTEi9d9xCOQEYRAiRwAJwOQIGR+mKaE25e2bSI23OXnuWTDQCgt46v
+RZcA4XwGCDnbex/mhlXt7kI=
+=hVSs
+-----END PGP SIGNATURE-----

Added: branches/upstream/libtest-http-server-simple-perl/current/lib/Test/HTTP/Server/Simple.pm
URL: http://svn.debian.org/wsvn/branches/upstream/libtest-http-server-simple-perl/current/lib/Test/HTTP/Server/Simple.pm?rev=18917&op=file
==============================================================================
--- branches/upstream/libtest-http-server-simple-perl/current/lib/Test/HTTP/Server/Simple.pm (added)
+++ branches/upstream/libtest-http-server-simple-perl/current/lib/Test/HTTP/Server/Simple.pm Sun Apr 20 14:56:38 2008
@@ -1,0 +1,236 @@
+package Test::HTTP::Server::Simple;
+
+our $VERSION = '0.06';
+
+use warnings;
+use strict;
+use Carp;
+
+use NEXT;
+
+use Test::Builder;
+my $Tester = Test::Builder->new;
+
+use constant WIN32 => $^O =~ /win32/i;
+
+my $Event; # used on win32 only
+if (WIN32) {
+    require Win32::Event;
+    $Event = Win32::Event->new();
+}
+
+=head1 NAME
+
+Test::HTTP::Server::Simple - Test::More functions for HTTP::Server::Simple
+
+
+=head1 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
+
+  
+=head1 DESCRIPTION
+
+This mixin class provides methods to test an L<HTTP::Server::Simple>-based web
+server.  Currently, it provides only one such method: C<started_ok>.
+
+=over 4 
+
+=item started_ok [$text]
+
+C<started_ok> takes 
+an optional test description.  The server needs to have been configured (specifically,
+its port needs to have been set), but it should not have been run or backgrounded.
+C<started_ok> calls C<background> on the server, which forks it to run in the background.
+L<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.  C<started_ok> returns the URL 
+C<http://localhost:$port> which you can use to connect to your server.
+
+Note that if the child process dies, or never gets around to listening for connections, this
+just hangs.  (This may be fixed in a future version.)
+
+Also, it probably won't work if you use a custom L<Net::Server> in your server.
+
+=cut
+
+my @CHILD_PIDS;
+
+# If an interrupt kills perl, END blocks are not run.  This
+# essentially converts interrupts (like CTRL-C) into a standard
+# perl exit (even if we're inside an eval {}).
+$SIG{INT} = sub { warn "INT:$$"; exit };
+
+END {
+    if (WIN32) {
+        # INT won't do since the server is doing a blocking read
+        # which isn't interrupted by anything but KILL on win32.
+        kill 9, $_ for @CHILD_PIDS;
+        sleep 1;
+        foreach (@CHILD_PIDS) {
+            sleep 1 while kill 0, $_;
+        }
+    }
+    else {
+        kill 'USR1', @CHILD_PIDS if @CHILD_PIDS;
+        wait for @CHILD_PIDS;
+    }
+} 
+
+sub started_ok {
+    my $self = shift;
+    my $text   = shift;
+    $text = 'started server' unless defined $text;
+
+    my $port = $self->port;
+    my $pid;
+
+    $self->{'test_http_server_simple_parent_pid'} = $$;
+
+    my $child_loaded_yet = 0;
+
+    # So this is a little complicated.  The following signal handler does two
+    # ENTIRELY DIFFERENT things:
+    #
+    #  In the parent, it just sets $child_loaded_yet, which breaks out of the
+    #  while loop below.  It's activated by the kid sending it a SIGUSR1 after
+    #  it runs setup_listener
+    #
+    #  In the kid, it sets the variable, but that's basically pointless since
+    #  the call to ->background doesn't actually return in the kid.  But also,
+    #  it exits.  And when you actually exit with 'exit' (as opposed to being
+    #  killed by a signal) END blocks get run.  Which means that you can use
+    #  Devel::Cover to test the kid's coverage.  This one is activated by the
+    #  parent's END block in this file.
+
+    local %SIG;
+    if (not WIN32) {
+        $SIG{'USR1'} = sub { $child_loaded_yet = 1; exit unless $self->{'test_http_server_simple_parent_pid'} == $$ }
+    }
+
+    # XXX TODO FIXME should somehow not have the signal handler around in the
+    # kid
+    # Comment: How about if ($pid) { $SIG{'USR1'} = ... }?
+    
+    eval { $pid = $self->background; };
+
+    if ($@) {
+        my $error_text = $@;  # In case the next line changes it.
+        $Tester->ok(0, $text);
+        $Tester->diag("HTTP::Server::Simple->background failed: $error_text");
+        return;
+    }
+
+    unless ($pid =~ /^-?\d+$/) {
+        $Tester->ok(0, $text);
+        $Tester->diag("HTTP::Server::Simple->background didn't return a valid PID");
+        return;
+    } 
+
+    push @CHILD_PIDS, $pid;
+
+    if (WIN32) {
+        $Event->wait();
+    }
+    else {
+        1 while not $child_loaded_yet;
+    }
+
+    $Tester->ok(1, $text);
+
+    return "http://localhost:$port";
+}
+
+=begin private
+
+=head2 setup_listener
+
+We send a signal to the parent here.  We need to use NEXT because this is a mixin.
+
+=end private
+
+=cut
+
+sub setup_listener {
+    my $self = shift;
+    $self->NEXT::setup_listener;
+    if (WIN32) {
+        $Event->pulse();
+    }
+    else {
+        kill 'USR1', $self->{'test_http_server_simple_parent_pid'};
+    }
+} 
+
+=back
+
+=head1 DEPENDENCIES
+
+L<Test::Builder>, L<HTTP::Server::Simple>, L<NEXT>.
+
+
+=head1 INCOMPATIBILITIES
+
+None reported.
+
+
+=head1 BUGS AND LIMITATIONS
+
+Installs an interrupt signal handler, which may override any that another part
+of your program has installed.
+
+Please report any bugs or feature requests to
+C<bug-test-http-server-simple at rt.cpan.org>, or through the web interface at
+L<http://rt.cpan.org>.
+
+
+=head1 AUTHOR
+
+David Glasser  C<< <glasser at bestpractical.com> >>
+
+
+=head1 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 L<perlartistic>.
+
+
+=head1 DISCLAIMER OF WARRANTY
+
+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.
+
+=cut
+
+1;
+

Added: branches/upstream/libtest-http-server-simple-perl/current/t/00.load.t
URL: http://svn.debian.org/wsvn/branches/upstream/libtest-http-server-simple-perl/current/t/00.load.t?rev=18917&op=file
==============================================================================
--- branches/upstream/libtest-http-server-simple-perl/current/t/00.load.t (added)
+++ branches/upstream/libtest-http-server-simple-perl/current/t/00.load.t Sun Apr 20 14:56:38 2008
@@ -1,0 +1,7 @@
+use Test::More tests => 1;
+
+BEGIN {
+use_ok( 'Test::HTTP::Server::Simple' );
+}
+
+diag( "Testing Test::HTTP::Server::Simple $Test::HTTP::Server::Simple::VERSION" );

Added: branches/upstream/libtest-http-server-simple-perl/current/t/01.basic.t
URL: http://svn.debian.org/wsvn/branches/upstream/libtest-http-server-simple-perl/current/t/01.basic.t?rev=18917&op=file
==============================================================================
--- branches/upstream/libtest-http-server-simple-perl/current/t/01.basic.t (added)
+++ branches/upstream/libtest-http-server-simple-perl/current/t/01.basic.t Sun Apr 20 14:56:38 2008
@@ -1,0 +1,44 @@
+#!/usr/bin/perl
+
+use Test::More tests => 6;
+use Test::Builder::Tester;
+
+test_out("not ok 1 - baz");
+test_fail(+2);
+test_diag("HTTP::Server::Simple->background failed: random failure");
+THSS::FailOnBackground->new(1234)->started_ok("baz");
+test_test("detect background failure");
+
+test_out("not ok 1 - blop");
+test_fail(+2);
+test_diag("HTTP::Server::Simple->background didn't return a valid PID");
+THSS::ReturnInvalidPid->new(4194)->started_ok("blop");
+test_test("detect bad pid");
+
+test_out("ok 1 - beep");
+my $URL = THSS::Good->new(9583)->started_ok("beep");
+test_test("start up correctly");
+
+is($URL, "http://localhost:9583");
+
+test_out("ok 1 - started server");
+$URL = THSS::Good->new(9384)->started_ok;
+test_test("start up correctly (with default message)");
+
+is($URL, "http://localhost:9384");
+
+
+# unfortunately we do not test the child-killing properties of THHS,
+# even though that's the main point of the module
+
+
+package THSS::FailOnBackground;
+use base qw/Test::HTTP::Server::Simple HTTP::Server::Simple/;
+sub background { die "random failure\n" }
+
+package THSS::ReturnInvalidPid;
+use base qw/Test::HTTP::Server::Simple HTTP::Server::Simple/;
+sub background { return "" }
+
+package THSS::Good;
+use base qw/Test::HTTP::Server::Simple HTTP::Server::Simple::CGI/;

Added: branches/upstream/libtest-http-server-simple-perl/current/t/pod-coverage.t
URL: http://svn.debian.org/wsvn/branches/upstream/libtest-http-server-simple-perl/current/t/pod-coverage.t?rev=18917&op=file
==============================================================================
--- branches/upstream/libtest-http-server-simple-perl/current/t/pod-coverage.t (added)
+++ branches/upstream/libtest-http-server-simple-perl/current/t/pod-coverage.t Sun Apr 20 14:56:38 2008
@@ -1,0 +1,6 @@
+#!perl -T
+
+use Test::More;
+eval "use Test::Pod::Coverage 1.04";
+plan skip_all => "Test::Pod::Coverage 1.04 required for testing POD coverage" if $@;
+all_pod_coverage_ok();

Added: branches/upstream/libtest-http-server-simple-perl/current/t/pod.t
URL: http://svn.debian.org/wsvn/branches/upstream/libtest-http-server-simple-perl/current/t/pod.t?rev=18917&op=file
==============================================================================
--- branches/upstream/libtest-http-server-simple-perl/current/t/pod.t (added)
+++ branches/upstream/libtest-http-server-simple-perl/current/t/pod.t Sun Apr 20 14:56:38 2008
@@ -1,0 +1,6 @@
+#!perl -T
+
+use Test::More;
+eval "use Test::Pod 1.14";
+plan skip_all => "Test::Pod 1.14 required for testing POD" if $@;
+all_pod_files_ok();




More information about the Pkg-perl-cvs-commits mailing list