Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses

TODO blocks for Test::XML, and in general

by nglenn (Beadle)
on Sep 04, 2012 at 16:56 UTC ( #991654=perlquestion: print w/replies, xml ) Need Help??
nglenn has asked for the wisdom of the Perl Monks concerning the following question:

I'm trying to use Test::XML::XPath, and I need to user Test::More's TODO block. It doesn't seem to work as stated in the Test::More documentation; this doesn't work:

use Test::More; use Test::XML::XPath; plan tests=>1; TODO: { local $TODO = 'testing todo block'; like_xpath('<xml-bad/>', '/xml', 'test test'); }

Running prove with the above test placed in 'test.t' gives the following output, failing the suite instead of passing it:

t\test.t .. t\test.t .. 1/1 # Failed test 'test test' # at C:/strawberry/perl/site/lib/Test/XML/ line 55. # input: <xml-bad/> # does not match: /xml # Looks like you failed 1 test of 1. t\test.t .. Dubious, test returned 1 (wstat 256, 0x100) Failed 1/1 subtests Test Summary Report ------------------- t\test.t (Wstat: 256 Tests: 1 Failed: 1) Failed test: 1 Non-zero exit status: 1 Files=1, Tests=1, 1 wallclock secs ( 0.19 usr + 0.14 sys = 0.33 CPU +) Result: FAIL

I wanted to try and write/send a patch for the module, but I realized I have no idea what I'm doing :) Looking at the source for Test::More, I do not understand how TODO blocks work. Looking at the source for Test::XML::XPath, I see that it uses Test::Builder and Test::More, but I have no idea how you would have to write the code to make it compliant with Test::More's TODO, TODO_skip, and SKIP blocks. Can anyone explain a) how the block functionality is implemented in Test::More and b) the proper way to write a testing module that preserves this functionality?

Replies are listed 'Best First'.
Re: TODO blocks for Test::XML, and in general
by MidLifeXis (Monsignor) on Sep 04, 2012 at 17:15 UTC

    Can you add the actual output and what you expect the output to be? For example, on my machine, I get:

    #$ perl -MTest::More -e 'plan "no_plan";TODO:{local $TODO="foo bar"; f +ail("blog");}' not ok 1 - blog # TODO foo bar # Failed (TODO) test 'blog' # at -e line 1. 1..1

    This is a valid TODO test (and a harness would mark the test suite as passed, even though it looks like it has failed). I don't have Test::XML::XPath installed, so just in case this is more of a case of improper expectations, pasting what you are seeing might help.


      I updated it. Running with prove shows that the test causes the entire test suite to fail.

        Stupid question, but does my snippet above emit a TODO test?

        I also rebuilt the like_xpath routine after removing the lines making use of the XPath parser (see below). What output do you get from it?

        use strict; use warnings; use Carp; use Test::More; use Test::Builder; sub like_xpath { my ($input, $statement, $test_name) = @_; die "usage: like_xpath(xml,xpath[,name])" unless $input && $statement; my $Test = Test::Builder->new; my $ok = eval { # Hardcode a failure return 0; }; if ($@) { $Test->ok( 0, $test_name ); $Test->diag( " Parse Failure: $@" ); return 0; } else { ok( $ok, $test_name ); unless ( $ok ) { diag ( " input: $input" ); diag ( " does not match: $statement" ); } return $ok; } } plan tests=>1; TODO: { local $TODO = 'testing todo block'; like_xpath('<xml-bad/>', '/xml', 'test test'); }


Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://991654]
Front-paged by Corion
[Corion]: The inconvenient thing is that my Linux machine is in another room than my desktop, so I have to walk up to it while some device is hooked up to it, just to press "allow" for install tasks etc :-)
[Corion]: I see the Chuwi H9 Air, but at the price of 8 or 9 cheapo tablets, that
[Corion]: ... that's not that great for quasi-disposable devices ;)
[Eily]: can't you just remote connect to the linux machine ?
[marto]: IIRC the hiemdal suite made life much easier on windows, and people on XDA developers put out released of windows only pages for adb that made it less of a pain
[marto]: Eily you can't remote connect the physical device via USB ;)
[Corion]: Eily: Sure, that's what I do, but some things you need to do on the Android device directly, like when navigating the bootloader :-)
[Eily]: marto you just need a longer cable :P
[Corion]: marto: Yeah, but I'm somewhat wary of installing random USB drivers downloaded from , Google Drive or whatever, so Linux wins there due to there being no conflicts and me just having to edit one text file in the worst case, to add the USB vendor
[hippo]: Long USB cable FTW.

How do I use this? | Other CB clients
Other Users?
Others taking refuge in the Monastery: (10)
As of 2018-05-23 09:12 GMT
Find Nodes?
    Voting Booth?