in reply to Offline alternatives to Apache for CGI testing
is there a better (?define!) alternative to Apache for PC-based (ie non-server based) CGI testing of perl scripts?
The alternative I would suggest is not to use a webserver at all. CGI scripts can be perfectly adequately tested without a webserver by setting the environment correctly and optionally providing the input data on STDIN. eg.
use strict; use warnings; use Test::More tests => 2; $ENV{REQUEST_METHOD} = 'GET'; $ENV{QUERY_STRING} = 'game=chess&game=ludo&weather=dull'; $ENV{PATH_INFO} = '/somewhere/else'; $ENV{PATH_TRANSLATED} = '/usr/local/somewhere/else'; $ENV{SCRIPT_NAME} = '/cgi-bin/foo.cgi'; $ENV{SERVER_PROTOCOL} = 'HTTP/1.0'; $ENV{SERVER_PORT} = 80; $ENV{SERVER_NAME} = 'here.there.com'; my $out = `/path/to/my/script.cgi`; like ($out, qr/Content-type: text\/html/, 'HTML response'); like ($out, qr/foo/, 'Foo found');
Depending on the actual deliverable, this may well be all you need.
|
|---|