Re: planning at the end

2006-07-23 Thread Nicholas Clark
On Thu, Jul 20, 2006 at 04:01:00PM -0700, Michael G Schwern wrote: > On 7/20/06, Gabor Szabo <[EMAIL PROTECTED]> wrote: > >If I am not mistaken the problem with no_plan is that the test script > >might exit before actually running all the tests you wanted and Harness > >won't notice it. > > PS In

Re: planning at the end

2006-07-21 Thread Adriano Ferreira
I'm beaten over this argument. After a little thought, I agree with Andy and chromatic that the "plan at the end" buys very little and can disturb the simplicity of the testing API for nothing. After all, it is very easy to write a code like that and rewrite our examples. use Test::More 'no_

Re: planning at the end

2006-07-21 Thread Adriano Ferreira
On 7/20/06, A. Pagaltzis <[EMAIL PROTECTED]> wrote: use Test::More; plan tests => my $tests; { require_ok( 'MyModule' ); my $obj = MyModule->new(); isa_ok( $obj, 'MyModule' ); } BEGIN { $tests += 3 } [snip clever code] Like Schwern said, this stuff

Re: planning at the end

2006-07-21 Thread Adriano Ferreira
On 7/20/06, David Wheeler <[EMAIL PROTECTED]> wrote: You probably could have used Test::More->builder->expected_tests to set the sample sized based on whatever value you put into the plan. I didn't know about Test::Builder->expected_tests, but from the code of Test::Builder 0.33 it looks like i

Re: planning at the end

2006-07-20 Thread Gabor Szabo
On 7/21/06, Michael G Schwern <[EMAIL PROTECTED]> wrote: On 7/20/06, Gabor Szabo <[EMAIL PROTECTED]> wrote: > If I am not mistaken the problem with no_plan is that the test script > might exit before actually running all the tests you wanted and Harness > won't notice it. PS In all my years of

Re: planning at the end

2006-07-20 Thread A. Pagaltzis
* Michael G Schwern <[EMAIL PROTECTED]> [2006-07-21 01:30]: > On 7/20/06, A. Pagaltzis <[EMAIL PROTECTED]> wrote: > >use Test::More; > > > >plan tests => my $tests; > > > >{ > >require_ok( 'MyModule' ); > >my $obj = MyModule->new(); > >isa_ok( $obj, 'MyModule' );

Re: planning at the end

2006-07-20 Thread Fergal Daly
On 21/07/06, chromatic <[EMAIL PROTECTED]> wrote: On Thursday 20 July 2006 16:57, Fergal Daly wrote: > On 21/07/06, chromatic <[EMAIL PROTECTED]> wrote: > > Test an XS component. Segfaults don't call done_testing_now(). > > > > Yes, that happened to me last night. Yes, I had 'no_plan' active.

Re: planning at the end

2006-07-20 Thread chromatic
On Thursday 20 July 2006 16:57, Fergal Daly wrote: > On 21/07/06, chromatic <[EMAIL PROTECTED]> wrote: > > Test an XS component. Segfaults don't call done_testing_now(). > > > > Yes, that happened to me last night. Yes, I had 'no_plan' active. Yes, > > I noticed it as a happy accident, thinkin

Re: planning at the end

2006-07-20 Thread Fergal Daly
On 21/07/06, chromatic <[EMAIL PROTECTED]> wrote: On Thursday 20 July 2006 16:01, Michael G Schwern wrote: > On 7/20/06, Gabor Szabo <[EMAIL PROTECTED]> wrote: > > If I am not mistaken the problem with no_plan is that the test script > > might exit before actually running all the tests you want

Re: planning at the end

2006-07-20 Thread chromatic
On Thursday 20 July 2006 16:01, Michael G Schwern wrote: > On 7/20/06, Gabor Szabo <[EMAIL PROTECTED]> wrote: > > If I am not mistaken the problem with no_plan is that the test script > > might exit before actually running all the tests you wanted and Harness > > won't notice it. > PS In all my

Re: planning at the end

2006-07-20 Thread Michael G Schwern
On 7/20/06, A. Pagaltzis <[EMAIL PROTECTED]> wrote: use Test::More; plan tests => my $tests; { require_ok( 'MyModule' ); my $obj = MyModule->new(); isa_ok( $obj, 'MyModule' ); } BEGIN { $tests += 3 } Pretty sneaky. This is now in the FAQ. http://pe

Re: planning at the end

2006-07-20 Thread Michael G Schwern
On 7/20/06, Gabor Szabo <[EMAIL PROTECTED]> wrote: If I am not mistaken the problem with no_plan is that the test script might exit before actually running all the tests you wanted and Harness won't notice it. PS In all my years of testing I have never been bitten by this in the real world whi

Re: planning at the end

2006-07-20 Thread Michael G Schwern
On 7/20/06, Gabor Szabo <[EMAIL PROTECTED]> wrote: If I am not mistaken the problem with no_plan is that the test script might exit before actually running all the tests you wanted and Harness won't notice it. That's what I wanted to avoid. So maybe if there was a mode where Test::Builder did n

Re: planning at the end

2006-07-20 Thread Michael G Schwern
On 7/20/06, Tyler MacDonald <[EMAIL PROTECTED]> wrote: Exactly. :-) Take a look at, for instance, IPC::Run's test cases... an array of sub{} blocks, some of which get skipped over on certain OS'es. It'd be really easy to accidentally put to ok()'s in one sub{} block and screw up the count

Re: planning at the end

2006-07-20 Thread A. Pagaltzis
* Tyler MacDonald <[EMAIL PROTECTED]> [2006-07-20 21:15]: > Take a look at, for instance, IPC::Run's test cases... an array > of sub{} blocks, some of which get skipped over on certain > OS'es. It'd be really easy to accidentally put to ok()'s in one > sub{} block and screw up the count. In the co

Re: planning at the end

2006-07-20 Thread A. Pagaltzis
* Adriano Ferreira <[EMAIL PROTECTED]> [2006-07-20 22:10]: > use Test::More; > > subplan tests => 2; > > require_ok('MyModule'); > my $obj = MyModule->new(); > isa_ok($obj, 'MyModule'); > > my @cities = ("Brasilia", "Rio de Janeiro", "Salvador"); > > subplan tests => [EMAIL PROTECTED]; > > fo

Re: planning at the end

2006-07-20 Thread David Wheeler
On Jul 20, 2006, at 13:38, Adriano Ferreira wrote: When I made changes, I usually decreased radically the size of the sample to not be drowned in "not ok". When everything was alright, I returned to sample sizes of 100 or so. It would have been easier if I could count with simple expressions and

Re: planning at the end

2006-07-20 Thread Adriano Ferreira
On 7/20/06, chromatic <[EMAIL PROTECTED]> wrote: I don't understand this. I have a Vim macro that switches between: use Test::More 'no_plan'; ... and: use Test::More tests => 1; When I work on a test suite, I switch off the plan. When I finish, I look at the number of tests

Re: planning at the end

2006-07-20 Thread Gabor Szabo
On 7/20/06, Andy Lester <[EMAIL PROTECTED]> wrote: On Jul 20, 2006, at 2:45 PM, Adriano Ferreira wrote: > Ok, that's weird. But it may occasionally have usefulness. Gabor > started the thread with the idea of having a test against web pages, > which he doesn't know how many at the beginning, bu

Re: planning at the end

2006-07-20 Thread chromatic
On Thursday 20 July 2006 13:05, Adriano Ferreira wrote: > Sometimes, I would like to > have something like that below so that I don't need to think about how > to compute the number of tests beforehand I don't understand this. I have a Vim macro that switches between: use Test::More 'no

Re: planning at the end

2006-07-20 Thread Adriano Ferreira
On 7/20/06, Hakim Cassimally <[EMAIL PROTECTED]> wrote: Restructuring your tests (moving OS-dependent, skippable sections to their own scripts for example) might make the requirement for a deferred plan seem less important ? Writing tests is harder. Writing code is more rewarding to the heart.

Re: planning at the end

2006-07-20 Thread Andy Lester
On Jul 20, 2006, at 2:45 PM, Adriano Ferreira wrote: Ok, that's weird. But it may occasionally have usefulness. Gabor started the thread with the idea of having a test against web pages, which he doesn't know how many at the beginning, but which may be verified at the end - his count against Te

Re: planning at the end

2006-07-20 Thread Adriano Ferreira
On 7/20/06, Andy Lester <[EMAIL PROTECTED]> wrote: On Jul 20, 2006, at 2:19 PM, Adriano Ferreira wrote: > was emitted, it would mean the test *should* tell the plan at the end. > If it doesn't, it is a failure. I don't think this is no protection. > It may be an improvement to 'no_plan' in cert

Re: planning at the end

2006-07-20 Thread Adriano Ferreira
On 7/20/06, Adriano Ferreira <[EMAIL PROTECTED]> wrote: When something like > >>> use Test::More tests => 'defer'; was emitted, it would mean the test *should* tell the plan at the end. If it doesn't, it is a failure. I don't think this is no protection. It may be an improvement to 'no_pl

Re: planning at the end

2006-07-20 Thread Andy Lester
On Jul 20, 2006, at 2:19 PM, Adriano Ferreira wrote: was emitted, it would mean the test *should* tell the plan at the end. If it doesn't, it is a failure. I don't think this is no protection. It may be an improvement to 'no_plan' in certain circumstances. What circumstance would that be? --

Re: planning at the end

2006-07-20 Thread Adriano Ferreira
On 7/20/06, Michael Peters <[EMAIL PROTECTED]> wrote: >> What benefit would that give? plan() is nice because it provides protection >> against you test script exiting prematurely. > > > The exact same benefit as doing a 'plan' at the > beginning, except this would work for scripts that don't k

Re: planning at the end

2006-07-20 Thread Tyler MacDonald
Michael Peters <[EMAIL PROTECTED]> wrote: > > If the calculated result used in the > > 'plan' at the end does not match the number of tests actually run, then you > > know you've got a problem with your test code. > > > > So this gives you protection against not being able to count? Exac

Re: planning at the end

2006-07-20 Thread Michael Peters
Tyler MacDonald wrote: > Michael Peters <[EMAIL PROTECTED]> wrote: >>> use Test::More tests => 'defer'; >>> >>> and then >>> >>> plan past_tests => $n; >> What benefit would that give? plan() is nice because it provides protection >> against you test script exiting prematurely. > >

Re: planning at the end

2006-07-20 Thread Tyler MacDonald
Michael Peters <[EMAIL PROTECTED]> wrote: > > use Test::More tests => 'defer'; > > > > and then > > > > plan past_tests => $n; > > What benefit would that give? plan() is nice because it provides protection > against you test script exiting prematurely. The exact same benefit as do

Re: planning at the end

2006-07-20 Thread Michael Peters
Adriano Ferreira wrote: > It would be something different, like > > use Test::More tests => 'defer'; > > and then > > plan past_tests => $n; What benefit would that give? plan() is nice because it provides protection against you test script exiting prematurely. -- Michael Peter

Re: planning at the end

2006-07-20 Thread Adriano Ferreira
On 7/20/06, Michael G Schwern <[EMAIL PROTECTED]> wrote: On 7/20/06, Gabor Szabo <[EMAIL PROTECTED]> wrote: > On the other hand I can count them during the test and can tell > Test::More that I was actually expecting $n tests. This is exactly how no_plan works. use Test::More 'no_plan'; Te

Re: planning at the end

2006-07-20 Thread Michael G Schwern
On 7/20/06, Gabor Szabo <[EMAIL PROTECTED]> wrote: As this is a live site with user created pages I don't know up front how many pages I am going to test thus I don't know the number of tests before I run them. On the other hand I can count them during the test and can tell Test::More that I was

Re: planning at the end

2006-07-20 Thread Andy Lester
On Jul 20, 2006, at 9:47 AM, Gabor Szabo wrote: Can I somehow do this - promise at the beginning that I will tell my plan at the end. (It should consider it a failuer if I don't give plan in the end.) No. That's not how plans work. Andy -- Andy Lester => [EMAIL PROTECTED] => www.petdance.c

Re: planning at the end

2006-07-20 Thread Gabor Szabo
I have a nasty workaround. # at the beginning my $test_allowance = 100; plan tests => $test_allowance; # run the tests here and for each test also execute $test_allowance--; # in the end ok(1) while $test_allowance--; I really hope there is a nicer way to do it. Gabor http://www.szabgab.

planning at the end

2006-07-20 Thread Gabor Szabo
While testing a *live* web site I crawl through several pages. For each page I would like to do some tests (e.g. it has a link to home, its HTML is valid, etc.) As this is a live site with user created pages I don't know up front how many pages I am going to test thus I don't know the number of t