You are viewing a plain text version of this content. The canonical link for it is here.
Posted to test-dev@httpd.apache.org by William McKee <wi...@knowmad.com> on 2004/07/10 01:27:28 UTC

A::T :withtestmore

Hi all,

I'm having some problems getting Apache::Test working with Test::More
for my response tests. It's working fine in my request tests but my
server is silently failing with the following output:

  server localhost:8529 started
  t/apache/knowmad/mailform/cgiapp_setup....request has failed (the response code was: 500)
  see t/logs/error_log for more details

Checking the logs only shows the server starting and stopping. If I
change the test count, I get messages such as:

  # Looks like you planned 6 tests but only ran 1

This makes me think the handler is running but output is not getting
returned to the request script. If I switch back to the default A::T
format, the tests pass fine.

Can anyone confirm/deny this behavior? In the meantime, I'll try to put
together a test script.


Thanks,
William

-- 
Knowmad Services Inc.
http://www.knowmad.com

Re: A::T :withtestmore

Posted by William McKee <wi...@knowmad.com>.
On Tue, Jul 13, 2004 at 09:12:32AM -0400, Geoffrey Young wrote:
> the limitation here is that perl package namespaces cannot contain hyphens,
> which is not specifically mentioned but can be inferred from perlvar.pod,
> "Technical Note on the Syntax of Variable Names".

Thanks for the explanation. Makes perfect sense now.


William

-- 
Knowmad Services Inc.
http://www.knowmad.com

Re: A::T :withtestmore

Posted by Geoffrey Young <ge...@modperlcookbook.org>.
>>I changed it to bugpm.pm (and changed the package name) and it worked fine.
> 
> 
> Actually, changing it to bug_tm.pm works. I had forgotten to change the
> package name when I retested :(. So hyphens in response tests are a bad
> thing?

the limitation here is that perl package namespaces cannot contain hyphens,
which is not specifically mentioned but can be inferred from perlvar.pod,
"Technical Note on the Syntax of Variable Names".

--Geoff

Re: A::T :withtestmore

Posted by William McKee <wi...@knowmad.com>.
On Sun, Jul 11, 2004 at 11:29:07PM -0400, Geoffrey Young wrote:
> > This makes me think that there may be a problem in the bug testing
> > framework itself when used in conjunction with the -testmore action.
> 
> I don't think so :)

I appreciate your confidence <g>.


> > I
> > don't see a require statement in Bug.pm so am at a loss to say why this
> > would be failing. I tried changing the name of bug-tm.pm to bug_tm.pm in
> > case the hypen was a problem; it didn't help. Any other ideas?
> 
> I changed it to bugpm.pm (and changed the package name) and it worked fine.

Actually, changing it to bug_tm.pm works. I had forgotten to change the
package name when I retested :(. So hyphens in response tests are a bad
thing?

At any rate, my system now appears to support Test::More in response
tests. Yeah!


Thanks,
William

-- 
Knowmad Services Inc.
http://www.knowmad.com

Re: A::T :withtestmore

Posted by Geoffrey Young <ge...@modperlcookbook.org>.
>   [Sun Jul 11 16:31:59 2004] [notice] Accept mutex: sysvsem (Default: sysvsem)
>   Warning: Use of "require" without parentheses is ambiguous at (eval 12) line 1.
>   [Sun Jul 11 16:32:01 2004] [error] Undefined subroutine &TestApache::My::Bug::bug-tm::handler called.\n
>   [Sun Jul 11 16:32:01 2004] [info] removed PID file /home/william/perl/bug-reporting-skeleton-mp1/t/logs/httpd.pid (pid=2537)
> 
> 
> Do you see this error when you run my package?

yup.

> 
> This makes me think that there may be a problem in the bug testing
> framework itself when used in conjunction with the -testmore action.

I don't think so :)

> I
> don't see a require statement in Bug.pm so am at a loss to say why this
> would be failing. I tried changing the name of bug-tm.pm to bug_tm.pm in
> case the hypen was a problem; it didn't help. Any other ideas?

I changed it to bugpm.pm (and changed the package name) and it worked fine.

--Geoff

Re: A::T :withtestmore

Posted by William McKee <wi...@knowmad.com>.
On Sat, Jul 10, 2004 at 03:10:11PM -0400, Geoffrey Young wrote:
> I couldn't get that patch to apply to current cvs.

Maybe that's my problem. I applied the patch to the Test.pm from 1.12
release.


> > However, I'm still not getting the expected
> > results. I suppose that could be the fuzz factor you mentioned but put
> > together a new version of my test package in case you want to see if I'm
> > just doing something stupid[1].
> 
> well, I get the same results, and I can't see offhand what you are doing
> wrong.  but I started a tarball from scratch and was able to get it working
> with no problem at all.  so, try this tarball
> 
>   http://perl.apache.org/~geoff/testmore-geoff.tar.gz

Thanks. This works for me too so I guess the patch works against the
1.12 version. I checked the error logs and found the following
difference in mine:

  [Sun Jul 11 16:31:59 2004] [notice] Accept mutex: sysvsem (Default: sysvsem)
  Warning: Use of "require" without parentheses is ambiguous at (eval 12) line 1.
  [Sun Jul 11 16:32:01 2004] [error] Undefined subroutine &TestApache::My::Bug::bug-tm::handler called.\n
  [Sun Jul 11 16:32:01 2004] [info] removed PID file /home/william/perl/bug-reporting-skeleton-mp1/t/logs/httpd.pid (pid=2537)


Do you see this error when you run my package?

This makes me think that there may be a problem in the bug testing
framework itself when used in conjunction with the -testmore action. I
don't see a require statement in Bug.pm so am at a loss to say why this
would be failing. I tried changing the name of bug-tm.pm to bug_tm.pm in
case the hypen was a problem; it didn't help. Any other ideas?


Thanks,
William

-- 
Knowmad Services Inc.
http://www.knowmad.com

Re: A::T :withtestmore

Posted by Geoffrey Young <ge...@modperlcookbook.org>.

William McKee wrote:
> Hi Geoff,
> 
> Thanks for the info and the patch. I applied the patch without a problem
> and then went to install the developer release of T::M. Dost my eyes
> decieve me or does that say it was last updated on November 11, 2002?
> That's a long release cycle.

indeed.

> 
> At any rate, I installed the latest copy of T::M and read your
> directions in the patch. 

I couldn't get that patch to apply to current cvs.

> However, I'm still not getting the expected
> results. I suppose that could be the fuzz factor you mentioned but put
> together a new version of my test package in case you want to see if I'm
> just doing something stupid[1].

well, I get the same results, and I can't see offhand what you are doing
wrong.  but I started a tarball from scratch and was able to get it working
with no problem at all.  so, try this tarball

  http://perl.apache.org/~geoff/testmore-geoff.tar.gz

which includes a new patch against current cvs.  after installing
Test-Simple-0.48_01 I get the expected output:

server localhost.localdomain:8529 started
t/geoff/foo....1..1
# Using Apache/Test.pm version 1.13
ok 1 - use Apache::Constants;
ok
All tests successful.

note (among other things) the lack of Test.pm verbose headers.

> 
> I understand that you can't release this code until T::M is released but
> considering that T::M may be a bit longer baking, an additional caveat
> in the A::T pod would be useful in case T::M doesn't get released before
> the next release of A::T. I've attached a patch against the pristine
> version of 1.12.

I thought I mentioned something like that someplace?  oh, well... yeah, I'll
look it over and make sure the docs are better.

--Geoff

Re: A::T :withtestmore

Posted by William McKee <wi...@knowmad.com>.
Hi Geoff,

Thanks for the info and the patch. I applied the patch without a problem
and then went to install the developer release of T::M. Dost my eyes
decieve me or does that say it was last updated on November 11, 2002?
That's a long release cycle.

At any rate, I installed the latest copy of T::M and read your
directions in the patch. However, I'm still not getting the expected
results. I suppose that could be the fuzz factor you mentioned but put
together a new version of my test package in case you want to see if I'm
just doing something stupid[1].

I understand that you can't release this code until T::M is released but
considering that T::M may be a bit longer baking, an additional caveat
in the A::T pod would be useful in case T::M doesn't get released before
the next release of A::T. I've attached a patch against the pristine
version of 1.12.


Thanks,
William

[1] http://knowmad.com/~william/testmore-bug.tar.gz

-- 
Knowmad Services Inc.
http://www.knowmad.com

Re: A::T :withtestmore

Posted by Geoffrey Young <ge...@modperlcookbook.org>.
> The problem appears to be due to headers not being sent when using
> Test::More. I found the code in Apache::Test which initializes a handler
> when `plan $r, tests => 10` is called.

you can't use Test::More on the server side (that is, from a handler, such
as you have here).  at least not with the current Apache-Test.

to do that, you need to apply the attached patch - it may have some fuzz due
to a change that I just implemented this week, but I have been using it for
a few months now and haven't had any problems (once I figured out all the
issues, that is).

so, apply the patch and read the docs in the patch and you should be good to
go.  if you have trouble getting it to apply I'll whip up a current one next
week.

oh, and keep in mind that until Test::More goes official with the features
in the (required) development version this will _not_ get integrated into
Apache-Test.  that's not to say I haven't found it stable, but rather that
we can't integrate features into our stable software that depend on an
external development API.

--Geoff

Re: A::T :withtestmore

Posted by William McKee <wi...@knowmad.com>.
On Fri, Jul 09, 2004 at 07:27:28PM -0400, William McKee wrote:
> Can anyone confirm/deny this behavior? In the meantime, I'll try to put
> together a test script.

I've been able to reproduce the error using Geoff's skeleton. I almost
thought I had it fixed, but it's a bit beyond my knowledge and skills
(esp. on a Friday evening!).

The problem appears to be due to headers not being sent when using
Test::More. I found the code in Apache::Test which initializes a handler
when `plan $r, tests => 10` is called. This sends a http header. I copied
it into my bug-tm.pm response handler (t/response/TestApache/My/Bug) but
am still getting 500 errors with nothing in the error_log.

The test is available at my website[1]. The default version will work! I
wanted to show that using Apache::Test normally in a response handler is
working. You'll need to change the name of
t/response/TestApache/My/Bug/bug-tm.pm.off so that it gets tested. In my
tests, doing this causes both bug.t and bug-tm.t to fail.


Thanks,
William

[1] http://knowmad.com/~william/testmore-bug.tar.gz

-- 
Knowmad Services Inc.
http://www.knowmad.com