Apache-Test
view release on metacpan or search on metacpan
lib/Apache/TestUtil.pm view on Meta::CPAN
indicating how many entries to expect, can be passed. For example:
t_server_log_error_is_expected(2);
will generate:
*** The following 2 error entries are expected and harmless ***
If the error is generated at compile time, the logging must be done in
the BEGIN block at the very beginning of the file:
BEGIN {
use Apache::TestUtil;
t_server_log_error_is_expected();
}
use DOES_NOT_exist;
After attempting to run this handler the I<error_log> file will
include:
*** The following error entry is expected and harmless ***
[Tue Apr 01 14:04:49 2003] [error] Can't locate "DOES_NOT_exist.pm"
in @INC (@INC contains: ...
Also see C<t_server_log_warn_is_expected()> which is similar but used
for warnings.
This function is exported by default.
=item t_server_log_warn_is_expected()
C<t_server_log_warn_is_expected()> generates a disclaimer for expected
warnings.
See the explanation for C<t_server_log_error_is_expected()> for more
details.
This function is exported by default.
=item t_client_log_error_is_expected()
C<t_client_log_error_is_expected()> generates a disclaimer for
expected errors. But in contrast to
C<t_server_log_error_is_expected()> called by the client side of the
script.
See the explanation for C<t_server_log_error_is_expected()> for more
details.
For example the following client script fails to find the handler:
use Apache::Test;
use Apache::TestUtil;
use Apache::TestRequest qw(GET);
plan tests => 1;
t_client_log_error_is_expected();
my $url = "/error_document/cannot_be_found";
my $res = GET($url);
ok t_cmp(404, $res->code, "test 404");
After running this test the I<error_log> file will include an entry
similar to the following snippet:
*** The following error entry is expected and harmless ***
[Tue Apr 01 14:02:55 2003] [error] [client 127.0.0.1]
File does not exist: /tmp/test/t/htdocs/error
When more than one entry is expected, an optional numerical argument,
indicating how many entries to expect, can be passed. For example:
t_client_log_error_is_expected(2);
will generate:
*** The following 2 error entries are expected and harmless ***
This function is exported by default.
=item t_client_log_warn_is_expected()
C<t_client_log_warn_is_expected()> generates a disclaimer for expected
warnings on the client side.
See the explanation for C<t_client_log_error_is_expected()> for more
details.
This function is exported by default.
=item t_catfile('a', 'b', 'c')
This function is essentially C<File::Spec-E<gt>catfile>, but
on Win32 will use C<Win32::GetLongpathName()> to convert the
result to a long path name (if the result is an absolute file).
The function is not exported by default.
=item t_catfile_apache('a', 'b', 'c')
This function is essentially C<File::Spec::Unix-E<gt>catfile>, but
on Win32 will use C<Win32::GetLongpathName()> to convert the
result to a long path name (if the result is an absolute file).
It is useful when comparing something to that returned by Apache,
which uses a Unix-style specification with forward slashes for
directory separators. The function is not exported by default.
=item t_start_error_log_watch(), t_finish_error_log_watch()
This pair of functions provides an easy interface for checking
the presence or absense of any particular message or messages
in the httpd error_log that were generated by the httpd daemon
as part of a test suite. It is likely, that you should proceed
this with a call to one of the t_*_is_expected() functions.
t_start_error_log_watch();
do_it;
ok grep {...} t_finish_error_log_watch();
Another usage case could be a handler that emits some debugging messages
to the error_log. Now, if this handler is called in a series of other
test cases it can be hard to find the relevant messages manually. In such
( run in 2.152 seconds using v1.01-cache-2.11-cpan-39bf76dae61 )