You are viewing a plain text version of this content. The canonical link for it is here.
Posted to apreq-cvs@httpd.apache.org by jo...@apache.org on 2003/06/13 11:46:52 UTC

cvs commit: httpd-apreq-2/glue/perl/t/response/TestApReq inherit.pm request.pm

joes        2003/06/13 02:46:52

  Modified:    glue/perl/t TEST.PL
               glue/perl/t/apreq big_input.t cookie.t inherit.t request.t
               glue/perl/t/response/TestApReq inherit.pm request.pm
  Log:
  Update perl tests- all pass save for the upload test,
  which is marked as a todo test.
  
  Revision  Changes    Path
  1.3       +2 -0      httpd-apreq-2/glue/perl/t/TEST.PL
  
  Index: TEST.PL
  ===================================================================
  RCS file: /home/cvs/httpd-apreq-2/glue/perl/t/TEST.PL,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- TEST.PL	12 Jun 2003 05:42:13 -0000	1.2
  +++ TEST.PL	13 Jun 2003 09:46:52 -0000	1.3
  @@ -4,6 +4,8 @@
   use warnings FATAL => 'all';
   
   use lib qw(lib Apache-Test/lib);
  +
  +use Apache2;
   use Apache::Build;
   require Win32 if Apache::Build::WIN32;
   
  
  
  
  1.2       +1 -0      httpd-apreq-2/glue/perl/t/apreq/big_input.t
  
  Index: big_input.t
  ===================================================================
  RCS file: /home/cvs/httpd-apreq-2/glue/perl/t/apreq/big_input.t,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- big_input.t	9 Jun 2003 06:30:04 -0000	1.1
  +++ big_input.t	13 Jun 2003 09:46:52 -0000	1.2
  @@ -1,3 +1,4 @@
  +#!/usr/bin/perl
   use strict;
   use warnings FATAL => 'all';
   
  
  
  
  1.2       +1 -0      httpd-apreq-2/glue/perl/t/apreq/cookie.t
  
  Index: cookie.t
  ===================================================================
  RCS file: /home/cvs/httpd-apreq-2/glue/perl/t/apreq/cookie.t,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- cookie.t	9 Jun 2003 06:30:04 -0000	1.1
  +++ cookie.t	13 Jun 2003 09:46:52 -0000	1.2
  @@ -1,3 +1,4 @@
  +#!/usr/bin/perl
   use strict;
   use warnings FATAL => 'all';
   
  
  
  
  1.2       +3 -2      httpd-apreq-2/glue/perl/t/apreq/inherit.t
  
  Index: inherit.t
  ===================================================================
  RCS file: /home/cvs/httpd-apreq-2/glue/perl/t/apreq/inherit.t,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- inherit.t	9 Jun 2003 06:30:04 -0000	1.1
  +++ inherit.t	13 Jun 2003 09:46:52 -0000	1.2
  @@ -1,3 +1,4 @@
  +#!/usr/bin/perl
   use strict;
   use warnings FATAL => 'all';
   
  @@ -8,7 +9,7 @@
   
   plan tests => 1;
   my $location = "/TestApReq__inherit";
  -ok t_cmp(<< 'VALUE', GET_BODY($location), "inheritance");
  +ok t_cmp(<< 'VALUE', $_=GET_BODY($location), "inheritance");
   method => GET
   VALUE
  -
  +warn $_;
  
  
  
  1.2       +2 -1      httpd-apreq-2/glue/perl/t/apreq/request.t
  
  Index: request.t
  ===================================================================
  RCS file: /home/cvs/httpd-apreq-2/glue/perl/t/apreq/request.t,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- request.t	9 Jun 2003 06:30:04 -0000	1.1
  +++ request.t	13 Jun 2003 09:46:52 -0000	1.2
  @@ -1,3 +1,4 @@
  +#!/usr/bin/perl
   use strict;
   use warnings FATAL => 'all';
   
  @@ -6,7 +7,7 @@
   use Apache::TestUtil;
   use Apache::TestRequest qw(GET_BODY UPLOAD_BODY);
   
  -plan tests => 2;
  +plan tests => 2, todo => [2];
   
   my $location = "/TestApReq__request";
   #print GET_BODY $location;
  
  
  
  1.2       +13 -8     httpd-apreq-2/glue/perl/t/response/TestApReq/inherit.pm
  
  Index: inherit.pm
  ===================================================================
  RCS file: /home/cvs/httpd-apreq-2/glue/perl/t/response/TestApReq/inherit.pm,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- inherit.pm	9 Jun 2003 04:00:45 -0000	1.1
  +++ inherit.pm	13 Jun 2003 09:46:52 -0000	1.2
  @@ -1,14 +1,19 @@
   package TestApReq::inherit;
  +use base 'Apache::Request';
   use strict;
  -use Apache::Request;
  -use Apache::Constants qw/OK/;
  +use warnings FATAL => 'all';
  +use APR;
  +use Apache::RequestRec;
  +use Apache::RequestIO;
  +use Devel::Peek;
   sub handler {
  -    my $r = Apache->request;
  -    $r->send_http_header('text/plain');
  -
  -    my $apr = Apache::Request->new($r);
  -    printf "method => %s\n", $apr->method;
  -    return OK;
  +    my $r = shift;
  +    $r->content_type('text/plain');
  +    $r = __PACKAGE__->new($r); # tickles refcnt bug in apreq-1
  +    Dump($r);
  +    die "Wrong package: ", ref $r unless $r->isa('TestApReq::inherit');
  +    $r->print(sprintf "method => %s\n", $r->method);
  +    return 0;
   }
   
   1;
  
  
  
  1.2       +8 -9      httpd-apreq-2/glue/perl/t/response/TestApReq/request.pm
  
  Index: request.pm
  ===================================================================
  RCS file: /home/cvs/httpd-apreq-2/glue/perl/t/response/TestApReq/request.pm,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- request.pm	9 Jun 2003 04:00:45 -0000	1.1
  +++ request.pm	13 Jun 2003 09:46:52 -0000	1.2
  @@ -2,28 +2,27 @@
   
   use strict;
   use warnings FATAL => 'all';
  -
  -use Apache::Test;
  -use Apache::TestUtil;
  -use Apache::Constants qw(OK M_POST DECLINED);
  -
  +use APR;
  +use Apache::RequestRec;
  +use Apache::RequestIO;
   use Apache::Request ();
   
   sub handler {
       my $r = shift;
       my $apr = Apache::Request->new($r);
   
  -    $r->send_http_header('text/plain');
  +    $r->content_type('text/plain');
   
       my $test  = $apr->param('test');
       my $value = $apr->param('value');
   
  -    return DECLINED unless defined $test;
  +#   return DECLINED unless defined $test;
   
       if ($test eq 'param') {
           $r->print($value);
       }
       elsif ($test eq 'upload') {
  +        return -1;
           my $upload = $apr->upload;
           my $fh = $upload->fh;
           local $/;
  @@ -31,10 +30,10 @@
           $r->print($data);
       } 
       else {
  -        
  +
       }
   
  -    return OK;
  +    return 0;
   }
   1;
   __END__
  
  
  

Re: cvs commit: httpd-apreq-2/glue/perl/t/response/TestApReq inherit.pm request.pm

Posted by Stas Bekman <st...@stason.org>.
Joe Schaefer wrote:
> Stas Bekman <st...@stason.org> writes:
> 
> [...]
> 
> 
>>Not to you. But users may try to run these as is, without using
>>$^X. I've pointed it out for this reason, just trying to minimize
>>support pains. 
> 
> 
> If the shebang line is omitted, how will the users run the tests?
> The files in question don't even have an executable bit set.

That's *exactly* my point. They shouldn't do that. If they have more than one 
perl on their system, and they have built apreq with non-/usr/bin/perl and 
they run the tests with it, all kind weird errors will happen at best.

Users should either run 'make test' or 't/TEST' and pass the test files as 
arguments if they want to run specific tests only. This is explained here:
http://perl.apache.org/docs/general/testing/testing.html#Individual_Testing

> I appreciate the support concern, and since I seem to be alone
> in my position, I'll concede that the shebang line should be 
> taken out of the tests, but AFAICT there is no technical advantage
> on either side of this debate.

Technical, no. Confusion-wise, yes. The less guns you give to your users, the 
less the chance that they will shoot themselves ;)

__________________________________________________________________
Stas Bekman            JAm_pH ------> Just Another mod_perl Hacker
http://stason.org/     mod_perl Guide ---> http://perl.apache.org
mailto:stas@stason.org http://use.perl.org http://apacheweek.com
http://modperlbook.org http://apache.org   http://ticketmaster.com


Re: cvs commit: httpd-apreq-2/glue/perl/t/response/TestApReq inherit.pm request.pm

Posted by Joe Schaefer <jo...@sunstarsys.com>.
Stas Bekman <st...@stason.org> writes:

[...]

> Not to you. But users may try to run these as is, without using
> $^X. I've pointed it out for this reason, just trying to minimize
> support pains. 

If the shebang line is omitted, how will the users run the tests?
The files in question don't even have an executable bit set.

I appreciate the support concern, and since I seem to be alone
in my position, I'll concede that the shebang line should be 
taken out of the tests, but AFAICT there is no technical advantage
on either side of this debate.

-- 
Joe Schaefer


Re: cvs commit: httpd-apreq-2/glue/perl/t/response/TestApReq inherit.pm request.pm

Posted by Stas Bekman <st...@stason.org>.
Joe Schaefer wrote:
> Stas Bekman <st...@stason.org> writes:
> 
> 
>>joes@apache.org wrote:
>>
>>>joes        2003/06/13 02:46:52
>>>  Modified:    glue/perl/t TEST.PL
>>>               glue/perl/t/apreq big_input.t cookie.t inherit.t request.t
>>>               glue/perl/t/response/TestApReq inherit.pm request.pm
>>
>>>  Index: request.t
>>>  ===================================================================
>>>  RCS file: /home/cvs/httpd-apreq-2/glue/perl/t/apreq/request.t,v
>>>  retrieving revision 1.1
>>>  retrieving revision 1.2
>>>  diff -u -r1.1 -r1.2
>>>  --- request.t	9 Jun 2003 06:30:04 -0000	1.1
>>>  +++ request.t	13 Jun 2003 09:46:52 -0000	1.2
>>>  @@ -1,3 +1,4 @@
>>>  +#!/usr/bin/perl
>>
>>May I ask, why this path is hardcoded? 
> 
> 
> It serves no practical purpose other than to inform emacs of the 
> file type (as well as being conventional for perl scripts).  The 
> tests (.t files) aren't ever directly executed by a shell, so the 
> actual path isn't important.

You don't need to change the file for that, I have this rule in .xemacs/init.el:

(setq auto-mode-alist
       (append '(("\\.\\([pP][Llm]\\|al\\|cgi\\|pod\\|t\\)$" . perl-mode)) 
auto-mode-alist ))
(setq interpreter-mode-alist (append interpreter-mode-alist
                                       '(("miniperl" . perl-mode))))

oh, I see David has already posted a similar one.

>>This is certainly a bite for problems, when people have several perl
>>installs and they build with non-/usr/bin/perl but get to test with
>>it.
> 
> 
> Nah, it won't cause any problems; the tests are always run with 
> $^X, not #!.

Not to you. But users may try to run these as is, without using $^X. I've 
pointed it out for this reason, just trying to minimize support pains.

__________________________________________________________________
Stas Bekman            JAm_pH ------> Just Another mod_perl Hacker
http://stason.org/     mod_perl Guide ---> http://perl.apache.org
mailto:stas@stason.org http://use.perl.org http://apacheweek.com
http://modperlbook.org http://apache.org   http://ticketmaster.com


Re: cvs commit: httpd-apreq-2/glue/perl/t/response/TestApReq inherit.pm request.pm

Posted by David Wheeler <da...@wheeler.net>.
On Saturday, June 14, 2003, at 01:44  AM, Joe Schaefer wrote:

> It serves no practical purpose other than to inform emacs of the
> file type (as well as being conventional for perl scripts).  The
> tests (.t files) aren't ever directly executed by a shell, so the
> actual path isn't important.

I personally don't like to put editor-specific stuff into files. I use 
this in my ~/.emacs, instead:

(setq auto-mode-alist
       (append
        '(("\\.\\([pP]\\([Llm]\\|erl\\)\\|al\\|pod\\|t\\)\\'" . 
cperl-mode))
        auto-mode-alist))

Gotta love lisp regexen, though, eh? ;-)

David

-- 
David Wheeler                                     AIM: dwTheory
david@kineticode.com                              ICQ: 15726394
http://kineticode.com/                         Yahoo!: dew7e
                                                Jabber: Theory@jabber.org
Kineticode. Setting knowledge in motion.[sm]


Re: cvs commit: httpd-apreq-2/glue/perl/t/response/TestApReq inherit.pm request.pm

Posted by Joe Schaefer <jo...@sunstarsys.com>.
Stas Bekman <st...@stason.org> writes:

> joes@apache.org wrote:
> > joes        2003/06/13 02:46:52
> >   Modified:    glue/perl/t TEST.PL
> >                glue/perl/t/apreq big_input.t cookie.t inherit.t request.t
> >                glue/perl/t/response/TestApReq inherit.pm request.pm
> 
> >   Index: request.t
> >   ===================================================================
> >   RCS file: /home/cvs/httpd-apreq-2/glue/perl/t/apreq/request.t,v
> >   retrieving revision 1.1
> >   retrieving revision 1.2
> >   diff -u -r1.1 -r1.2
> >   --- request.t	9 Jun 2003 06:30:04 -0000	1.1
> >   +++ request.t	13 Jun 2003 09:46:52 -0000	1.2
> >   @@ -1,3 +1,4 @@
> >   +#!/usr/bin/perl
> 
> May I ask, why this path is hardcoded? 

It serves no practical purpose other than to inform emacs of the 
file type (as well as being conventional for perl scripts).  The 
tests (.t files) aren't ever directly executed by a shell, so the 
actual path isn't important.

> This is certainly a bite for problems, when people have several perl
> installs and they build with non-/usr/bin/perl but get to test with
> it.

Nah, it won't cause any problems; the tests are always run with 
$^X, not #!.

-- 
Joe Schaefer


Re: cvs commit: httpd-apreq-2/glue/perl/t/response/TestApReq inherit.pm request.pm

Posted by Stas Bekman <st...@stason.org>.
joes@apache.org wrote:
> joes        2003/06/13 02:46:52
> 
>   Modified:    glue/perl/t TEST.PL
>                glue/perl/t/apreq big_input.t cookie.t inherit.t request.t
>                glue/perl/t/response/TestApReq inherit.pm request.pm

>   Index: request.t
>   ===================================================================
>   RCS file: /home/cvs/httpd-apreq-2/glue/perl/t/apreq/request.t,v
>   retrieving revision 1.1
>   retrieving revision 1.2
>   diff -u -r1.1 -r1.2
>   --- request.t	9 Jun 2003 06:30:04 -0000	1.1
>   +++ request.t	13 Jun 2003 09:46:52 -0000	1.2
>   @@ -1,3 +1,4 @@
>   +#!/usr/bin/perl

May I ask, why this path is hardcoded? This is certainly a bite for problems, 
when people have several perl installs and they build with non-/usr/bin/perl 
but get to test with it.

__________________________________________________________________
Stas Bekman            JAm_pH ------> Just Another mod_perl Hacker
http://stason.org/     mod_perl Guide ---> http://perl.apache.org
mailto:stas@stason.org http://use.perl.org http://apacheweek.com
http://modperlbook.org http://apache.org   http://ticketmaster.com