cvs commit: modperl-2.0/t/response/TestApache compat.pm
dougm 01/12/19 17:31:24 Modified:lib/Apache compat.pm t/response/TestApache compat.pm Log: use/require Apache::File; compat Revision ChangesPath 1.32 +2 -0 modperl-2.0/lib/Apache/compat.pm Index: compat.pm === RCS file: /home/cvs/modperl-2.0/lib/Apache/compat.pm,v retrieving revision 1.31 retrieving revision 1.32 diff -u -r1.31 -r1.32 --- compat.pm 2001/12/14 04:52:45 1.31 +++ compat.pm 2001/12/20 01:31:24 1.32 @@ -32,6 +32,8 @@ $INC{'Apache.pm'} = __FILE__; $INC{'Apache/Constants.pm'} = __FILE__; + +$INC{'Apache/File.pm'} = __FILE__; } package Apache; 1.9 +1 -0 modperl-2.0/t/response/TestApache/compat.pm Index: compat.pm === RCS file: /home/cvs/modperl-2.0/t/response/TestApache/compat.pm,v retrieving revision 1.8 retrieving revision 1.9 diff -u -r1.8 -r1.9 --- compat.pm 2001/12/14 04:52:45 1.8 +++ compat.pm 2001/12/20 01:31:24 1.9 @@ -84,6 +84,7 @@ } } elsif ($data{test} eq 'Apache::File') { +require Apache::File; my $file = $vars-{t_conf_file}; debug new Apache::File file object;
cvs commit: modperl-2.0/t/response/TestApache compat.pm
stas01/12/13 20:52:46 Modified:todo api.txt lib/Apache compat.pm t/apache compat.t t/response/TestApache compat.pm Log: - Apache-gensym now lives in compat.pm Revision ChangesPath 1.17 +0 -3 modperl-2.0/todo/api.txt Index: api.txt === RCS file: /home/cvs/modperl-2.0/todo/api.txt,v retrieving revision 1.16 retrieving revision 1.17 diff -u -r1.16 -r1.17 --- api.txt 2001/11/13 17:42:49 1.16 +++ api.txt 2001/12/14 04:52:45 1.17 @@ -90,9 +90,6 @@ $r-cgi_header_out: anything in 1.x land actually using it? -Apache-gensym: - Apache::compat ? - $r-post_connection: alias not implemented 1.31 +5 -0 modperl-2.0/lib/Apache/compat.pm Index: compat.pm === RCS file: /home/cvs/modperl-2.0/lib/Apache/compat.pm,v retrieving revision 1.30 retrieving revision 1.31 diff -u -r1.30 -r1.31 --- compat.pm 2001/12/10 08:28:22 1.30 +++ compat.pm 2001/12/14 04:52:45 1.31 @@ -26,6 +26,7 @@ use APR::Table (); use APR::Pool (); use mod_perl (); +use Symbol (); BEGIN { $INC{'Apache.pm'} = __FILE__; @@ -64,6 +65,10 @@ sub module { require Apache::Module; return Apache::Module::loaded($_[1]); +} + +sub gensym { +return Symbol::gensym(); } package Apache::Constants; 1.8 +8 -1 modperl-2.0/t/apache/compat.t Index: compat.t === RCS file: /home/cvs/modperl-2.0/t/apache/compat.t,v retrieving revision 1.7 retrieving revision 1.8 diff -u -r1.7 -r1.8 --- compat.t 2001/12/10 04:32:40 1.7 +++ compat.t 2001/12/14 04:52:45 1.8 @@ -6,7 +6,7 @@ use Apache::TestUtil; use Apache::TestRequest; -plan tests = 30, todo = [24, 27, 29], \have_lwp; +plan tests = 31, todo = [25, 28, 30], \have_lwp; my $location = /TestApache::compat; @@ -38,6 +38,13 @@ GET_BODY(query(@data)), q{$r-Apache::args} ); +} + +# Apache-gensym +{ +my @data = (test = 'gensym'); +my $data = GET_BODY query(@data) || ''; +ok_nok($data); } # header_in 1.8 +6 -1 modperl-2.0/t/response/TestApache/compat.pm Index: compat.pm === RCS file: /home/cvs/modperl-2.0/t/response/TestApache/compat.pm,v retrieving revision 1.7 retrieving revision 1.8 diff -u -r1.7 -r1.8 --- compat.pm 2001/12/10 08:31:15 1.7 +++ compat.pm 2001/12/14 04:52:45 1.8 @@ -14,6 +14,7 @@ sub handler { my $r = shift; +$gr = $r; $r-send_http_header('text/plain'); @@ -33,6 +34,11 @@ if ($data{test} eq 'content' || $data{test} eq 'args') { $r-print(test $data{test}); } +elsif ($data{test} eq 'gensym') { +debug Apache-gensym; +my $fh = Apache-gensym; +ok ref $fh eq 'GLOB'; +} elsif ($data{test} eq 'header') { my $way = $data{way}; my $sub = header_$way; @@ -78,7 +84,6 @@ } } elsif ($data{test} eq 'Apache::File') { -$gr = $r; my $file = $vars-{t_conf_file}; debug new Apache::File file object;
cvs commit: modperl-2.0/t/response/TestApache compat.pm
stas01/12/05 08:03:25 Modified:lib/Apache compat.pm t/apache compat.t t/response/TestApache compat.pm Log: - add 'PerlOptions +GlobalRequest' to avoid core dumps in tests - warn user if Apache-request fails - add the returned by tmpfile filename test Revision ChangesPath 1.26 +4 -1 modperl-2.0/lib/Apache/compat.pm Index: compat.pm === RCS file: /home/cvs/modperl-2.0/lib/Apache/compat.pm,v retrieving revision 1.25 retrieving revision 1.26 diff -u -r1.25 -r1.26 --- compat.pm 2001/12/05 05:31:09 1.25 +++ compat.pm 2001/12/05 16:03:25 1.26 @@ -301,11 +301,14 @@ my $class = shift; my $limit = 100; my $r = Apache-request; +unless ($r) { +die 'PerlOptions +GlobalRequest' setting is required; +} while ($limit--) { my $tmpfile = $TMPDIR/${$} . $TMPNAM++; my $fh = $class-new; sysopen($fh, $tmpfile, $Mode, $Perms); -$r-register_cleanup(sub { unlink $tmpfile }) if $r; +$r-pool-cleanup_register(sub { unlink $tmpfile }) if $r; if ($fh) { return wantarray ? ($tmpfile, $fh) : $fh; } 1.5 +1 -1 modperl-2.0/t/apache/compat.t Index: compat.t === RCS file: /home/cvs/modperl-2.0/t/apache/compat.t,v retrieving revision 1.4 retrieving revision 1.5 diff -u -r1.4 -r1.5 --- compat.t 2001/12/05 05:31:09 1.4 +++ compat.t 2001/12/05 16:03:25 1.5 @@ -6,7 +6,7 @@ use Apache::TestUtil; use Apache::TestRequest; -plan tests = 20, \have_lwp; +plan tests = 21, \have_lwp; my $location = /TestApache::compat; 1.4 +10 -2 modperl-2.0/t/response/TestApache/compat.pm Index: compat.pm === RCS file: /home/cvs/modperl-2.0/t/response/TestApache/compat.pm,v retrieving revision 1.3 retrieving revision 1.4 diff -u -r1.3 -r1.4 --- compat.pm 2001/12/05 05:31:09 1.3 +++ compat.pm 2001/12/05 16:03:25 1.4 @@ -116,9 +116,15 @@ debug new+open non-exists; ok !Apache::File-new($file.yeahright); -debug open tmpfile; -ok my ($tmpfile, $tmpfh) = Apache::File-tmpfile; +# tmpfile +my ($tmpfile, $tmpfh) = Apache::File-tmpfile; +#89573612 +debug open tmpfile fh; +ok $tmpfh; +debug open tmpfile name; +ok $tmpfile; + debug write/read from tmpfile; my $write = test $$; print $tmpfh $write; @@ -134,3 +140,5 @@ sub debug { $gr-print(# $_\n) for @_; } 1; +__END__ +PerlOptions +GlobalRequest
cvs commit: modperl-2.0/t/response/TestApache compat.pm
stas01/12/05 08:39:01 Modified:t/apache compat.t t/response/TestApache compat.pm Log: - add the rest of the sub tests for the $r methods provided by Apache::File in 1.x. Revision ChangesPath 1.6 +3 -3 modperl-2.0/t/apache/compat.t Index: compat.t === RCS file: /home/cvs/modperl-2.0/t/apache/compat.t,v retrieving revision 1.5 retrieving revision 1.6 diff -u -r1.5 -r1.6 --- compat.t 2001/12/05 16:03:25 1.5 +++ compat.t 2001/12/05 16:39:01 1.6 @@ -6,7 +6,7 @@ use Apache::TestUtil; use Apache::TestRequest; -plan tests = 21, \have_lwp; +plan tests = 26, \have_lwp; my $location = /TestApache::compat; @@ -54,7 +54,7 @@ # Apache::File { -my @data = (test = 'file'); +my @data = (test = 'Apache::File'); my $data = GET_BODY query(@data) || ''; ok_nok($data); } @@ -66,7 +66,7 @@ $location? . join '', map { $_=$args{$_} } keys %args; } -sub t_header{ +sub t_header { my ($way, $what, $comment) = @_; ok t_cmp( ok, 1.5 +25 -3 modperl-2.0/t/response/TestApache/compat.pm Index: compat.pm === RCS file: /home/cvs/modperl-2.0/t/response/TestApache/compat.pm,v retrieving revision 1.4 retrieving revision 1.5 diff -u -r1.4 -r1.5 --- compat.pm 2001/12/05 16:03:25 1.4 +++ compat.pm 2001/12/05 16:39:01 1.5 @@ -77,7 +77,7 @@ $r-print(t_is_equal($exp, $got) ? 'ok' : 'nok'); } } -elsif ($data{test} eq 'file') { +elsif ($data{test} eq 'Apache::File') { $gr = $r; my $file = $vars-{t_conf_file}; @@ -118,7 +118,7 @@ # tmpfile my ($tmpfile, $tmpfh) = Apache::File-tmpfile; -#89573612 + debug open tmpfile fh; ok $tmpfh; @@ -131,9 +131,31 @@ seek $tmpfh, 0, 0; my $read = $tmpfh; ok $read eq $write; + +debug \$r-discard_request_body; +ok $r-discard_request_body == Apache::OK; + +debug \$r-meets_conditions; +ok $r-meets_conditions == Apache::OK; + +debug \$r-set_content_length; +$r-set_content_length(10); +my $cl_header = $r-headers_out-{Content-length} || ''; +ok $cl_header == 10; + +# XXX: how to test etag? +debug \$r-set_etag; +$r-set_etag; +ok 1; + +debug \$r-update_mtime/\$r-mtime; +my $time = time; +$r-update_mtime($time); +ok $r-mtime == $time; + } -OK; +Apache::OK; } sub ok{ $gr-print($_[0] ? ok\n : nok\n); }
cvs commit: modperl-2.0/t/response/TestApache compat.pm
stas01/09/29 12:33:40 Modified:t/apache compat.t t/response/TestApache compat.pm Log: - prepare a ground for adding many new sub-tests for Apache::compat - add the content-type test for send_http_header($val); - add tests for $r-header_{in|out} (5,7,9,11 are failing!) Revision ChangesPath 1.2 +58 -10modperl-2.0/t/apache/compat.t Index: compat.t === RCS file: /home/cvs/modperl-2.0/t/apache/compat.t,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- compat.t 2001/05/04 19:04:15 1.1 +++ compat.t 2001/09/29 19:33:39 1.2 @@ -2,22 +2,70 @@ use warnings FATAL = 'all'; use Apache::Test; + +use Apache::TestUtil; use Apache::TestRequest; -plan tests = 2, \have_lwp; +plan tests = 11, todo = [5,7,9,11], \have_lwp; my $location = /TestApache::compat; -my $str; - -my @data = (ok = '2'); -my %data = @data; -$str = POST_BODY $location, \@data; +# $r-send_http_header('text/plain'); +{ +my @data = (test = 'content-type'); +ok t_cmp( +text/plain, +HEAD(query(@data))-content_type(), +q{$r-send_http_header('text/plain')} +); +} + +# $r-content +{ +my @data = (test = 'content'); +ok t_cmp( +@data, +POST_BODY($location, \@data), +q{$r-content via POST} +); +} + +# $r-Apache::args +{ +my @data = (test = 'args'); +ok t_cmp( +@data, +GET_BODY(query(@data)), +q{$r-Apache::args} +); +} + +# header_in +t_header('in','get_scalar',q{scalar ctx: $r-header_in($key)}); +t_header('in','get_list', q{list ctx: $r-header_in($key)}); +t_header('in','set', q{$r-header_in($key = $val)}); +t_header('in','unset', q{$r-header_in($key = undef)}); + +# header_out +t_header('out','get_scalar',q{scalar ctx: $r-header_out($key)}); +t_header('out','get_list', q{list ctx: $r-header_out($key)}); +t_header('out','set', q{$r-header_out($key = $val)}); +t_header('out','unset', q{$r-header_out($key = undef)}); -ok $str eq @data; -my $q = join '=', @data; -$str = GET_BODY $location?$q; -ok $str eq @data; +### helper subs ### +sub query { +my(%args) = (@_ % 2) ? %{+shift} : @_; +$location? . join '', map { $_=$args{$_} } keys %args; +} + +sub t_header{ +my ($way, $what, $comment) = @_; +ok t_cmp( +ok, +GET_BODY(query(test = 'header', way = $way, what = $what)), +$comment +); +} 1.2 +51 -2 modperl-2.0/t/response/TestApache/compat.pm Index: compat.pm === RCS file: /home/cvs/modperl-2.0/t/response/TestApache/compat.pm,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- compat.pm 2001/05/04 19:04:17 1.1 +++ compat.pm 2001/09/29 19:33:39 1.2 @@ -5,7 +5,8 @@ use Apache::compat (); -use Apache::Constants qw(OK M_POST); +use Apache::TestUtil; +use Apache::Constants qw(OK M_POST DECLINED); sub handler { my $r = shift; @@ -20,7 +21,55 @@ %data = $r-Apache::args; } -$r-print(ok $data{ok}); +return DECLINED unless exists $data{test}; + +if ($data{test} eq 'content' || $data{test} eq 'args') { +$r-print(test $data{test}); +} +elsif ($data{test} eq 'header') { +my $way = $data{way}; +my $sub = header_$way; +my $sub_good = headers_$way; +if ($data{what} eq 'get_scalar') { +# get in scalar ctx +my $key; +if ($way eq 'in') { +$key = user-agent; # should exist with lwp +} +else { +# outgoing headers aren't set yet, so we set one +$key = X-barabara; +$r-$sub_good-set($key, $key x 2); +} +my $exp = $r-$sub_good-get($key); +my $got = $r-$sub($key); +$r-print(t_is_equal($exp, $got) ? 'ok' : 'nok'); +} +elsif ($data{what} eq 'get_list') { +# get in list ctx +my $key = $data{test}; +my @exp = qw(foo bar); +$r-$sub_good-add($key = $_) for @exp; +my @got = $r-$sub($key); +$r-print(t_is_equal(\@exp, \@got) ? 'ok' : 'nok'); +} +elsif ($data{what} eq 'set') { +# set +my $key = $data{test}; +my $exp = $key x 2; +$r-$sub($key = $exp); +my $got = $r-$sub($key); +$r-print(t_is_equal($exp, $got) ? 'ok' : 'nok'); +} +elsif ($data{what} eq 'unset') { +