Re: Calling All Test:: Authors
- Original Message > From: Michael G Schwern > > > The latest developer release of Test::More allows subtests. Subtests are > > great > > in that they solve a lot of problems in advanced Perl testing, but they have > > required a change in Test::Builder. > > Whoa whoa whoa! While its great and all to get people to change their code to > use Test::Builder::Module, I think we got our wires crossed. > > subtest() has to be fixed to work with the existing singleton style. There's > just far too much code out there making that assumption and I'm not going to > pretend they're all suddenly going to change or that it all lives on CPAN. I remember, when I was a child, reading a parable about a bunch of monkeys who complained about their leaky roof, but every time the sun came out, they always ran around and played and never fixed that roof. Then the rain would return and they'd huddle inside and complain about the leaky roof. I know subtest() needs to be fixed. However, the next time this issue comes around (and there *will* be a next time if we don't plan for it :) it would be nice if the roof was fixed (or at lest less leaky). The great thing about pointing out this issue and asking module authors to address this is that it's NOT an emergency. Now if you'll excuse me, I need to go play in the sunshine. Cheers, Ovid -- Buy the book - http://www.oreilly.com/catalog/perlhks/ Tech blog- http://use.perl.org/~Ovid/journal/ Twitter - http://twitter.com/OvidPerl Official Perl 6 Wiki - http://www.perlfoundation.org/perl6
Re: Calling All Test:: Authors
Ricardo SIGNES wrote: > * Ovid [2009-06-30T10:21:24] >> The latest developer release of Test::More allows subtests. Subtests are >> great in that they solve a lot of problems in advanced Perl testing, but they >> have required a change in Test::Builder. Previously you could do stuff like >> this: > > I updated my Test:: libraries to Test::Builder->new in their test routines, > instead, as that's what I thought the original wisdom was. Is that still > okay? (I did not add subtest-specific tests.) > > That is, I turned: > > my $TEST = Test::Builder->new; > sub is_baloney { $TEST->ok('delicious') } > > into: > > sub is_baloney { > my $TEST = Test::Builder->new; > $TEST->ok('delicious'); > } Using Test::Builder::Module and the builder method will do a better job of future-proofing you if/when I decide to take advantage of it. -- "I went to college, which is a lot like being in the Army, except when stupid people yell at me for stupid things, I can hit them." -- Jonathan Schwarz
Re: Calling All Test:: Authors
Ovid wrote: > (Helps if I send this from a subscribed address): > > From http://use.perl.org/~Ovid/journal/39193 > > The latest developer release of Test::More allows subtests. Subtests are great > in that they solve a lot of problems in advanced Perl testing, but they have > required a change in Test::Builder. Whoa whoa whoa! While its great and all to get people to change their code to use Test::Builder::Module, I think we got our wires crossed. subtest() has to be fixed to work with the existing singleton style. There's just far too much code out there making that assumption and I'm not going to pretend they're all suddenly going to change or that it all lives on CPAN. -- But there's no sense crying over every mistake. You just keep on trying till you run out of cake. -- Jonathan Coulton, "Still Alive"
Re: Calling All Test:: Authors
- Original Message > From: Ricardo SIGNES > > I updated my Test:: libraries to Test::Builder->new in their test routines, > instead, as that's what I thought the original wisdom was. Is that still > okay? (I did not add subtest-specific tests.) > > That is, I turned: > > my $TEST = Test::Builder->new; > sub is_baloney { $TEST->ok('delicious') } > > into: > > sub is_baloney { > my $TEST = Test::Builder->new; > $TEST->ok('delicious'); > } Currently this should be fine as all the builder() method does is call Test::Builder->new (and that's what I did in Test::JSON, to be honest). I can't say whether or not this behavior will change in the future. I just used the information passed to me by Schwern and by the Test::Builder::Module documentation. Cheers, Ovid -- Buy the book - http://www.oreilly.com/catalog/perlhks/ Tech blog- http://use.perl.org/~Ovid/journal/ Twitter - http://twitter.com/OvidPerl Official Perl 6 Wiki - http://www.perlfoundation.org/perl6
Re: Calling All Test:: Authors
On Tue, Jun 30, 2009 at 11:01 AM, David Golden wrote: > On Tue, Jun 30, 2009 at 10:21 AM, Ovid wrote: >> my $BUILDER = Test::Builder->new; > > I'm running visitcpan to generate a list of offenders now. Results posted > soon. And here we go: http://echo.dagolden.com/~xdg/2009-06-30-test-builder-new.txt Some are certainly false positives, e.g. Test-Simple itself. -- David
Re: Calling All Test:: Authors
On Tue, Jun 30, 2009 at 10:21 AM, Ovid wrote: > my $BUILDER = Test::Builder->new; I'm running visitcpan to generate a list of offenders now. Results posted soon. -- David
Re: Calling All Test:: Authors
* Ovid [2009-06-30T10:21:24] > The latest developer release of Test::More allows subtests. Subtests are > great in that they solve a lot of problems in advanced Perl testing, but they > have required a change in Test::Builder. Previously you could do stuff like > this: I updated my Test:: libraries to Test::Builder->new in their test routines, instead, as that's what I thought the original wisdom was. Is that still okay? (I did not add subtest-specific tests.) That is, I turned: my $TEST = Test::Builder->new; sub is_baloney { $TEST->ok('delicious') } into: sub is_baloney { my $TEST = Test::Builder->new; $TEST->ok('delicious'); } -- rjbs
Calling All Test:: Authors
>From http://use.perl.org/~Ovid/journal/39193 The latest developer release of Test::More allows subtests. Subtests are great in that they solve a lot of problems in advanced Perl testing, but they have required a change in Test::Builder. Previously you could do stuff like this: package Test::StringReverse; use base 'Test::Builder::Module'; our @EXPORT = qw(is_reversed); my $BUILDER = Test::Builder->new; sub is_reversed ($$;$) { my ( $have, $want, $name ) = @_; my $passed = $want eq scalar reverse $name; $BUILDER->ok($passed, $name); $BUILDER->diag(<<"END_DIAG") if not $passed; have: $have want: $want END_DIAG return $passed; } 1; And you've have a simple (untested;) test for whether or not strings are reversed. The reason that worked is that Test::Builder->new used to return a singleton. This is no longer true. If someone uses your test library in a subtest, the above code would break. Instead, you want to do this: sub is_reversed ($$;$) { my ( $have, $want, $name ) = @_; my $passed = $want eq scalar reverse $name; my $builder = __PACKAGE__->builder; $builder->ok($passed, $name); $builder->diag(<<"END_DIAG") if not $passed; have: $have want: $want END_DIAG return $passed; } It's a minor change, it's completely backwards-compatible and it supports subtests. Cheers, Ovid -- Buy the book - http://www.oreilly.com/catalog/perlhks/ Tech blog- http://use.perl.org/~Ovid/journal/ Twitter - http://twitter.com/OvidPerl Official Perl 6 Wiki - http://www.perlfoundation.org/perl6
Calling All Test:: Authors
(Helps if I send this from a subscribed address): From http://use.perl.org/~Ovid/journal/39193 The latest developer release of Test::More allows subtests. Subtests are great in that they solve a lot of problems in advanced Perl testing, but they have required a change in Test::Builder. Previously you could do stuff like this: package Test::StringReverse; use base 'Test::Builder::Module'; our @EXPORT = qw(is_reversed); my $BUILDER = Test::Builder->new; sub is_reversed ($$;$) { my ( $have, $want, $name ) = @_; my $passed = $want eq scalar reverse $name; $BUILDER->ok($passed, $name); $BUILDER->diag(<<"END_DIAG") if not $passed; have: $have want: $want END_DIAG return $passed; } 1; And you've have a simple (untested;) test for whether or not strings are reversed. The reason that worked is that Test::Builder->new used to return a singleton. This is no longer true. If someone uses your test library in a subtest, the above code would break. Instead, you want to do this: sub is_reversed ($$;$) { my ( $have, $want, $name ) = @_; my $passed = $want eq scalar reverse $name; my $builder = __PACKAGE__->builder; $builder->ok($passed, $name); $builder->diag(<<"END_DIAG") if not $passed; have: $have want: $want END_DIAG return $passed; } It's a minor change, it's completely backwards-compatible and it supports subtests. Cheers, Ovid -- Buy the book - http://www.oreilly.com/catalog/perlhks/ Tech blog- http://use.perl.org/~Ovid/journal/ Twitter - http://twitter.com/OvidPerl Official Perl 6 Wiki - http://www.perlfoundation.org/perl6 -- Buy the book - http://www.oreilly.com/catalog/perlhks/ Tech blog- http://use.perl.org/~Ovid/journal/ Twitter - http://twitter.com/OvidPerl Official Perl 6 Wiki - http://www.perlfoundation.org/perl6