Apache-Test

 view release on metacpan or  search on metacpan

Changes  view on Meta::CPAN

<haroon.rafique@utoronto.ca>]

new Apache::Test functions: 
have_min_apache_version - to require a minimal Apache version. 
have_apache_version     - to require a specific Apache version. 
[Stas]

Apache::TestUtil API change:
write_perl_script  => t_write_perl_script
write_shell_script => t_write_shell_script 
chown              => t_chown
All 3 functions are now optionally exported [Geoffrey Young].

Provide a new request macro _BODY_ASSERT to replace _BODY in cases
where the client part of the test directly prints to the output, in
order to avoid skipped tests instead of reporting the failure of the
server side. Use it in automatically generated tests. [Stas]

httpd (1.3 && 2) / winFU have problems when the first path's segment
includes ':' (security precaution which breaks the rfc) so we can't
use /TestFoo::bar as path_info in Apache::Tests. Adjusting all tests

Changes  view on Meta::CPAN


In autogenerated t/TEST, make sure not to include 'use Apache2' for
the mod_perl 2.0 build itself [Stas]

avoid starting httpd with 'Group root' when running the test suite
under root [Stas]

add support for 'make test TEST_VERBOSE=1 "TEST_FILES=foo bar"' [Stas]

Apache::Test now can run 'make test' under 'root', without permission
problems (e.g. when files need to be written), it'll chown all the
files under t/ to the user chosen to run the server with, before
running the tests and will restore the permissions at the end. [Stas]

don't inherit loading of the mod_perl object from the system-wide
config, since Apache::TestRunPerl already configures it [Stas]

Support two new shortcuts for skip functionality:
 - have_threads: checks whether both Apache and Perl support threads
 - under_construction: to print a consistent/clear skip reason
[Stas]

lib/Apache/TestUtil.pm  view on Meta::CPAN


$VERSION = '0.02';
@ISA     = qw(Exporter);

@EXPORT = qw(t_cmp t_debug t_append_file t_write_file t_open_file
    t_mkdir t_rmtree t_is_equal t_filepath_cmp t_write_test_lib
    t_server_log_error_is_expected t_server_log_warn_is_expected
    t_client_log_error_is_expected t_client_log_warn_is_expected
);

@EXPORT_OK = qw(t_write_perl_script t_write_shell_script t_chown
                t_catfile_apache t_catfile t_file_watch_for
                t_start_error_log_watch t_finish_error_log_watch
                t_start_file_watch t_read_file_watch t_finish_file_watch);

%CLEAN = ();

$Apache::TestUtil::DEBUG_OUTPUT = \*STDOUT;

# 5.005's Data::Dumper has problems to dump certain datastructures
use constant HAS_DUMPER => eval { $] >= 5.006 && require Data::Dumper; };

lib/Apache/TestUtil.pm  view on Meta::CPAN

    }

    return File::Path::mkpath($full_path, 0, 0755);
}

sub t_rmtree {
    die "must pass a dirname" unless defined $_[0];
    File::Path::rmtree((@_ > 1 ? \@_ : $_[0]), 0, 1);
}

#chown a file or directory to the test User/Group
#noop if chown is unsupported

sub t_chown {
    my $file = shift;
    my $config = Apache::Test::config();
    my($uid, $gid);

    eval {
        #XXX cache this lookup
        ($uid, $gid) = (getpwnam($config->{vars}->{user}))[2,3];
    };

    if ($@) {
        if ($@ =~ /^The getpwnam function is unimplemented/) {
            #ok if unsupported, e.g. win32
            return 1;
        }
        else {
            die $@;
        }
    }

    CORE::chown($uid, $gid, $file) || die "chown $file: $!";
}

# $string = struct_as_string($indent_level, $var);
#
# return any nested datastructure via Data::Dumper or ala Data::Dumper
# as a string. undef() is a valid arg.
#
# $indent_level should be 0 (used for nice indentation during
# recursive datastructure traversal)
sub struct_as_string{

lib/Apache/TestUtil.pm  view on Meta::CPAN

This function is exported by default.

=item t_rmtree()

  t_rmtree(@dirs);

t_rmtree() deletes the whole directories trees passed in I<@dirs>.

This function is exported by default.

=item t_chown()

  Apache::TestUtil::t_chown($file);

Change ownership of $file to the test's I<User>/I<Group>.  This
function is noop on platforms where chown(2) is unsupported
(e.g. Win32).

=item t_is_equal()

  t_is_equal($a, $b);

t_is_equal() compares any two datastructures and returns 1 if they are
exactly the same, otherwise 0. The datastructures can be nested
hashes, arrays, scalars, undefs or a combination of any of these.  See
t_cmp() for an example.



( run in 1.998 second using v1.01-cache-2.11-cpan-71847e10f99 )