emitting messages in Test::*
I noticed that Test::Builder offers the ability to emit messages with s/^/# /mg, which is very nice. Can/should this capability be exposed via Test::Simple, Test::More, etc? Sometimes it's nice to explain what to do about a test failure that may be an intermittent failure, or to warn that they should upgrade an optional prerequisite if one is too old, etc. Right now I just print "# ...\n", but that seems hackish when put in the same test scripts as the nice, shiny, new testing APIs. - Barrie
Re: emitting messages in Test::*
On Wed, Dec 19, 2001 at 07:52:03AM -0500, Barrie Slaymaker wrote: > I noticed that Test::Builder offers the ability to emit messages with > s/^/# /mg, which is very nice. Can/should this capability be exposed > via Test::Simple, Test::More, etc? Its been on the TODO list to toss a diag() into Test::More. ok( ... ) || diag(...); for some reason I keep putting it off. Test::Simple won't get one, it would double the size of the API! ;) -- Michael G. Schwern <[EMAIL PROTECTED]>http://www.pobox.com/~schwern/ Perl Quality Assurance <[EMAIL PROTECTED]> Kwalitee Is Job One The eye opening delightful morning taste of expired cheese bits in sour milk!
Re: v0.3 [Was: CPAN Upload: R/RB/RBS/Test-Differences-0.2.tar.gz]
On Mon, Dec 17, 2001 at 04:10:30PM +0900, Tatsuhiko Miyagawa wrote: > On Sat, 15 Dec 2001 09:10:33 -0500 > Barrie Slaymaker <[EMAIL PROTECTED]> wrote: > > > Now I see what you're after with the -M approach, thanks for the > > example. > > Cool. > > > I can understand that :) since CPAN is/seems a non-started for a > > significant number of folks (I have a Win32 system that it's > > nonfuncitonal on; haven't debugged it yet). > > I think Test::Differences is mainly for module developpers, We'll have to agree to disagree; I'd rather get test failure reports with more explanatory test output than less explanatory output. As Schwern points out, there's always the t/lib/Test/Differences.pm, use lib "t/lib"; approach if you want to make their lives easier. That's a bit more work on your part (ie keeping up with Test::Difference releases), and I can't blame anyone for not wanting more work :). > not for module users, thus the necessity for Test::Differences would > be better optional in distributing modules. I don't want to get in the business of overloading every future Test::* module's ok() (from Test.pm) and is_deeply() (from Test::More) equivalent. So I going to have to suggest that you do something like (tested): use Test; eval "use Test::Differences"; sub my_ok { goto &eq_or_diff if defined &eq_or_diff; goto &ok; } plan tests => 1; my_ok "a", "b"; That preserves line number reportage and gives you the flexibility you desire without the maint. hassle of tracking Test::Differences' releases. I've added this to the docs, thanks for pointing out the need. - Barrie
Re: emitting messages in Test::*
On Wed, 19 Dec 2001, Barrie Slaymaker wrote: > I noticed that Test::Builder offers the ability to emit messages with > s/^/# /mg, which is very nice. Can/should this capability be exposed > via Test::Simple, Test::More, etc? Can't you just "use Test::Builder" somewhere in your test script like so: use Test::More tests => 2; use Test::Builder; # get the singleton my $Test = Test::Builder->new(); unless(ok(0,"first test")) { # more diagnostic messages $Test->diag("Ooops\n","Badness\n"); } # this will still work ok(1, "second test"); Of course, a nicer interface than having to fall back to Test::Builder would be, um, nice. Later. Mark. -- s'' Mark Fowler London.pm Bath.pm http://www.twoshortplanks.com/ [EMAIL PROTECTED] ';use Term'Cap;$t=Tgetent Term'Cap{};print$t->Tputs(cl);for$w(split/ +/ ){for(0..30){$|=print$t->Tgoto(cm,$_,$y)." $w";select$k,$k,$k,.03}$y+=2}
Re: Test::Builder: Multiple test libraries in one test.
In perl.qa, you wrote: >Candidates for this sort of thing would be CGI::Test, Test::Cmd, >Test::Unit, Test::Mail and ExtUtils::TBone. And, of course, Barrie's >Test::Differences. Actually, Test::Mail doesn't work like that. It's more or less a wrapper around Test::More that handles incoming email. Doesn't implement any of its own ok()-like routines at all, just makes it easy to use Test::More's routines on incoming email. K. -- Kirrily 'Skud' Robert - [EMAIL PROTECTED] - http://infotrope.net/ Usenet: open mouth, insert foot, propagate internationally
Re: is() with arbitrary comparisions
In perl.qa, you wrote: >I think I have a solution to the rigidity of is(). ie. something with >the diagnostic output of is(), but the flexibility of ok(). >It all makes sense, so what I really need is a better name. How about: compare($foo, "<=", $bar) K. -- Kirrily 'Skud' Robert - [EMAIL PROTECTED] - http://infotrope.net/ "Does anyone know my root password?" --Renee (from the Netizen quotes file)
Re: is() with arbitrary comparisions
-BEGIN PGP SIGNED MESSAGE- Moin, On 11-Dec-01 Kirrily Robert tried to scribble about: > In perl.qa, you wrote: >>I think I have a solution to the rigidity of is(). ie. something with >>the diagnostic output of is(), but the flexibility of ok(). > >>It all makes sense, so what I really need is a better name. > > How about: > > compare($foo, "<=", $bar) I tried to "update" my BigInt testsuite from "use Test;" to "use Test::More" or "use Test::Simple". It wasn't easy. First, ok() is no no longer ok(), but is now is(), because ok() is no longer ok to use with ok($this,$that); but is() is ok with $that. And then there is isnt(), isn't it? Not to speak of the use of can_ok(), which you can use, ok? isnt() $that ok() with you? $that should pass() ok() & be ! like() $this fail() function I've heard about. I'll better skip() some releases until it is() ok() to use Test::More without() going insane().[0] And scalar localtime() you want YetAnotherComparingFunctionThatPrintsok? *hops around like() mad and flaps his wings* > "Does anyone know my root password?" > --Renee (from the Netizen quotes file) We. But we won't tell you. ;o) Regards, Te"I'll stick to use Test; for now"ls PS: SCNR;) [0] Any more than I already am, that is(). - -- perl -MDev::Bollocks -e'print Dev::Bollocks->rand(),"\n"' collaboratively expedite principle-centered solutions http://bloodgate.com/perl My current Perl projects PGP key available on http://bloodgate.com/tels.asc or via email -BEGIN PGP SIGNATURE- Version: 2.6.3i Charset: latin1 iQEVAwUBPCDGeXcLPEOTuEwVAQHNYgf9HdsU46rWzHLwSbThAdJQgN9TznkslpXf YN5pMdPoVJ20l3DI5HQrvN2pMQC/RIQQsmRiArCJyUItod/mf6X/FbyqxBHZwZGg JjPqgzr6WsQ1gItwoyVi3U7epra+nGKw8Ao7OOPOpganRbsuBjjVf9imGEz0GuqR 6pWGiyCCD5KePpC9nzCsUNrQM7CmOsYBQWdSAjDHYoeBsmrpSucJov/yvsJwT0XI vTmDjO/Q/OHRaj2RMfOVk+sK6awWZgfoApepSaDOf6Wa7UqtpPttOtFSNQxgDveH fhs6yyPP+e0wAKwtIUousG3+Hd2SDBk7l3En7CpS38gmR06oxDR+2g== =Dbmy -END PGP SIGNATURE-
Re: is() with arbitrary comparisions
On Wed, 19 Dec 2001 10:04:17 -0700, Tels wrote: > First, ok() is no no longer ok(), but is now is(), because ok() is no longer > ok to use with ok($this,$that); but is() is ok with $that. And then there is > isnt(), isn't it? Not to speak of the use of can_ok(), which you can use, ok? > isnt() $that ok() with you? $that should pass() ok() & be ! like() $this > fail() function I've heard about. I'll better skip() some releases until it > is() ok() to use Test::More without() going insane().[0] You just hurt my eyes, and I've read Slashcode. If you wrote up your experiences, perhaps it'd make a good article or tutorial on converting an existing test suite to Test::More. -- c
[PATCH] Re: emitting messages in Test::*
On Wed, 19 Dec 2001 05:12:05 -0700, Michael G Schwern wrote: > On Wed, Dec 19, 2001 at 07:52:03AM -0500, Barrie Slaymaker wrote: >> I noticed that Test::Builder offers the ability to emit messages with s/^/# >> /mg, which is very nice. Can/should this capability be exposed via >> Test::Simple, Test::More, etc? > > Its been on the TODO list to toss a diag() into Test::More. > > ok( ... ) || diag(...); > > for some reason I keep putting it off. > > Test::Simple won't get one, it would double the size of the API! ;) Something like this? diffing against a directory tree is odd... there must be a better way. -- c diff -ur /var/tmp/.cpan/build/Test-Simple-0.36/MANIFEST Test-Simple-0.36/MANIFEST --- /var/tmp/.cpan/build/Test-Simple-0.36/MANIFEST Thu Nov 29 12:11:49 2001 +++ Test-Simple-0.36/MANIFEST Wed Dec 19 12:17:21 2001 @@ -10,6 +10,7 @@ t/Builder.t t/More.t t/buffer.t +t/diag.t t/exit.t t/extra.t t/fail-like.t diff -ur /var/tmp/.cpan/build/Test-Simple-0.36/lib/Test/More.pm Test-Simple-0.36/lib/Test/More.pm --- /var/tmp/.cpan/build/Test-Simple-0.36/lib/Test/More.pm Tue Nov 27 13:41:34 2001 +++ Test-Simple-0.36/lib/Test/More.pm Wed Dec 19 12:01:26 2001 @@ -28,6 +28,7 @@ $TODO plan can_ok isa_ok +diag ); my $Test = Test::Builder->new; @@ -905,6 +906,21 @@ return eq_array( [sort _bogus_sort @$a1], [sort _bogus_sort @$a2] ); } +=cut + +=item B + + diag("Uh oh\n", "Something is wrong...\n"); + +Prints a diagnostic message or messages. These are guaranteed not to interfere +with test output, and they will be suppressed by any test harness when running +in quiet mode. They can be very handy otherwise. + +=cut + +sub diag { + $Test->diag(@_); +} =back --- /dev/null Thu Aug 30 03:54:37 2001 +++ Test-Simple-0.36/t/diag.t Wed Dec 19 12:16:18 2001 @@ -0,0 +1,46 @@ +#!perl -w +use strict; + +use Test::More; +use Test::Builder; + +# this is a singleton, easy enough to test this +my $Test = Test::Builder->new(); + +# now make a filehandle where we can send data +my $output; +tie *FAKEOUT, 'FakeOut', \$output; + +# force diagnostic output to a filehandle, glad I added this to Test::Builder :) +use vars qw( $TODO ); +$TODO = 1; +$Test->todo_output(\*FAKEOUT); + +diag("a single line"); + +my @lines; +push @lines, $output; +$output = ''; + +diag("multiple\n", "lines"); +push @lines, split(/\n/, $output); + +undef $TODO; + +plan tests => 4; + +is( scalar @lines, 3, 'diag() should send messages to its filehandle' ); +like( $lines[0], '/^#\s+/', '... should add comment mark to all lines' ); +is( $lines[0], "# a single line", '... should send exact message' ); +is( $output, "# multiple\n# lines", '... should append multi messages'); + +package FakeOut; + +sub TIEHANDLE { + bless( $_[1], $_[0] ); +} + +sub PRINT { + my $self = shift; + $$self .= join('', @_); +}
Re: is() with arbitrary comparisions
On Tue, Dec 11, 2001 at 01:52:12PM -0500, Kirrily Robert wrote: Are we doing the time warp again, or are the Huskies just tired of pulling the packets across the border? > How about: > > compare($foo, "<=", $bar) cmp_ok(). Close. -- Michael G. Schwern <[EMAIL PROTECTED]>http://www.pobox.com/~schwern/ Perl Quality Assurance <[EMAIL PROTECTED]> Kwalitee Is Job One "Let's face it," said bearded Rusty Simmons, opening a can after the race. "This is a good excuse to drink some beer." At 10:30 in the morning? "Well, it's past noon in Dublin," said teammate Mike [Joseph] Schwern. "It's our duty." -- "Sure, and It's a Great Day for Irish Runners" Newsday, Sunday, March 20, 1988
Re: Test::Builder: Multiple test libraries in one test.
On Thu, Dec 13, 2001 at 02:07:56PM -0500, Kirrily Robert wrote: > Actually, Test::Mail doesn't work like that. It's more or less a > wrapper around Test::More that handles incoming email. Doesn't > implement any of its own ok()-like routines at all, just makes it easy > to use Test::More's routines on incoming email. Ahh, in that case I might suggest instead of doing: *Test::Simple::TESTOUT = \*LOG; *Test::Simple::TESTERR = \*LOG; *Test::More::TESTERR = \*LOG; eval qq( package $package; use Test::More 'no_plan'; &${package}::$sub; ); which I have a feeling isn't going to work anymore, those filehandles are gone, you should do: $t = Test::Builder->new; $t->output(\*LOG); $t->failure_output(\*LOG); $t->todo_output(\*LOG); eval qq( package $package; use Test::More 'no_plan'; \n#line 1 $msgid &${package}::$sub; ); The "#line 1 $msgid" bit is so the failure output doesn't all say "Failed at /usr/local/share/perl/5.6.1/Test/Mail.pm line 58". But instead maybe something a little more meaningful like "Failed at [EMAIL PROTECTED] line 4" so you can at least track it back to the email which caused the problem. -- Michael G. Schwern <[EMAIL PROTECTED]>http://www.pobox.com/~schwern/ Perl Quality Assurance <[EMAIL PROTECTED]> Kwalitee Is Job One you're a bleeding-heart liberal. LET ME PLUG MY ASS WITH PASTE RIGHT NOW! -- japhy
Re: [PATCH] Re: emitting messages in Test::*
On Wed, Dec 19, 2001 at 12:20:35PM -0700, chromatic wrote: > Something like this? Something uncannily like this, only without the literal tabs. > diffing against a directory tree is odd... there must be a better > way. I usually just check each individual file into RCS (vc-register-buffer for the emacs heads) and then use rcsdiff -u on the files I've changed when I'm done (vc-diff). Thanks. -- Michael G. Schwern <[EMAIL PROTECTED]>http://www.pobox.com/~schwern/ Perl Quality Assurance <[EMAIL PROTECTED]> Kwalitee Is Job One and I pull out the Magnum from under the desk where I keep it in case someone laughs at a joke that's so dry it's got a built in water-fountain, and blow the lot of them away as a community Service. -- BOFH
Re: is() with arbitrary comparisions
On Wed, Dec 19, 2001 at 03:50:12PM -0500, Michael G Schwern wrote: > On Tue, Dec 11, 2001 at 01:52:12PM -0500, Kirrily Robert wrote: > > Are we doing the time warp again, or are the Huskies just tired of > pulling the packets across the border? > > > > How about: > > > > compare($foo, "<=", $bar) > > cmp_ok(). Close. My mail server got all confused and constipated for a few days. Sorry for the old email suddenly appearing today :) K.
Re: [PATCH] Re: emitting messages in Test::*
On Wed, Dec 19, 2001 at 12:20:35PM -0700, chromatic wrote: > On Wed, 19 Dec 2001 05:12:05 -0700, Michael G Schwern wrote: > > > Its been on the TODO list to toss a diag() into Test::More. > > > > ok( ... ) || diag(...); > > > > for some reason I keep putting it off. > > > > Test::Simple won't get one, it would double the size of the API! ;) > > Something like this? diffing against a directory tree is odd... there must be > a better way. diff -Naur old-dir new-dir works here, but only if both directory trees are pristine. Now that I've got Diff::Text out the door (though a bugfix release is headed out soon), perhaps a program that uses File::Find and Diff::Text while ignoring binary files, things matching MANIFEST.SKIP, and editor droppings wouldn't be a bad thing. Oh, for a mass injection of free time... Looks nice to me (not that I have anything to do with Schwern's modules :), but I think it needs to be in Test::More instead of Test::Simple. - Barrie
Re: is() with arbitrary comparisions
Tels posted some of his Test::More experiences off-list. Some of them are rather good so I'll post my reply on-list. On Wed, Dec 19, 2001 at 10:42:55PM +0100, Tels wrote: > * Use Test::Simple/More for new testfiles. It can help you. If Test::More > scares you, use Test::Simple or only a subset of T::M. > * Don't convert old tests needless, better spent the time adding tests. > (But the conversation might take little time so try it if you have only a > small testsuite). If it makes you feel any better, I still have heaps of modules which I haven't bothered to convert over to Test::More. I do it when I find myself needing a Test::More feature and usually not before. > For the Test-developers: > > * Test::More is already quite confusing (Especially since ok() is no longer > what it used to be and you now must use is()!). Actually, Test::More's ok() is just like Test's ok(). And its not. Test.pm's ok() has at least three forms of operation. ok( $foo eq $bar ); # like Test::More::ok() ok( $foo, $bar ); # like Test::More::is() ok( $foo, qr/bar/ );# like Test::More::like() and then there's some of the more out there functionality: ok( $foo, $bar ); # like is( &$foo, $bar ); if $foo happens to # be a code ref. I never understood why this # magic was added. ok( $foo, $bar ); # if $bar looks like a regex (ie. "/wibble/") # it works as like(). Otherwise its is(). # Sucks if $bar == '/usr/local/' So I preserved the first of the five (which just happened to correspond to the way I wrote my custom ok() functions) because it is the most generic of them all. You can write any test with it. I also decided that Test::More users would have to learn five different functions rather than learning one function with five different modes of operation. > Insted of spending time to add even more confusing functions that > are used very little (if at all), shouldn't we do something more > usefull? > > For instance, I know of a lot of CPAN modules without tests at all, and I > talked to a few authors, and even if they decide to add tests (after my > 'convincing' emails), it takes time, or never gets done, or the tests are > to simple and too few. An even more confusing Test::More might scare them > off even more. Don't hand them Test::More, hand them Test::Simple. Or Test::Tutorial which eases the user into the Test::More interface. I *might* be convinced into adding is() to Test::Simple. I tend to use that nearly as much as ok(). Test::More's interface is nearly complete. After diag() I don't think I'm going to be adding any more functions. The rest will be either Test::Builder methods or left to a 3rd party Test::Builder based mix-in module (a la Test::Differences) to handle. Of course, with Test::Builder you can make your own test library in your own image and not have to listen to me anymore. -- Michael G. Schwern <[EMAIL PROTECTED]>http://www.pobox.com/~schwern/ Perl Quality Assurance <[EMAIL PROTECTED]> Kwalitee Is Job One Some like elmers glue but it needs reapplying. I use super glue. -- tlk
Re: is() with arbitrary comparisions
On Wed, Dec 19, 2001 at 05:39:45PM -0500, Michael G Schwern wrote: > > For instance, I know of a lot of CPAN modules without tests at all, and I > > talked to a few authors, and even if they decide to add tests (after my > > 'convincing' emails), it takes time, or never gets done, or the tests are > > to simple and too few. An even more confusing Test::More might scare them > > off even more. Looking again at Test::More's rather lengthy SYNOPSIS, I'll take kindly to doc reorganizations. -- Michael G. Schwern <[EMAIL PROTECTED]>http://www.pobox.com/~schwern/ Perl Quality Assurance <[EMAIL PROTECTED]> Kwalitee Is Job One sun readdened wheat stalks bowing down in autumn sun my mind wanders far -- stimps
[ANNOUNCE] Test::Simple/More/Builder/Tutorial 0.41
Small update. diag() has finally been added to Test::More, thanks to chromatic. Also, I noticed that internal eval()s were interfering with the outside's $@ and $!, so I protected against that. Why eval() is fiddling with $! I don't know. 0.41 Mon Dec 17 22:45:20 EST 2001 * chromatic added diag() - Internal eval()'s sometimes interfering with $@ and $!. Fixed. 0.40 Fri Dec 14 15:41:39 EST 2001 * isa_ok() now accepts unblessed references gracefully - Nick Clark found a bug with like() and a regex with % in it. - exit.t was hanging on 5.005_03 VMS perl. Test now skipped. - can_ok() would pass if no methods were given. Now fails. - isnt() diagnostic output format changed * Added some docs about embedding and extending Test::More * Added Test::More->builder * Added cmp_ok() * Added todo_skip() * Added unlike() - Piers pointed out that sometimes people override isa(). isa_ok() now accounts for that. -- Michael G. Schwern <[EMAIL PROTECTED]>http://www.pobox.com/~schwern/ Perl Quality Assurance <[EMAIL PROTECTED]> Kwalitee Is Job One i need another hit just gimme some fucking paste please, it hurts so bad -- Fmh
Untested modules update: The Magic Number is 27
The good news is lib.t and MM_Unix just went into the core. The even better news is Wolfgang Laun came riding in out of the East and has begun fixing perlcc! He's repairing B::Assembler and B::Disassembler and has written assembler.t And not to break the trend, the Net::Ping CPAN distribution already has a battery of tests which are ready-made for the core. Jarkko's looking to see if there's some reason we're not using them already. The bad news is the remaining Pod::* modules need a champion. And does anyone have a Netware machine so we can try out ExtUtils::MM_NW5? The magic number is 27 (26 if Net::Ping goes in). #B::Bytecode[module broken, can't test] #B::C [ditto] #B::CC [ditto ditto] #B::Concise [[EMAIL PROTECTED]] #B::Disassembler[Wolfgang Laun] #B::Lint[[EMAIL PROTECTED]] #B::Stackobj[[EMAIL PROTECTED]] #B::Xref[[EMAIL PROTECTED]] Byteloader CPAN # CPAN::FirstTime [[EMAIL PROTECTED]] in progress Dynaloader ExtUtils::MM_NW5 # ExtUtils::MM_OS2 [[EMAIL PROTECTED]] ExtUtils::MM_VMS [exists, but needs some lovin'] # ExtUtils::MM_Win32 [[EMAIL PROTECTED]] ExtUtils::Install ExtUtils::Liblist ExtUtils::Mksymlists # Net::Cmd [[EMAIL PROTECTED]] Net::Domain # Net::Ping [[EMAIL PROTECTED] (could be taken from the CPAN dist)] Net::POP3 # O [[EMAIL PROTECTED]] in progress Pod::Functions (no docs!) Pod::Html Pod::InputObjects Pod::Select Pod::Usage # re [[EMAIL PROTECTED]] proposed patch on p5p -- Michael G. Schwern <[EMAIL PROTECTED]>http://www.pobox.com/~schwern/ Perl Quality Assurance <[EMAIL PROTECTED]> Kwalitee Is Job One I'm exploring my nipples.