logo       

Re: passing arguments to tests: msg#00041

Subject: Re: passing arguments to tests

5.8.1  recently started failing 2 tests in op/cproto.t, on pop(), shift();

this only happens on one box, ie RH-7.2, not RH-9, and I havent tried
a make distclean, so I havent reported it to p5p.

Instead I decided that some false laziness was in order, and I should go digging.
But, I thought it would be handy to run only those 2 tests, ie:

       [jimc@harpo t]$ ./perl op/cproto.t 130 178

which when run, gives:

....(debugging elided)
1..234
not ok 130 - pop
#     Failed test (../lib/Test/More.pm at line 332)
not ok 178 - shift
#     Failed test (../lib/Test/More.pm at line 332)
WHOA!  Somehow you got a different number of results than tests ran!
This should never happen!  Please contact the author immediately!
END failed--call queue aborted, <DATA> line 234.


I did this by hacking horribly on Test::Builder so that it

   1. reads @ARGV to know what test numbers to run. (130, 178 above)
*yes, action at a distance*, but it allows Test::More users to get selective,
         nominally w/o breaking tests
      ( not quite - failures now 11, not 2, using the patch)

   2. skips tests that arent in @ARGV, if @ARGV;

   3. <contrite sincerity='low' ulterior-motive='flame-retardance'>
I moved the is_*() functions into a subclass, then either package-aliased them or eval'd a new baseclass function which conditionally calls the sub-class one. It should be faster than just wrapping funcs with conditionals, and felt less like
         cut-paste programming...
Interestingly, I had to clone the BEGIN {require threads} block into the sub-class
         package too.
also, I used our $Level, from 5.6, cuz it fixed localization probs between base and subclass.
      </contrite>

Im certain the implementation is *unsuitable*, but Id like to advocate some
cmdline option which would allow constraining the test-list to the 'interesting' ones. It could be helpful when using debugger on tests (ive had issues with stepping thru
<DATA> sets in the past (charnames,iirc), though not with this test)

   ./perl op/cproto.t -testonly=130,178

Anyway, patch is attached for your amusement

--jimc

ps. make distclean would have been quicker ;-)
30,31c30
< #use vars qw($Level);
< our $Level;
---
> use vars qw($Level);
278,292d276
< package Test::Builder::Funcs;
< 
< BEGIN {
<     use Config;
<     if( $] >= 5.008 && $Config{useithreads} ) {
<         require threads;
<         require threads::shared;
<         threads::shared->import;
<     }
<     else {
<         *share = sub { 0 };
<         *lock  = sub { 0 };
<     }
< }
< 
384d367
<     #$Level = $Test::Builder::Level + 1;
401d383
<     #local $Level = $Test::Builder::Level + 1;
460d441
<     # local $Level = $Test::Builder::Level + 1;
477d457
<     #    local $Level = $Test::Builder::Level + 1;
515d494
<     # local $Level = $Test::Builder::Level + 1;
521a501
>     local $Level = $Level + 1;
570d549
<     # local $Level = $Test::Builder::Level + 1;
621d599
<     # local $Level = $Test::Builder::Level + 1;
646,688d623
< 
< our @TestOnly = @ARGV;
< 
< package Test::Builder;
< 
< { # unless (@ARGV) {
<     # no test-list args given, run all tests normally.
<     # basically, we'll insure that above sub-class functions are 'exported' up
<     no strict 'refs', 'subs';
<     foreach my $sub (keys %Test::Builder::Funcs::) {
<       next unless *{'Test::Builder::Funcs::'.$sub}{CODE};
<       unless (@TestOnly) {
<           print "Funcs::$sub\n";
<           *{'Test::Builder::'.$sub} = *{'Test::Builder::Funcs::'.$sub}{CODE};
<       } else {
<           next if *{'Test::Builder::'.$sub}{CODE};
<           my $proto = prototype('Test::Builder::Funcs::'.$sub);
<           print __PACKAGE__, "::$sub ($proto)\n";
<           my $code = qq{
<               #share (\$Curr_Test);
<               sub $sub { 
<                   unless (grep {\$_ == \$Curr_Test+1} \@TestOnly) {
<                       print "ok - skipping \$Curr_Test per cmdln args\\n";
<                       \$Curr_Test++;
<                       return 1;
<                   }
<                   goto &{Test::Builder::Funcs::$sub};
<               };
<             };
<             print "compiling: $code\n";
<             eval "$code";
<             warn $@ if $@;
<       }
<     }
<     # check it
<     foreach my $sub (keys %Test::Builder::) {
<       next unless *{'Test::Builder::Funcs::'.$sub}{CODE};
<       next unless *{'Test::Builder::'.$sub}{CODE};
<       print "defined $sub\n";
< 
<     }
< }
< 
<Prev in Thread] Current Thread [Next in Thread>
Google Custom Search

Recently Viewed:
boot-loaders.gr...    php.pear.genera...    debugging.valgr...    kde.redhat.user...    text.xml.xsl.ge...    culture.languag...    hardware.microc...    java.servicemix...    redhat.release....    web.zope.plone....    user-groups.lin...    opendarwin.webk...    video.mjpeg.use...    sysutils.bcfg2....    encryption.gpg....    lx-office.devel...    xfree86.forum/2...    mail.mutt.devel...    acpi.devel/2003...    qnx.openqnx.dev...    network.irc.irs...    freebsd.devel.m...   
Home | blog view | USPTO Patent Archive | advertise | OSDir is an inevitable website. super tiny logo

Free Magazines

Cisco News
Receive a free quarterly e-newsletter with exclusive articles on how Cisco IT uses its own products and solutions to enable the business.
subscribe

Systems Management News, the newspaper for IT systems administration and data center managers! Each issue of Systems Management News is chock-full of news and analysis to help you understand what's happening in your field.
subscribe

The Enterprise Newsweekly eWeek is the essential technology information source for builders of e-business.
subscribe

Oracle Magazine Oracle Magazine contains technology strategy articles, sample code, tips, Oracle and partner news, how to articles for developers and DBAs, and more. Oracle (NASDAQ: ORCL) is the world's largest enterprise software company.
subscribe

Total Telecom Total Telecom is "The Economist of the communications industry".
subscribe